2018-01-19 15:42:43 +00:00
|
|
|
# Ticketfrei social bot
|
2017-06-17 12:57:43 +00:00
|
|
|
|
2018-03-24 10:58:15 +00:00
|
|
|
Version: 2.0beta
|
2018-01-19 15:00:36 +00:00
|
|
|
|
2018-03-24 10:58:15 +00:00
|
|
|
Ticketfrei is a mastodon/twitter/mail bot to dodge ticket controllers in public
|
|
|
|
transport systems.
|
2017-06-17 12:57:43 +00:00
|
|
|
|
2018-05-24 19:58:20 +00:00
|
|
|
The functionality is simple: It retweets every tweet where it is mentioned.
|
2017-06-17 12:57:43 +00:00
|
|
|
|
2018-05-24 19:58:20 +00:00
|
|
|
This leads to a community which evolves around it. If you see ticket
|
|
|
|
controllers, tweet their location and mention the bot. The bot then retweets
|
|
|
|
your tweet and others can read the info and think twice whether they want to
|
|
|
|
buy a ticket or not. If enough people, a critical mass, participate for the bot
|
|
|
|
to become reliable, you have positive self-reinforcing dynamics.
|
2017-06-17 12:57:43 +00:00
|
|
|
|
2018-03-24 10:58:15 +00:00
|
|
|
Today, 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.
|
2017-06-17 12:57:43 +00:00
|
|
|
|
2018-03-24 10:58:15 +00:00
|
|
|
In version 2, this bot has received a frontend website. On this website, people
|
|
|
|
can register an own bot for their city - the website manages multiple bots for
|
|
|
|
multiple citys. This way, you do not have to host it yourself.
|
2017-06-17 12:57:43 +00:00
|
|
|
|
2018-05-24 19:58:20 +00:00
|
|
|
In the promotion folder, you'll find some promotion material you can use to
|
|
|
|
build up such a community in your city. Unfortunately it is in german - but
|
|
|
|
it's editable, feel free to translate it!
|
2017-06-17 12:57:43 +00:00
|
|
|
|
2018-05-24 19:58:20 +00:00
|
|
|
Website: https://ticketfrei.links-tech.org
|
2018-01-19 15:00:36 +00:00
|
|
|
|
2018-03-24 10:58:15 +00:00
|
|
|
More information: https://wiki.links-tech.org/IT/Ticketfrei
|
2017-11-28 14:11:09 +00:00
|
|
|
|
2018-03-24 10:58:15 +00:00
|
|
|
## Do you want Ticketfrei in your city?
|
2017-07-11 19:51:37 +00:00
|
|
|
|
2018-05-24 19:58:20 +00:00
|
|
|
Just go to https://ticketfrei.links-tech.org or another website where this software is
|
2018-03-24 10:58:15 +00:00
|
|
|
running.
|
2017-11-28 14:11:09 +00:00
|
|
|
|
2018-03-24 10:58:15 +00:00
|
|
|
* Register a twitter account
|
|
|
|
* Register a Mastodon account
|
|
|
|
* Register on the ticketfrei site
|
|
|
|
* Configure account
|
|
|
|
* The hard part: do the promotion! You need a community.
|
2017-11-28 14:11:09 +00:00
|
|
|
|
2018-03-24 10:58:15 +00:00
|
|
|
### Maintaining
|
2018-01-19 15:00:36 +00:00
|
|
|
|
2018-05-24 19:58:20 +00:00
|
|
|
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. That way, 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.
|
2018-01-19 15:00:36 +00:00
|
|
|
|
2018-03-24 10:58:15 +00:00
|
|
|
To this date, we have never heard of this happening though.
|
2018-01-19 15:00:36 +00:00
|
|
|
|
2018-09-13 17:54:51 +00:00
|
|
|
### blockisting
|
2018-01-19 15:00:36 +00:00
|
|
|
|
2018-09-13 17:54:51 +00:00
|
|
|
You also need to edit the goodlist and the blocklist. You can do this on the
|
2018-03-24 10:58:15 +00:00
|
|
|
website, in the settings of your bot.
|
2018-01-19 15:00:36 +00:00
|
|
|
|
2018-03-24 10:58:15 +00:00
|
|
|
Just add the words to the goodlist, which you want to require. A report is only
|
2018-05-24 19:58:20 +00:00
|
|
|
spread if it contains at least one of them. If you want to RT everything, just
|
2018-03-24 10:58:15 +00:00
|
|
|
add a ```*```.
|
2017-06-17 22:35:34 +00:00
|
|
|
|
2018-09-13 17:54:51 +00:00
|
|
|
There is also a blocklist, which you can use to automatically sort out
|
2018-05-24 19:58:20 +00:00
|
|
|
malicious messages. Be careful though, our filter can't read the intention with
|
2018-03-24 10:58:15 +00:00
|
|
|
which a word was used. Maybe you wanted it there.
|
2017-10-17 13:27:24 +00:00
|
|
|
|
2018-03-24 10:58:15 +00:00
|
|
|
## Do you want to offer a Ticketfrei website to others?
|
2017-06-17 23:44:22 +00:00
|
|
|
|
2018-03-24 10:58:15 +00:00
|
|
|
If you want to offer this website to others, feel free to do so. If you have questions, just open
|
|
|
|
a GitHub issue or write to tech@lists.links-tech.org, we are happy to help and share best practices.
|
2017-06-17 23:44:22 +00:00
|
|
|
|
2018-03-24 10:58:15 +00:00
|
|
|
We wrote these installation notes, so you can set up the website easily:
|
2017-06-17 12:57:43 +00:00
|
|
|
|
2018-03-24 10:58:15 +00:00
|
|
|
### Install
|
2017-10-17 13:27:24 +00:00
|
|
|
|
2018-03-24 10:58:15 +00:00
|
|
|
To Do:
|
2017-07-23 13:47:23 +00:00
|
|
|
|
|
|
|
```shell
|
2018-09-23 16:53:46 +00:00
|
|
|
sudo apt install python3 virtualenv uwsgi uwsgi-plugin-python3 nginx git exim4
|
2018-03-27 18:02:47 +00:00
|
|
|
cd /srv
|
|
|
|
sudo git clone https://github.com/b3yond/ticketfrei
|
|
|
|
cd ticketfrei
|
2017-07-23 13:47:23 +00:00
|
|
|
```
|
|
|
|
|
2018-03-24 10:58:15 +00:00
|
|
|
Install the necessary packages, create and activate virtualenv:
|
2018-02-16 11:02:58 +00:00
|
|
|
|
2018-03-24 10:58:15 +00:00
|
|
|
```shell
|
|
|
|
virtualenv -p python3 .
|
|
|
|
. bin/activate
|
|
|
|
```
|
|
|
|
|
|
|
|
Install the dependencies:
|
|
|
|
|
|
|
|
```shell
|
2018-09-09 12:26:46 +00:00
|
|
|
pip install tweepy pytoml Mastodon.py bottle pyjwt pylibscrypt Markdown twx
|
2018-03-24 10:58:15 +00:00
|
|
|
```
|
2018-02-16 11:02:58 +00:00
|
|
|
|
2018-03-24 10:58:15 +00:00
|
|
|
Configure the bot:
|
2018-02-16 11:02:58 +00:00
|
|
|
|
2018-03-24 10:58:15 +00:00
|
|
|
```shell
|
|
|
|
cp config.toml.example config.toml
|
|
|
|
vim config.toml
|
2018-02-16 11:02:58 +00:00
|
|
|
```
|
2018-03-24 10:58:15 +00:00
|
|
|
|
|
|
|
This configuration is only for the admin. Users can log into
|
|
|
|
twitter/mastodon/mail and configure their personal bot on the settings page.
|
|
|
|
|
2018-03-27 18:02:47 +00:00
|
|
|
Set up LetsEncrypt:
|
|
|
|
```shell
|
|
|
|
sudo apt-get install python-certbot-nginx -t stretch-backports
|
|
|
|
sudo certbot --authenticator webroot --installer nginx --agree-tos --redirect --hsts
|
|
|
|
```
|
|
|
|
|
2018-09-23 16:53:46 +00:00
|
|
|
Configure exim4 for using mbox files.
|
|
|
|
|
|
|
|
```
|
|
|
|
sudo dpkg-reconfigure exim4-config
|
|
|
|
# Choose the following values:
|
|
|
|
# internet site; mail is sent and received directly using SMTP
|
|
|
|
# your domain name
|
|
|
|
#
|
|
|
|
# your domain name
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# No
|
|
|
|
# mbox format in /var/mail/
|
|
|
|
# No
|
|
|
|
```
|
|
|
|
|
2018-03-26 23:04:07 +00:00
|
|
|
Deploy ticketfrei with uwsgi:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
echo "Enter your domain name into the following prompt:" && read DOMAIN
|
|
|
|
|
|
|
|
# configure nginx
|
|
|
|
sudo sed -r "s/example.org/$DOMAIN/g" deployment/example.org.conf > /etc/nginx/sites-enabled/$DOMAIN.conf
|
|
|
|
|
2018-05-28 20:26:07 +00:00
|
|
|
# create folder for socket & database
|
2018-04-15 07:41:27 +00:00
|
|
|
sudo mkdir /var/ticketfrei
|
|
|
|
sudo chown www-data:www-data -R /var/ticketfrei
|
2018-05-28 20:26:07 +00:00
|
|
|
|
|
|
|
# create folder for logs
|
|
|
|
sudo mkdir /var/log/ticketfrei
|
2018-03-27 18:02:47 +00:00
|
|
|
sudo chown www-data:www-data -R /var/log/ticketfrei
|
2018-03-26 23:04:07 +00:00
|
|
|
|
|
|
|
# start up nginx
|
|
|
|
sudo service nginx restart
|
|
|
|
|
|
|
|
# create and start the frontend systemd service
|
|
|
|
sudo cp deployment/ticketfrei-web.service /etc/systemd/system/
|
|
|
|
sudo systemctl daemon-reload
|
|
|
|
sudo systemctl start ticketfrei-web.service
|
2018-07-14 15:17:36 +00:00
|
|
|
|
|
|
|
# create and start the backend systemd service
|
|
|
|
sudo cp deployment/ticketfrei-backend.service /etc/systemd/system
|
|
|
|
sudo systemctl daemon-reload
|
|
|
|
sudo systemctl start ticketfrei-backend.service
|
2018-03-26 23:04:07 +00:00
|
|
|
```
|
2018-03-27 18:02:47 +00:00
|
|
|
|
|
|
|
### Logs
|
|
|
|
|
|
|
|
There are several logfiles which you can look at:
|
|
|
|
|
|
|
|
```
|
|
|
|
# for the uwsgi deployment:
|
|
|
|
less /var/log/ticketfrei/uwsgi.log
|
|
|
|
|
2018-04-15 09:26:48 +00:00
|
|
|
# for the backend:
|
|
|
|
less /var/log/ticketfrei/backend.log
|
|
|
|
|
2018-03-27 18:02:47 +00:00
|
|
|
# for the systemd service:
|
|
|
|
less /var/log/syslog
|
|
|
|
|
|
|
|
# for the nginx web server:
|
|
|
|
less /var/log/nginx/example.org_error.log
|
|
|
|
```
|
2018-06-23 22:24:01 +00:00
|
|
|
|
|
|
|
### Development Install
|
|
|
|
|
|
|
|
If you want to install it locally to develop on it:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
sudo apt install python3 virtualenv uwsgi uwsgi-plugin-python3 nginx git
|
|
|
|
sudo git clone https://github.com/b3yond/ticketfrei
|
|
|
|
cd ticketfrei
|
2018-06-23 22:26:00 +00:00
|
|
|
git checkout multi-deployment
|
2018-06-23 22:24:01 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Install the necessary packages, create and activate virtualenv:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
virtualenv -p python3 .
|
|
|
|
. bin/activate
|
|
|
|
```
|
|
|
|
|
|
|
|
Install the dependencies:
|
|
|
|
|
|
|
|
```shell
|
2018-09-09 12:26:46 +00:00
|
|
|
pip install tweepy pytoml Mastodon.py bottle pyjwt pylibscrypt Markdown twx
|
2018-06-23 22:24:01 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Configure the bot:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
cp config.toml.example config.toml
|
|
|
|
vim config.toml
|
|
|
|
```
|
|
|
|
|
|
|
|
This configuration is only for the admin. Users can log into
|
|
|
|
twitter/mastodon/mail and configure their personal bot on the settings page.
|
|
|
|
|
|
|
|
```shell
|
|
|
|
# create folder for socket & database
|
|
|
|
sudo mkdir /var/ticketfrei
|
|
|
|
sudo chown $USER:$USER -R /var/ticketfrei
|
|
|
|
|
|
|
|
# create folder for logs
|
|
|
|
sudo mkdir /var/log/ticketfrei
|
|
|
|
sudo chown $USER:$USER -R /var/log/ticketfrei
|
|
|
|
|
|
|
|
# start Ticketfrei
|
|
|
|
./frontend.py & ./backend.py &
|
|
|
|
```
|
|
|
|
|