a micro-messaging bot to organize using public transport without having to pay.
Go to file
2018-03-22 10:05:49 +01:00
appkeys implement basic auto-reblogging 2017-06-17 18:15:13 +02:00
blacklists blacklisted certain racist slurs 2018-01-07 01:33:10 +01:00
frontend added mastodon oauth dance 2018-03-20 21:24:20 +01:00
goodlists change goodlist to regex patterns 2017-06-25 21:12:26 +02:00
guides invented a campaign 2017-10-11 22:22:53 +02:00
logs added empty logs folder 2017-07-20 22:37:34 +02:00
promotion added OpenGraph data, started enable button 2018-03-16 09:51:10 +01:00
static start refactoring web-frontend. 2018-03-22 02:23:31 +01:00
template start refactoring web-frontend. 2018-03-22 02:23:31 +01:00
.gitignore gitignore readd. how do I prevent ticketfrei.sqlite from updating the stub in the repo? 2018-02-16 11:46:10 +01:00
config.toml.example fix sqlite commands, rename to website.py 2018-01-26 15:19:03 +01:00
db.py unified formatting of db_init SQL 2018-03-22 10:05:49 +01:00
LICENSE add license 2017-10-17 00:14:57 +02:00
mailbot.py excepted IMAP4 error with unknown cause 2018-01-23 09:17:26 +01:00
README.md create db manually 2018-02-16 12:02:58 +01:00
report.py Standardized reports; moved flow() logic to crawl(), repost(), & post(); bots don't own Trigger anymore 2018-01-18 11:41:08 +01:00
retootbot.py excepted Mastodon API Error with a too broad exception 2018-01-19 00:17:09 +01:00
retweetbot.py excepted TweepError that was raised without an explanation further than 503 2018-01-18 21:48:36 +01:00
sendmail.py started an IMAP listener to implement a 3rd bot: the Mailbot. 2018-01-05 14:16:24 +01:00
ticketfrei-web.py start refactoring web-frontend. 2018-03-22 02:23:31 +01:00
ticketfrei.py updated README to version 1.0. you can disable accounts now 2018-01-19 16:00:36 +01:00
ticketfrei.sqlite-journal complete db create statement 2018-03-22 09:51:50 +01:00
trigger.py Renamed config file to config.toml 2017-12-30 10:32:20 +01:00

Ticketfrei social bot

Version: 1.0

Ticketfrei is a mastodon/twitter/mail bot to dodge ticket controllers in public transport systems.

The functionality is simple: it retweets every tweet where it is mentioned.

This leads to a community which evolves around it; if you see ticket controllers, you tweet their location and mention the bot. The bot then retweets your tweet and others can read the info and think twice if they want to buy a ticket. If enough people, a critical mass, participate for the bot to become reliable, you have positive self-reinforcing dynamics.

In the promotion folder, you will find some promotion material you can use to build up such a community in your city. It is in german though =/

Website: https://wiki.links-tech.org/IT/Ticketfrei

Install

Setting up a ticketfrei bot for your city is quite easy. Here are the few steps:

First you need to install python3 and virtualenv with your favourite package manager.

Create and activate virtualenv:

sudo apt install python3 virtualenv uwsgi uwsgi-plugin-python nginx
virtualenv -p python3 .
. bin/activate

Install the dependencies:

pip install tweepy pytoml requests Mastodon.py bottle pyjwt 

Configure the bot:

cp config.toml.example config.toml
vim config.toml

You can use a Twitter, a Mastodon, and Mail with the account. They will communicate with each other; if someone warns others via Mail, Twitter and Mastodon users will also see the message. And vice versa.

You have to configure all of the accounts via config.toml; it should be fairly intuitive to enter the right values.

Maintaining

There is one security hole: people could start mentioning the bot with useless information, turning it into a spammer. That's why it has to be maintained; if someone spams the bot, mute them and undo the retweet. So it won't retweet their future tweets and the useless retweet is deleted if someone tries to check if something was retweeted in the last hour or something.

To this date, we have never heard of this happening though.

blacklisting

You also need to edit the goodlist and the blacklist. They are in the "goodlists" and "blacklists" folders. All text files in those directories will be used, so you should delete our templates; but feel free to use them as an orientation.

Just add the words to the goodlist, which you want to require. A report is only spread, if it contains at least one of them. If you want to RT everything, just add a *.

There is also a blacklist, which you can use to automatically sort out malicious tweets. Be careful though, our filter can't read the intention with which a word was used. Maybe you wanted it there.

screen

To keep the bots running when you are logged out of the shell, you can use screen:

sudo apt-get install screen 
echo "if [ -z "$STY" ]; then screen -RR; fi" >> ~/.bash_login
screen
python3 ticketfrei.py

To log out of the screen session, press "ctrl+a", and then "d".

Manually creating the database

Unfortunately, if you want to help developing, you have to create the database manually for now.

At the moment, we use a SQLITE3 database. If you are in the repo directory, just open it with sqlitebrowser ticketfrei.sqlite. Then execute following SQL to create the tables:

CREATE TABLE `user` (
    `id`    INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
    `email` TEXT,
    `pass_hashed`   TEXT,
    `enabled`   INTEGER
)