Compare commits
353 Commits
Author | SHA1 | Date |
---|---|---|
b3yond | 47da8415df | |
b3yond | 400e15d18a | |
b3yond | 55db252f44 | |
b3yond | f64142d882 | |
b3yond | f286c127ba | |
b3yond | 4428fa932f | |
b3yond | cc5ab22be5 | |
b3yond | 56e948b798 | |
b3yond | c36b8ab673 | |
b3yond | 17df4f15e4 | |
b3yond | b5de7cde9f | |
b3yond | 8eb2d98c03 | |
b3yond | 9836ec7752 | |
b3yond | 9e8cfa624c | |
b3yond | 084049bbfe | |
b3yond | 6a8cf5c6af | |
b3yond | de657ba350 | |
b3yond | bbe27e2586 | |
b3yond | 9a3c09b119 | |
b3yond | 30de2196ac | |
b3yond | 9ca521493a | |
b3yond | 0449d892a3 | |
b3yond | f59be986e2 | |
b3yond | 79d5a6f112 | |
b3yond | 9800b52153 | |
b3yond | 54930a32f6 | |
b3yond | 0b862e35c8 | |
b3yond | 13fcb41148 | |
b3yond | d3d7bd098d | |
b3yond | 8a4cc17575 | |
b3yond | 3d669e6caf | |
b3yond | e032ecbcc3 | |
b3yond | 30f1f8a21c | |
b3yond | 942f19fefe | |
b3yond | 5119c6bfbb | |
b3yond | 2068b99b87 | |
b3yond | 4851fc0b63 | |
b3yond | b9a4899981 | |
b3yond | 304d83ffad | |
b3yond | 9b3efd7bd2 | |
b3yond | 24598f0b87 | |
b3yond | dc8f51c632 | |
b3yond | 34d43f1911 | |
b3yond | 2a4d517f1d | |
b3yond | 2d12aa7107 | |
b3yond | 47a7452eb4 | |
b3yond | 234ed59049 | |
b3yond | 5efea773b8 | |
b3yond | 3b19278774 | |
b3yond | 03033d26d7 | |
b3yond | b35e885ae2 | |
b3yond | d61d5750bb | |
b3yond | aa9267e8d1 | |
b3yond | 732ac1c5d3 | |
b3yond | b94ead7041 | |
b3yond | b20a080129 | |
b3yond | 1412dbc54c | |
b3yond | f28df3ce3e | |
b3yond | 0cf1d8b603 | |
b3yond | 244bde51b6 | |
b3yond | 36c21dbfbb | |
b3yond | f360c4f8fd | |
b3yond | fcab07246b | |
b3yond | 11f3c5713b | |
b3yond | 1a793657af | |
b3yond | e9ac7286d9 | |
b3yond | 823df7b04a | |
git-sid | 1703eb3802 | |
git-sid | 72d6798022 | |
git-sid | c2ed73bafc | |
git-sid | c576888da5 | |
b3yond | 25bfe8e838 | |
b3yond | eae077cb9b | |
b3yond | 91181e1cf8 | |
b3yond | 6757e62242 | |
b3yond | c37a447392 | |
b3yond | 3e83ba95da | |
b3yond | faaf8ac5f4 | |
b3yond | a54538bcea | |
b3yond | 6f3c953736 | |
b3yond | 0624bcb378 | |
b3yond | 6cac81e444 | |
git-sid | f68a869309 | |
b3yond | a0bd5e69e1 | |
b3yond | 4b953f54e5 | |
git-sid | 8acbfb4569 | |
b3yond | 439dbeb1fa | |
b3yond | fd8b29c55f | |
b3yond | f1d7215eba | |
b3yond | 4586e14ee4 | |
b3yond | 40c834020a | |
git-sid | b85360b0a8 | |
git-sid | 185014a452 | |
b3yond | b5f6854a1c | |
b3yond | 7ca904564c | |
b3yond | b80b80dc43 | |
b3yond | 96329e968e | |
b3yond | c7aa87cb3b | |
b3yond | ad4e65e0fa | |
b3yond | 9c599cec37 | |
b3yond | 848b7b1cb5 | |
Jorge Maldonado Ventura | 0ffe4daac8 | |
b3yond | 372e0612a6 | |
b3yond | 57a2e4dcb1 | |
b3yond | ec399db2eb | |
b3yond | ef0ce8f9f1 | |
b3yond | 27b63d9f8f | |
b3yond | cc0b3378a9 | |
b3yond | d002969377 | |
b3yond | 1f0583da74 | |
b3yond | e1eb737ad0 | |
b3yond | 9beb864a2f | |
b3yond | a05205289f | |
b3yond | 89fce872f3 | |
b3yond | d7eba3d233 | |
b3yond | 10b3550ad6 | |
b3yond | 2d879383d4 | |
b3yond | 4343be7e06 | |
b3yond | 55a804f0d6 | |
b3yond | cae74a5715 | |
b3yond | 3d23b47a6e | |
sid | 57a4a50254 | |
sid | a8504971ea | |
b3yond | 9db71e485d | |
b3yond | 8dfffffe76 | |
b3yond | 4fb2930c6c | |
b3yond | fd8f236cdd | |
b3yond | 44cd1308ba | |
b3yond | 4c6ab2d3ae | |
b3yond | 0719b094f8 | |
sid | a48ba9ebf8 | |
sid | 4b37c0df3d | |
b3yond | 83d8700e30 | |
sid | 86d63fe9a0 | |
b3yond | bfd9a2d5fe | |
b3yond | 7543bf3e6e | |
b3yond | cd5eeb3917 | |
b3yond | f4736c91dd | |
b3yond | 559b709b8f | |
b3yond | 628fcb4f95 | |
b3yond | 2a9c5c657f | |
b3yond | c9dfb6611a | |
b3yond | 04a6b82c1b | |
sid | 29a577508f | |
b3yond | d4d58daf40 | |
b3yond | 48d44cf698 | |
b3yond | 9274dfdecb | |
b3yond | 5ec4d1aab0 | |
b3yond | 62eb588b28 | |
b3yond | 9885e39d68 | |
b3yond | 01b3657c8e | |
Tech | 6996cbfc09 | |
b3yond | 591020f8cc | |
b3yond | d706c4f1cc | |
Thomas L | 642cf429e5 | |
b3yond | dd24a2b265 | |
b3yond | 3afa73ccaf | |
b3yond | 1a76cba4fb | |
b3yond | 84746a6d01 | |
b3yond | 064ca181c0 | |
b3yond | 16580f3181 | |
b3yond | 7f8697947c | |
b3yond | 758ff1db46 | |
b3yond | 9b01ac7eac | |
b3yond | 898f229145 | |
b3yond | 0b41b43421 | |
b3yond | 24beedf467 | |
Thomas L | fd2a389d12 | |
b3yond | 25c57039ea | |
b3yond | 20cfe159e9 | |
Thomas L | 57cf3bd7d6 | |
Thomas L | 1af14a5db4 | |
Thomas L | 22de5e7e4e | |
b3yond | 4d556ec595 | |
b3yond | bf7c21c113 | |
b3yond | 45d4cd2062 | |
b3yond | 034513718f | |
b3yond | 261496c097 | |
b3yond | 19cc64d00d | |
b3yond | 27497e7129 | |
Thomas L | d280130b29 | |
Thomas L | 78331212e6 | |
b3yond | 10fb150c21 | |
b3yond | 29c35be8a5 | |
Thomas L | bfc311b6c9 | |
Thomas L | 4981223ee8 | |
Thomas L | 9339015101 | |
Thomas L | 4850860f82 | |
b3yond | c9fd91de74 | |
b3yond | affd209a3b | |
b3yond | ca55223be9 | |
b3yond | 5670c92d33 | |
Thomas L | 2b6b3a2263 | |
b3yond | 0aa1d79621 | |
b3yond | 788f55860b | |
b3yond | ba6e13a2be | |
Thomas L | 8e08eb9c2e | |
b3yond | c71bc8574a | |
b3yond | bc41d7460c | |
b3yond | 9425fde917 | |
Thomas L | 88afab1270 | |
Tech | 5db529702c | |
b3yond | 66bb1f86a3 | |
b3yond | 49bd00fba3 | |
b3yond | ec3053a0ab | |
Tech | 036c742f34 | |
Thomas L | 1dd75c10d5 | |
Thomas L | 890e720c91 | |
Tech | a3e33c36c6 | |
Tech | 670a1a6d8f | |
b3yond | 51dec7e072 | |
Tech | c3f9f86d3f | |
b3yond | 2d7b222c21 | |
Tech | dde4e6af7b | |
Thomas L | cb764f2ec3 | |
b3yond | d207d4e960 | |
b3yond | 5d2ffbd935 | |
d24phant | ce79b37b38 | |
d24phant | 2fdc6f1f28 | |
d24phant | f99b44d815 | |
d24phant | c980e7abb5 | |
b3yond | 95ada7ba62 | |
b3yond | 9ac7ab3b70 | |
b3yond | 64f1fff275 | |
Thomas L | 3ea06d1e93 | |
Thomas L | daf6fe831f | |
Thomas L | 751f9154cc | |
b3yond | 061fb62bdc | |
Tech | 305fb8e06a | |
b3yond | ba9b28f254 | |
b3yond | a8efcd7825 | |
b3yond | 17d044ec20 | |
b3yond | be118fb4bd | |
b3yond | aa5669b019 | |
b3yond | 5f55eb88ff | |
b3yond | c548a81272 | |
b3yond | a65d410e4f | |
b3yond | 570792ba37 | |
b3yond | c612a9dee0 | |
b3yond | bd2599c91a | |
b3yond | 81e2357e2f | |
b3yond | a3b74dcfff | |
b3yond | 32e86a3c0e | |
b3yond | b9613a60de | |
Thomas L | 404be47d1b | |
b3yond | 235b8524f8 | |
b3yond | 9e09dcea84 | |
b3yond | c48704ea73 | |
b3yond | cdc88e3ee3 | |
b3yond | ee8040893e | |
b3yond | 390f4dc76e | |
b3yond | a176f856d8 | |
b3yond | 529270a396 | |
Thomas L | 3f4ec83abe | |
b3yond | f9033a009f | |
b3yond | eb0252f235 | |
b3yond | 9cc2bf4228 | |
b3yond | 28891d5069 | |
b3yond | 9e70ff6866 | |
b3yond | 87302faf9e | |
b3yond | 8a7c2f0110 | |
b3yond | 7bbcbe1ab1 | |
b3yond | 4b21dddddf | |
b3yond | 26d1282413 | |
b3yond | 79f301d823 | |
b3yond | 2ce2a45f7b | |
b3yond | 52c2d1e341 | |
b3yond | 1f01938a8c | |
b3yond | a7bae0aed9 | |
b3yond | 1b75e03fc5 | |
b3yond | 7ccf6917c8 | |
b3yond | 2e89f9bf2d | |
b3yond | fb36221a40 | |
b3yond | 0c04ce4b70 | |
b3yond | 1e0a8a09ed | |
b3yond | 27902954e8 | |
b3yond | 821f201454 | |
b3yond | 9e221ed290 | |
b3yond | 3bc1010edf | |
b3yond | 0ba2438541 | |
b3yond | 0acb89ebf0 | |
b3yond | c9d5f7441a | |
b3yond | ace28ee25a | |
b3yond | 63cf134ffa | |
b3yond | c0328be3a4 | |
b3yond | c9e6a35372 | |
b3yond | 04e05ee8ca | |
b3yond | 37b2706a3b | |
b3yond | 9305a32eb7 | |
b3yond | 12fbbde79c | |
b3yond | 21e4af6fa9 | |
b3yond | c8e67d1937 | |
b3yond | 10de40549c | |
b3yond | ee61ba19e6 | |
b3yond | 72d0acb20a | |
b3yond | b174db3cfe | |
b3yond | 048bad181b | |
b3yond | b5288f341c | |
b3yond | 75e1ff902c | |
b3yond | d6a0c6d377 | |
b3yond | cde5494de3 | |
b3yond | ff73c5dc21 | |
b3yond | 9ef0b27970 | |
b3yond | 9f060b405e | |
b3yond | 5feb6cf5be | |
b3yond | da421769e9 | |
b3yond | 89ce129b38 | |
b3yond | 2f74791dd6 | |
b3yond | 2e80d10222 | |
b3yond | 2b4d8650c9 | |
b3yond | 7689eb25f8 | |
Thomas L | f2a0cf18b4 | |
Thomas L | f0aaa4dc54 | |
b3yond | b9e1b38963 | |
b3yond | 409f9e80f8 | |
b3yond | 851992803f | |
b3yond | 79a8965d1c | |
b3yond | a0ca940008 | |
b3yond | 5c98aa7677 | |
b3yond | 01ad0e1c40 | |
b3yond | e962bbbe85 | |
b3yond | 0b89a52da3 | |
b3yond | 31a54fc19f | |
b3yond | 654af44534 | |
b3yond | 8357be7f7d | |
b3yond | 98dd5e4212 | |
b3yond | aa45a8e814 | |
b3yond | 0f6fc60b5e | |
b3yond | df32f3c614 | |
b3yond | d7dea7df00 | |
b3yond | 96ef5e2a3f | |
b3yond | e64e3702f6 | |
Thomas L | 594b3fb5de | |
b3yond | d22c85da1b | |
b3yond | 4aa4846527 | |
b3yond | 7a1a857ab4 | |
b3yond | cbf16b8f74 | |
b3yond | fb24c758a8 | |
b3yond | 15d2c75b5a | |
b3yond | 2c21fb09ca | |
b3yond | 42aa60a968 | |
b3yond | a4eef4b086 | |
b3yond | 9e38906898 | |
b3yond | b1348e5578 | |
b3yond | 1ee464cf97 | |
b3yond | 3ee52532d2 | |
b3yond | 357d6c4fc2 | |
b3yond | 36f919826f | |
b3yond | 694a930d73 | |
b3yond | d6a94432c8 | |
Thomas L | aefe78eb50 | |
b3yond | 150e3579b7 | |
ng0 | f4b8300ac1 |
|
@ -1,27 +0,0 @@
|
|||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
|
||||
---
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Actual Behavior**
|
||||
A clear and concise description of what happens.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Ticketfrei Version**
|
||||
See the commit on which Ticketfrei is running at example.org/version.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
|
@ -1,17 +0,0 @@
|
|||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
|
@ -1,7 +0,0 @@
|
|||
---
|
||||
name: Something else
|
||||
about: Other ideas?
|
||||
|
||||
---
|
||||
|
||||
*If your suggestion is neither a bug report nor a feature request, this is the right place. Just describe what you have in mind.*
|
|
@ -0,0 +1,84 @@
|
|||
Ticketfrei Community Code of Conduct
|
||||
====================================
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers strive to make participation in the Ticketfrei
|
||||
community a pleasurable, harassment-free experience.
|
||||
|
||||
|
||||
Our Standards
|
||||
-------------
|
||||
|
||||
Examples of behavior that contribute to creating a positive environment include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Showing empathy towards community members and newcomers
|
||||
* Helping and mediating in cases of upsets or conflict
|
||||
|
||||
Examples of behavior which we ask everybody to avoid include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
||||
* Trolling, insulting/derogatory comments, and personal attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other behaviour which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
We recognize that sometimes people may have a bad day, or may be unaware of
|
||||
the impact of their behaviour. When that happens, you may carefully remind
|
||||
them in public or private, whatever is more appropriate. Assume good faith;
|
||||
it's more likely that participants are unaware than that they are intentionally
|
||||
trying to denigrate others or reduce the quality of discussion.
|
||||
|
||||
|
||||
Maintainers and Responsibilities
|
||||
--------------------------------
|
||||
|
||||
Project maintainers are those with commit rights to Ticketfrei. Each
|
||||
maintainer is asked to take responsibility and appropriate, careful action in
|
||||
response to witnessed instances of questionable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct.
|
||||
|
||||
They may also ban temporarily or permanently a contributor for other behaviors
|
||||
that they deem inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
Scope
|
||||
-----
|
||||
|
||||
This Code of Conduct applies both within project communication channels and
|
||||
gatherings as well as in public spaces when an individual is representing the
|
||||
project or its community. Examples of representing a project or community
|
||||
include using an official project e-mail address, posting via an official
|
||||
social media account, or acting as an representative at an online or offline
|
||||
event.
|
||||
|
||||
Reporting and Responses
|
||||
-----------------------
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting select project maintainers, currently
|
||||
tech@lists.links-tech.org. They will review reports and involve other
|
||||
maintainers as appropriate, resulting in a response that is deemed neccessary
|
||||
and appropriate to the circumstances.
|
||||
|
||||
Maintainers are obligated to maintain confidentiality with regard to the
|
||||
reporter of an incident. Maintainers are themselves not exempt from being
|
||||
reported about and may face temporary or permanent repercussions as determined
|
||||
by other maintainers.
|
||||
|
||||
|
||||
Attribution
|
||||
-----------
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at [http://contributor-covenant.org/version/1/4][version]
|
||||
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/4/
|
||||
|
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
|||
Copyright (c) 2017 Thomas L <tom@dl6tom.de>
|
||||
Copyright (c) 2017 b3yond <b3yond@riseup.net>
|
||||
Copyright (c) 2018 sid <sid-sid@riseup.net>
|
||||
Copyright (c) 2018 sid
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
151
README.md
151
README.md
|
@ -3,23 +3,6 @@
|
|||
Ticketfrei is a mastodon/twitter/mail bot to dodge ticket controllers in public
|
||||
transport systems.
|
||||
|
||||
## Mission
|
||||
|
||||
Public transportation is meant to provide an easy and time-saving way to move
|
||||
within a region while being affordable for everybody. Unfortunately, this is
|
||||
not yet the case. Ticketfrei's approach is to **enable people to reclaim public
|
||||
transportation.**
|
||||
|
||||
On short term we want to do this by helping users to avoid controllers and
|
||||
fines - on long term by **pressuring public transportation companies to offer
|
||||
their services free of charge**, financed by the public.
|
||||
|
||||
Because with Ticketfrei you're able to use trains and subways for free anyway.
|
||||
Take part and create a new understanding of what public transportation could
|
||||
look like!
|
||||
|
||||
## How It Works
|
||||
|
||||
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
|
||||
|
@ -108,7 +91,7 @@ virtualenv -p python3 .
|
|||
Install the dependencies:
|
||||
|
||||
```shell
|
||||
pip install tweepy pytoml Mastodon.py bottle pyjwt pylibscrypt Markdown twx gitpython
|
||||
pip install tweepy pytoml Mastodon.py bottle pyjwt pylibscrypt Markdown twx
|
||||
```
|
||||
|
||||
Configure the bot:
|
||||
|
@ -152,19 +135,10 @@ 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
|
||||
|
||||
# create folder for database
|
||||
# create folder for socket & database
|
||||
sudo mkdir /var/ticketfrei
|
||||
sudo chown www-data:www-data -R /var/ticketfrei
|
||||
|
||||
# create folder for socket
|
||||
sudo mkdir /var/run/ticketfrei
|
||||
sudo chown -R www-data:www-data /var/run/ticketfrei
|
||||
sudo -s
|
||||
echo "mkdir /var/run/ticketfrei" >> /etc/rc.local
|
||||
echo "chown -R www-data:www-data /var/run/ticketfrei" >> /etc/rc.local
|
||||
echo "service ticketfrei-web restart" >> /etc/rc.local
|
||||
exit
|
||||
|
||||
# change /etc/aliases permissions to be able to receive reports per mail
|
||||
sudo chown root:www-data /etc/aliases
|
||||
sudo chmod 664 /etc/aliases
|
||||
|
@ -187,17 +161,6 @@ sudo systemctl daemon-reload
|
|||
sudo systemctl start ticketfrei-backend.service
|
||||
```
|
||||
|
||||
### Backup
|
||||
|
||||
For automated backups, you need to backup these files:
|
||||
|
||||
* `/var/ticketfrei/db.sqlite`
|
||||
* `/srv/ticketfrei/config.toml`
|
||||
* `/etc/aliases`
|
||||
|
||||
You can find an example how to do this with borgbackup in the deployment
|
||||
folder. Adjust it to your needs.
|
||||
|
||||
### Logs
|
||||
|
||||
There are several logfiles which you can look at:
|
||||
|
@ -267,113 +230,3 @@ sudo chown $USER:$USER -R /var/log/ticketfrei
|
|||
./frontend.py & ./backend.py &
|
||||
```
|
||||
|
||||
# Project History
|
||||
|
||||
## Version 1
|
||||
|
||||
- more of less hacked together during a mate-fueled weekend
|
||||
- backend-only, twitter & mastodon
|
||||
- just a script, which crawled & retweeted tweets, if they match a whitelist & blocklist
|
||||
- whitelist & blocklist were just 2 files
|
||||
|
||||
## Version 2
|
||||
|
||||
Reasons for the rewrite:
|
||||
- user management: Users should be able to run a Ticketfrei bot in their city
|
||||
- without needing a server, without needing command line skills
|
||||
- more networks; not only Twitter & Mastodon, also Email & Telegram
|
||||
|
||||
2 processes: backend & frontend.
|
||||
The two Processes talk via a database.
|
||||
The two Processes have separate log files.
|
||||
Both processes take some config values from config.toml.
|
||||
|
||||
### Backend
|
||||
|
||||
The Backend takes care of crawling & spreading the reports.
|
||||
|
||||
backend.py:
|
||||
- main loop which does the crawling & posting.
|
||||
- loops through all cities in the database
|
||||
- per city it tries all of the networks/bots:
|
||||
- per network/bot it runs the crawl()-function to ask the social network for new reports
|
||||
- then it checks whether the report is appropriate
|
||||
- if yes, it posts the report via all networks/bots, which belong to the city.
|
||||
|
||||
config.py: imports config values
|
||||
- Imports values from config.toml
|
||||
- If there is no config file it tries to use environment variables,
|
||||
- Apart from that it uses the default values.
|
||||
|
||||
bot.py: bot parent Class
|
||||
- just the absolute minimum what a bot needs to be able to do: crawl + post
|
||||
- is never instantiated, only inherited from
|
||||
|
||||
report.py: report Class
|
||||
- defines how reports are supposed to look like
|
||||
|
||||
active_bots/mailbot.py as an example for how a network/bot works
|
||||
- crawl():
|
||||
- mails arrive at an mbox file through exim4
|
||||
- the bot checks whether they are new
|
||||
- the bot generates a report object from the mail and returns it to the backend.py-loop
|
||||
- post():
|
||||
- asks the database for the list of mails which want to receive reports for this city
|
||||
- sends the report.text to those mail addresses
|
||||
|
||||
|
||||
### Frontend
|
||||
|
||||
the architecture of the frontend is loosely oriented off [Model View
|
||||
Controller](https://blog.codinghorror.com/understanding-model-view-controller/).
|
||||
|
||||
user.py (Model)
|
||||
- high-level interface to talk to the database
|
||||
- database calls; almost all values in the database are specific to a city/user
|
||||
- user.py is also a Class for frontend web authentication
|
||||
- user.py keeps the user-id, through which the frontend tracks authentication
|
||||
|
||||
db.py (Model)
|
||||
- DB-Layout; creates the database if it doesn't exist yet.
|
||||
- holds some database calls which are not city-specific.
|
||||
|
||||
frontend.py (Controller): bottle web application
|
||||
- handles POST/GET requests
|
||||
- talks to the database through user.py
|
||||
- everyone can look at the pages, and register
|
||||
- but only authenticated users can login and change settings
|
||||
|
||||
session.py: User Authentication
|
||||
- takes care of session cookies and "403 unauthenticated" error messages
|
||||
|
||||
sendmail.py: helper script to send mails
|
||||
- sends all mails the frontend, backend, and bots need to send
|
||||
|
||||
static/
|
||||
- css, images, javascript for the login form etc.
|
||||
|
||||
template/ (view)
|
||||
- base for the HTML generation, uses the bottle-template-framework
|
||||
- wrapper.tpl is the base template for every other template
|
||||
|
||||
|
||||
### active_bots: how to implement a new network
|
||||
|
||||
If you want to write a new bot, e.g. a Wire-Bot, you have to take these steps:
|
||||
|
||||
- look for a python-library which can talk to Wire
|
||||
- the city/users have to provide authentication details; this needs a form in
|
||||
the settings
|
||||
- depending on the network either a password, a token, or an implementation
|
||||
of the OAuth login flow
|
||||
- the backend needs to crawl messages from the network, & post reports to the
|
||||
network
|
||||
|
||||
Files you need to change:
|
||||
|
||||
1. active_bots/wire.py - crawl & post functions
|
||||
2. settings.tpl - form to authenticate to the network & possible network specific settings.
|
||||
3. frontend.py - routes for the forms you added to settings.tpl
|
||||
4. db.py - database layout, to store the account credentials/tokens, and to save which message you have last seen
|
||||
5. user.py - database calls to get or set values
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ from bot import Bot
|
|||
from config import config
|
||||
from db import db
|
||||
|
||||
logger = logging.getLogger("main")
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Mailbot(Bot):
|
||||
|
@ -19,11 +19,7 @@ class Mailbot(Bot):
|
|||
def crawl(self, user):
|
||||
reports = []
|
||||
# todo: adjust to actual mailbox
|
||||
try:
|
||||
mails = mailbox.mbox("/var/mail/" + config['mail']['mbox_user'])
|
||||
except FileNotFoundError:
|
||||
logger.error("No mbox file found.")
|
||||
return reports
|
||||
mails = mailbox.mbox("/var/mail/" + config['mail']['mbox_user'])
|
||||
for msg in mails:
|
||||
if get_date_from_header(msg['Date']) > user.get_seen_mail():
|
||||
if user.get_city().lower() in msg['To'].lower():
|
||||
|
@ -58,16 +54,30 @@ def make_report(msg, user):
|
|||
date = get_date_from_header(msg['Date'])
|
||||
|
||||
author = msg['From'] # get mail author from email header
|
||||
for part in msg.walk():
|
||||
if part.get_content_type() == 'text/plain':
|
||||
text = part.get_payload()
|
||||
elif part.get_content_type() == 'text/html':
|
||||
text = re.sub(r'<[^>]*>', '', msg.get_payload())
|
||||
try:
|
||||
post = report.Report(author, "mail", text, None, date)
|
||||
except UnboundLocalError:
|
||||
logger.error('No suitable message body')
|
||||
return
|
||||
|
||||
if msg.is_multipart():
|
||||
text = []
|
||||
for part in msg.get_payload():
|
||||
if part.get_content_type() == "text":
|
||||
text.append(part.get_payload())
|
||||
elif part.get_content_type() == "application/pgp-signature":
|
||||
pass # ignore PGP signatures
|
||||
elif part.get_content_type() == "multipart/mixed":
|
||||
for p in part:
|
||||
if isinstance(p, str):
|
||||
text.append(p)
|
||||
elif p.get_content_type() == "text":
|
||||
text.append(part.get_payload())
|
||||
else:
|
||||
logger.error("unknown MIMEtype: " +
|
||||
p.get_content_type())
|
||||
else:
|
||||
logger.error("unknown MIMEtype: " +
|
||||
part.get_content_type())
|
||||
text = '\n'.join(text)
|
||||
else:
|
||||
text = msg.get_payload()
|
||||
post = report.Report(author, "mail", text, None, date)
|
||||
user.save_seen_mail(date)
|
||||
return post
|
||||
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
from bot import Bot
|
||||
import logging
|
||||
import mastodon
|
||||
from mastodon import Mastodon
|
||||
import re
|
||||
from report import Report
|
||||
|
||||
|
||||
logger = logging.getLogger("main")
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class MastodonBot(Bot):
|
||||
|
@ -19,93 +19,42 @@ class MastodonBot(Bot):
|
|||
"""
|
||||
mentions = []
|
||||
try:
|
||||
m = mastodon.Mastodon(*user.get_masto_credentials())
|
||||
m = Mastodon(*user.get_masto_credentials())
|
||||
except TypeError:
|
||||
# No Mastodon Credentials in database.
|
||||
# logger.error("No Mastodon Credentials in database.", exc_info=True)
|
||||
return mentions
|
||||
try:
|
||||
notifications = m.notifications()
|
||||
except mastodon.MastodonNetworkError:
|
||||
logger.error("Mastodon Network Error.")
|
||||
return mentions
|
||||
except mastodon.MastodonAPIError:
|
||||
try:
|
||||
logger.error("Mastodon API Error: " + m.instance()['urls']['streaming_api'] + ", city: " + str(user.uid))
|
||||
except mastodon.MastodonServerError:
|
||||
logger.error("Mastodon Server Error 500, can't get instance.")
|
||||
except mastodon.MastodonVersionError:
|
||||
logger.error("Mastodon Server Error 500, server version too low.")
|
||||
return mentions
|
||||
except mastodon.MastodonInternalServerError:
|
||||
try:
|
||||
logger.error("Mastodon Error: 500. Server: " + m.instance()['urls']['streaming_api'])
|
||||
except mastodon.MastodonServerError:
|
||||
logger.error("Mastodon Server Error 500, can't get instance.")
|
||||
except mastodon.MastodonVersionError:
|
||||
logger.error("Mastodon Server Error 500, server version too low.")
|
||||
return mentions
|
||||
except mastodon.MastodonBadGatewayError:
|
||||
try:
|
||||
logger.error("Mastodon Error: 502. Server: " + m.instance()['urls']['streaming_api'])
|
||||
except mastodon.MastodonServerError:
|
||||
logger.error("Mastodon Server Error 502, can't get instance.")
|
||||
except mastodon.MastodonVersionError:
|
||||
logger.error("Mastodon Server Error 502, server version too low.")
|
||||
return mentions
|
||||
except mastodon.MastodonServiceUnavailableError:
|
||||
try:
|
||||
logger.error("Mastodon Error: 503. Server: " + m.instance()['urls']['streaming_api'])
|
||||
except mastodon.MastodonServerError:
|
||||
logger.error("Mastodon Server Error 503, can't get instance.")
|
||||
except mastodon.MastodonVersionError:
|
||||
logger.error("Mastodon Server Error 503, server version too low.")
|
||||
return mentions
|
||||
except mastodon.MastodonGatewayTimeoutError:
|
||||
try:
|
||||
logger.error("Mastodon Error: 504. Server: " + m.instance()['urls']['streaming_api'])
|
||||
except mastodon.MastodonServerError:
|
||||
logger.error("Mastodon Server Error 504, can't get instance.")
|
||||
except mastodon.MastodonVersionError:
|
||||
logger.error("Mastodon Server Error 504, server version too low.")
|
||||
return mentions
|
||||
except mastodon.MastodonServerError:
|
||||
try:
|
||||
logger.error("Unknown Mastodon Server Error. Server: " + m.instance()['urls']['streaming_api'], exc_info=True)
|
||||
except mastodon.MastodonServerError:
|
||||
logger.error("Unknown Mastodon Server Error.", exc_info=True)
|
||||
except mastodon.MastodonVersionError:
|
||||
logger.error("Unknown Mastodon Server Error.", exc_info=True)
|
||||
except Exception:
|
||||
logger.error("Unknown Mastodon API Error.", exc_info=True)
|
||||
return mentions
|
||||
for status in notifications:
|
||||
try:
|
||||
if (status['type'] == 'mention' and
|
||||
if (status['type'] == 'mention' and
|
||||
not user.toot_is_seen(status['status']['uri'])):
|
||||
# save state
|
||||
user.toot_witness(status['status']['uri'])
|
||||
# add mention to mentions
|
||||
text = re.sub(r'<[^>]*>', '', status['status']['content'])
|
||||
text = re.sub(
|
||||
"(?<=^|(?<=[^a-zA-Z0-9-_.]))@([A-Za-z]+[A-Za-z0-9-_]+)",
|
||||
"", text)
|
||||
if status['status']['visibility'] == 'public':
|
||||
mentions.append(Report(status['account']['acct'],
|
||||
self,
|
||||
text,
|
||||
status['status']['id'],
|
||||
status['status']['created_at']))
|
||||
else:
|
||||
mentions.append(Report(status['account']['acct'],
|
||||
'mastodonPrivate',
|
||||
text,
|
||||
status['status']['id'],
|
||||
status['status']['created_at']))
|
||||
except TypeError:
|
||||
pass
|
||||
# save state
|
||||
user.toot_witness(status['status']['uri'])
|
||||
# add mention to mentions
|
||||
text = re.sub(r'<[^>]*>', '', status['status']['content'])
|
||||
text = re.sub(
|
||||
"(?<=^|(?<=[^a-zA-Z0-9-_.]))@([A-Za-z]+[A-Za-z0-9-_]+)",
|
||||
"", text)
|
||||
if status['status']['visibility'] == 'public':
|
||||
mentions.append(Report(status['account']['acct'],
|
||||
self,
|
||||
text,
|
||||
status['status']['id'],
|
||||
status['status']['created_at']))
|
||||
else:
|
||||
mentions.append(Report(status['account']['acct'],
|
||||
'mastodonPrivate',
|
||||
text,
|
||||
status['status']['id'],
|
||||
status['status']['created_at']))
|
||||
return mentions
|
||||
|
||||
def post(self, user, report):
|
||||
try:
|
||||
m = mastodon.Mastodon(*user.get_masto_credentials())
|
||||
m = Mastodon(*user.get_masto_credentials())
|
||||
except TypeError:
|
||||
return # no mastodon account for this user.
|
||||
if report.source == self:
|
||||
|
|
|
@ -3,7 +3,8 @@ import logging
|
|||
from report import Report
|
||||
from twx.botapi import TelegramBot as Telegram
|
||||
|
||||
logger = logging.getLogger("main")
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TelegramBot(Bot):
|
||||
|
@ -12,45 +13,20 @@ class TelegramBot(Bot):
|
|||
seen_tg = user.get_seen_tg()
|
||||
try:
|
||||
updates = tb.get_updates(offset=seen_tg + 1,
|
||||
allowed_updates="message",
|
||||
timeout=5).wait()
|
||||
allowed_updates="message").wait()
|
||||
except TypeError:
|
||||
updates = tb.get_updates(timeout=5).wait()
|
||||
updates = tb.get_updates().wait()
|
||||
reports = []
|
||||
if updates == None:
|
||||
return reports
|
||||
for update in updates:
|
||||
# return when telegram returns an error code
|
||||
if update in [303, 404, 420, 500, 502]:
|
||||
if update in [303, 404, 420, 500]:
|
||||
return reports
|
||||
# log unusual telegram error messages
|
||||
if isinstance(update, int):
|
||||
try:
|
||||
logger.error("City " + str(user.uid) +
|
||||
": Unknown Telegram error code: " +
|
||||
str(update) + " - " + str(updates[1]))
|
||||
except TypeError:
|
||||
logger.error("Unknown Telegram error code: " + str(update))
|
||||
elif isinstance(update, int):
|
||||
logger.error("Unknown Telegram error code: " + str(update))
|
||||
return reports
|
||||
# save the last message, so it doesn't get crawled again
|
||||
user.save_seen_tg(update.update_id)
|
||||
# skip if message is None
|
||||
if update.message is None:
|
||||
continue
|
||||
# complain if message is a photo
|
||||
if update.message.photo is not None:
|
||||
tb.send_message(
|
||||
update.message.sender.id,
|
||||
"Sending Photos is not supported for privacy reasons. Can "
|
||||
"you describe it as text instead?")
|
||||
continue
|
||||
# complain if message is a media file
|
||||
if update.message.text is None:
|
||||
tb.send_message(
|
||||
update.message.sender.id,
|
||||
"We only support text reporting for privacy reasons. Can "
|
||||
"you describe it as text instead?")
|
||||
continue
|
||||
if update.message.text.lower() == "/start":
|
||||
user.add_telegram_subscribers(update.message.sender.id)
|
||||
tb.send_message(
|
||||
|
@ -66,24 +42,19 @@ class TelegramBot(Bot):
|
|||
elif update.message.text.lower() == "/help":
|
||||
tb.send_message(
|
||||
update.message.sender.id,
|
||||
"Send reports here to share them with other users. "
|
||||
"Use /start and /stop to get reports or not.")
|
||||
"Send reports here to share them with other users. Use /start and /stop to get reports or not.")
|
||||
# TODO: /help message should be set in frontend
|
||||
else:
|
||||
# set report.author to "" to avoid mailbot crash
|
||||
sender_name = update.message.sender.username
|
||||
if sender_name is None:
|
||||
sender_name = ""
|
||||
|
||||
reports.append(Report(sender_name, self, update.message.text,
|
||||
None, update.message.date))
|
||||
reports.append(Report(update.message.sender.username, self,
|
||||
update.message.text, None,
|
||||
update.message.date))
|
||||
return reports
|
||||
|
||||
def post(self, user, report):
|
||||
tb = Telegram(user.get_telegram_credentials())
|
||||
text = report.text
|
||||
if len(text) > 4096:
|
||||
text = text[:4096 - 2] + " \N{Horizontal ellipsis}"
|
||||
text = text[:4096 - 4] + u' ...'
|
||||
try:
|
||||
for subscriber_id in user.get_telegram_subscribers():
|
||||
tb.send_message(subscriber_id, text).wait()
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import logging
|
||||
import tweepy
|
||||
import re
|
||||
import requests
|
||||
import report
|
||||
from time import time
|
||||
from bot import Bot
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TwitterDMListener(Bot):
|
||||
|
||||
def get_api(self, user):
|
||||
keys = user.get_twitter_credentials()
|
||||
auth = tweepy.OAuthHandler(consumer_key=keys[0],
|
||||
consumer_secret=keys[1])
|
||||
auth.set_access_token(keys[2], # access_token_key
|
||||
keys[3]) # access_token_secret
|
||||
return tweepy.API(auth, wait_on_rate_limit=True)
|
||||
|
||||
def crawl(self, user):
|
||||
"""
|
||||
crawls all Tweets which mention the bot from the twitter rest API.
|
||||
|
||||
:return: reports: (list of report.Report objects)
|
||||
"""
|
||||
reports = []
|
||||
try:
|
||||
if user.get_last_twitter_request() + 60 > time():
|
||||
return reports
|
||||
except TypeError:
|
||||
user.set_last_twitter_request(time())
|
||||
try:
|
||||
api = self.get_api(user)
|
||||
except TypeError:
|
||||
return reports # no twitter account for this user.
|
||||
last_dm = user.get_seen_dm()
|
||||
try:
|
||||
if last_dm is None:
|
||||
mentions = api.direct_messages()
|
||||
else:
|
||||
mentions = api.direct_messages(since_id=last_dm[0])
|
||||
user.set_last_twitter_request(time())
|
||||
for status in mentions:
|
||||
text = re.sub(
|
||||
"(?<=^|(?<=[^a-zA-Z0-9-_\.]))@([A-Za-z]+[A-Za-z0-9-_]+)",
|
||||
"", status.text)
|
||||
reports.append(report.Report(status.author.screen_name,
|
||||
"twitterDM",
|
||||
text,
|
||||
status.id,
|
||||
status.created_at))
|
||||
user.save_seen_dm(last_dm)
|
||||
return reports
|
||||
except tweepy.RateLimitError:
|
||||
logger.error("Twitter API Error: Rate Limit Exceeded",
|
||||
exc_info=True)
|
||||
# :todo implement rate limiting
|
||||
except requests.exceptions.ConnectionError:
|
||||
logger.error("Twitter API Error: Bad Connection", exc_info=True)
|
||||
except tweepy.TweepError as terror:
|
||||
# Waiting for https://github.com/tweepy/tweepy/pull/1109 to get
|
||||
# merged, so direct messages work again
|
||||
if terror.api_code == 34:
|
||||
return reports
|
||||
logger.error("Twitter API Error: General Error", exc_info=True)
|
||||
return reports
|
||||
|
||||
def post(self, user, report):
|
||||
pass
|
|
@ -9,7 +9,7 @@ import report
|
|||
from bot import Bot
|
||||
|
||||
|
||||
logger = logging.getLogger("main")
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TwitterBot(Bot):
|
||||
|
@ -67,13 +67,13 @@ class TwitterBot(Bot):
|
|||
except requests.exceptions.ConnectionError:
|
||||
logger.error("Twitter API Error: Bad Connection", exc_info=True)
|
||||
except tweepy.TweepError:
|
||||
logger.error("Twitter API Error: General Error. User: " + str(user.uid), exc_info=True)
|
||||
logger.error("Twitter API Error: General Error", exc_info=True)
|
||||
return []
|
||||
|
||||
def post(self, user, report):
|
||||
try:
|
||||
api = self.get_api(user)
|
||||
except TypeError:
|
||||
except IndexError:
|
||||
return # no twitter account for this user.
|
||||
try:
|
||||
if report.source == self:
|
||||
|
|
11
backend.py
11
backend.py
|
@ -5,7 +5,7 @@ from config import config
|
|||
from db import db
|
||||
import logging
|
||||
from sendmail import sendmail
|
||||
from time import sleep
|
||||
|
||||
|
||||
def shutdown():
|
||||
try:
|
||||
|
@ -16,14 +16,11 @@ def shutdown():
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logger = logging.getLogger("main")
|
||||
logger.setLevel(logging.DEBUG)
|
||||
logger = logging.getLogger()
|
||||
fh = logging.FileHandler('/var/log/ticketfrei/backend.log')
|
||||
formatter = logging.Formatter('%(asctime)s %(levelname)8s: %(message)s')
|
||||
fh.setFormatter(formatter)
|
||||
fh.setLevel(logging.DEBUG)
|
||||
logger.addHandler(fh)
|
||||
|
||||
logger.info("Backend Daemon was started...")
|
||||
|
||||
bots = []
|
||||
for ActiveBot in active_bots.__dict__.values():
|
||||
|
@ -34,14 +31,12 @@ if __name__ == '__main__':
|
|||
while True:
|
||||
for user in db.active_users:
|
||||
for bot in bots:
|
||||
sleep(1)
|
||||
reports = bot.crawl(user)
|
||||
for status in reports:
|
||||
if not user.is_appropriate(status):
|
||||
logger.info("Inaproppriate message: %d %s %s" % (user.uid, status.author, status.text))
|
||||
continue
|
||||
for bot2 in bots:
|
||||
sleep(1)
|
||||
bot2.post(user, status)
|
||||
logger.info("Resent: %d %s %s" % (user.uid, status.author, status.text))
|
||||
except Exception:
|
||||
|
|
69
config.py
69
config.py
|
@ -1,70 +1,5 @@
|
|||
import pytoml as toml
|
||||
import os
|
||||
|
||||
|
||||
def load_env():
|
||||
"""
|
||||
load environment variables from the environment. If empty, use default
|
||||
values from config.toml.example.
|
||||
|
||||
:return: config dictionary of dictionaries.
|
||||
"""
|
||||
with open('config.toml.example') as defaultconf:
|
||||
configdict = toml.load(defaultconf)
|
||||
|
||||
try:
|
||||
if os.environ['CONSUMER_KEY'] != "":
|
||||
configdict['twitter']['consumer_key'] = os.environ['CONSUMER_KEY']
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
try:
|
||||
if os.environ['CONSUMER_SECRET'] != "":
|
||||
configdict['twitter']['consumer_secret'] = os.environ['CONSUMER_SECRET']
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
try:
|
||||
if os.environ['HOST'] != "":
|
||||
configdict['web']['host'] = os.environ['HOST']
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
try:
|
||||
if os.environ['PORT'] != "":
|
||||
configdict['web']['port'] = os.environ['PORT']
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
try:
|
||||
if os.environ['CONTACT'] != "":
|
||||
configdict['web']['contact'] = os.environ['CONTACT']
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
try:
|
||||
if os.environ['MBOX_USER'] != "":
|
||||
configdict['mail']['mbox_user'] = os.environ['MBOX_USER']
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
try:
|
||||
if os.environ['DB_PATH'] != "":
|
||||
configdict['database']['db_path'] = os.environ['DB_PATH']
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
return configdict
|
||||
|
||||
|
||||
# read config in TOML format (https://github.com/toml-lang/toml#toml)
|
||||
try:
|
||||
with open('config.toml') as configfile:
|
||||
config = toml.load(configfile)
|
||||
except FileNotFoundError:
|
||||
config = load_env()
|
||||
|
||||
if __name__ == "__main__":
|
||||
for category in config:
|
||||
for key in config[category]:
|
||||
print(key + "=" + str(config[category][key]))
|
||||
with open('config.toml') as configfile:
|
||||
config = toml.load(configfile)
|
||||
|
|
|
@ -10,7 +10,10 @@ port = 80
|
|||
contact = "b3yond@riseup.net"
|
||||
|
||||
[mail]
|
||||
mbox_user = "root"
|
||||
mailserver = "smtp.riseup.net"
|
||||
user = "user"
|
||||
passphrase = "sup3rs3cur3"
|
||||
mbox = "root"
|
||||
|
||||
[database]
|
||||
db_path = "/var/ticketfrei/db.sqlite"
|
||||
|
|
40
db.py
40
db.py
|
@ -1,13 +1,12 @@
|
|||
from config import config
|
||||
import jwt
|
||||
import logging
|
||||
from os import urandom, system
|
||||
from os import urandom
|
||||
from pylibscrypt import scrypt_mcf
|
||||
import sqlite3
|
||||
from time import sleep, time
|
||||
|
||||
|
||||
logger = logging.getLogger("main")
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class DB(object):
|
||||
|
@ -15,25 +14,13 @@ class DB(object):
|
|||
self.conn = sqlite3.connect(dbfile)
|
||||
self.cur = self.conn.cursor()
|
||||
self.create()
|
||||
self.secret = self.get_secret()
|
||||
|
||||
def execute(self, *args, **kwargs):
|
||||
return self.cur.execute(*args, **kwargs)
|
||||
|
||||
def commit(self):
|
||||
start_time = time()
|
||||
while 1:
|
||||
try:
|
||||
self.conn.commit()
|
||||
break
|
||||
except sqlite3.OperationalError as error:
|
||||
# another thread may be writing, give it a chance to finish
|
||||
sleep(0.5)
|
||||
logger.exception()
|
||||
if time() - start_time > 5:
|
||||
# if it takes this long, something is wrong
|
||||
system("rcctl restart frontend_daemon")
|
||||
logger.warning("frontend_daemon is getting restarted")
|
||||
self.conn.commit()
|
||||
self.conn.commit()
|
||||
|
||||
def close(self):
|
||||
self.conn.close()
|
||||
|
@ -128,6 +115,13 @@ class DB(object):
|
|||
FOREIGN KEY(twitter_accounts_id)
|
||||
REFERENCES twitter_accounts(id)
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS telegram_accounts (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
|
||||
user_id INTEGER,
|
||||
api_token TEXT,
|
||||
active INTEGER,
|
||||
FOREIGN KEY(user_id) REFERENCES user(id)
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS telegram_subscribers (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
|
||||
user_id INTEGER,
|
||||
|
@ -202,7 +196,7 @@ class DB(object):
|
|||
'passhash': scrypt_mcf(
|
||||
password.encode('utf-8')
|
||||
).decode('ascii')
|
||||
}, self.get_secret()).decode('ascii')
|
||||
}, self.secret).decode('ascii')
|
||||
|
||||
def mail_subscription_token(self, email, city):
|
||||
"""
|
||||
|
@ -216,17 +210,17 @@ class DB(object):
|
|||
token = jwt.encode({
|
||||
'email': email,
|
||||
'city': city
|
||||
}, self.get_secret()).decode('ascii')
|
||||
}, self.secret).decode('ascii')
|
||||
return token
|
||||
|
||||
def confirm_subscription(self, token):
|
||||
json = jwt.decode(token, self.get_secret())
|
||||
json = jwt.decode(token, self.secret)
|
||||
return json['email'], json['city']
|
||||
|
||||
def confirm(self, token, city):
|
||||
from user import User
|
||||
try:
|
||||
json = jwt.decode(token, self.get_secret())
|
||||
json = jwt.decode(token, self.secret)
|
||||
except jwt.DecodeError:
|
||||
return None # invalid token
|
||||
if 'passhash' in json.keys():
|
||||
|
@ -259,10 +253,6 @@ u\d\d?"""
|
|||
uid = json['uid']
|
||||
with open("/etc/aliases", "a+") as f:
|
||||
f.write(city + ": " + config["mail"]["mbox_user"] + "\n")
|
||||
try:
|
||||
os.system("newaliases")
|
||||
except:
|
||||
logger.exception()
|
||||
self.execute("INSERT INTO email (user_id, email) VALUES(?, ?);",
|
||||
(uid, json['email']))
|
||||
self.execute("""INSERT INTO telegram_accounts (user_id, apikey,
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
#!/bin/ksh
|
||||
|
||||
daemon="/usr/local/bin/python3 /srv/ticketfrei/backend.py"
|
||||
daemon_user="root"
|
||||
|
||||
. /etc/rc.d/rc.subr
|
||||
|
||||
rc_bg=YES
|
||||
rc_reload=NO
|
||||
|
||||
rc_start() {
|
||||
rc_exec "cd /srv/ticketfrei; /usr/bin/nice -n15 ${daemon} ${daemon_flags}"
|
||||
}
|
||||
|
||||
rc_cmd $1
|
|
@ -1,15 +0,0 @@
|
|||
#!/bin/ksh
|
||||
. /etc/borg-env
|
||||
export BORG_REPO=nathan@nephilim:repositories-borg/ticketfrei
|
||||
export BORG_RSH="ssh \
|
||||
-o TCPKeepAlive=no \
|
||||
-o ServerAliveInterval=15 \
|
||||
-o ServerAliveCountMax=10 \
|
||||
-o Compression=no"
|
||||
|
||||
rcctl stop backend_daemon
|
||||
rcctl stop frontend_daemon
|
||||
/usr/local/bin/borg create --stats ::'backup{now:%Y%m%d-%H%M}' /srv/ticketfrei /var/ticketfrei /etc
|
||||
rcctl start backend_daemon
|
||||
rcctl start frontend_daemon
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
server {
|
||||
|
||||
listen 443 ssl;
|
||||
server_name example.org;
|
||||
ssl_certificate /etc/letsencrypt/live/example.org/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/example.org/privkey.pem;
|
||||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
|
||||
ssl_ciphers HIGH:!aNULL:!MD5;
|
||||
|
||||
access_log /var/log/nginx/example.org_access.log;
|
||||
error_log /var/log/nginx/example.org_error.log;
|
||||
|
||||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||||
|
||||
location / {
|
||||
include uwsgi_params;
|
||||
|
||||
uwsgi_pass unix:///var/run/ticketfrei/ticketfrei.sock;
|
||||
}
|
||||
|
||||
location /.well-known/acme-challenge {
|
||||
root /var/www/acme;
|
||||
}
|
||||
}
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name example.org;
|
||||
return 301 https://$server_name$request_uri;
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
#!/bin/ksh
|
||||
|
||||
daemon="/usr/local/bin/python3 /srv/ticketfrei/frontend.py"
|
||||
daemon_user="frontend"
|
||||
|
||||
. /etc/rc.d/rc.subr
|
||||
|
||||
rc_bg=YES
|
||||
rc_reload=NO
|
||||
|
||||
rc_start() {
|
||||
rc_exec "env > /tmp/envars; cd /srv/ticketfrei; ${daemon} ${daemon_flags}"
|
||||
}
|
||||
|
||||
rc_cmd $1
|
|
@ -0,0 +1,17 @@
|
|||
[Unit]
|
||||
Description=Ticketfrei Backend
|
||||
After=syslog.target network.target
|
||||
|
||||
[Service]
|
||||
WorkingDirectory=/srv/ticketfrei
|
||||
ExecStart=/srv/ticketfrei/bin/python3 backend.py
|
||||
# Requires systemd version 211 or newer
|
||||
#RuntimeDirectory=uwsgi
|
||||
Restart=always
|
||||
KillSignal=SIGQUIT
|
||||
Type=simple
|
||||
StandardError=syslog
|
||||
NotifyAccess=all
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -0,0 +1,17 @@
|
|||
[Unit]
|
||||
Description=Ticketfrei Web Application
|
||||
After=syslog.target network.target
|
||||
|
||||
[Service]
|
||||
WorkingDirectory=/srv/ticketfrei
|
||||
ExecStart=/usr/bin/uwsgi --ini /srv/ticketfrei/deployment/uwsgi.ini
|
||||
# Requires systemd version 211 or newer
|
||||
RuntimeDirectory=uwsgi
|
||||
Restart=always
|
||||
KillSignal=SIGQUIT
|
||||
Type=notify
|
||||
StandardError=syslog
|
||||
NotifyAccess=all
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
24
frontend.py
24
frontend.py
|
@ -56,22 +56,11 @@ def register_post():
|
|||
@get('/confirm/<city>/<token>')
|
||||
@view('template/propaganda.tpl')
|
||||
def confirm(city, token):
|
||||
# check whether city already exists
|
||||
if db.by_city(city):
|
||||
return dict(error='This Account was already confirmed, please try '
|
||||
'signing in.')
|
||||
# create db-entry
|
||||
if db.confirm(token, city):
|
||||
# :todo show info "Account creation successful."
|
||||
redirect('/settings')
|
||||
return dict(error='Account creation failed. Please try to register again.')
|
||||
|
||||
|
||||
@get('/version')
|
||||
def version():
|
||||
import git
|
||||
repo = git.Repo(search_parent_directories=True)
|
||||
return repo.head.object.hexsha
|
||||
return dict(error='Email confirmation failed.')
|
||||
|
||||
|
||||
@post('/login')
|
||||
|
@ -178,10 +167,9 @@ def register_telegram(user):
|
|||
return city_page(user.get_city(), info="Thanks for registering Telegram!")
|
||||
|
||||
|
||||
# unused afaik
|
||||
#@get('/api/state')
|
||||
#def api_enable(user):
|
||||
# return user.state()
|
||||
@get('/api/state')
|
||||
def api_enable(user):
|
||||
return user.state()
|
||||
|
||||
|
||||
@get('/static/<filename:path>')
|
||||
|
@ -198,7 +186,6 @@ def guides(filename):
|
|||
def logout():
|
||||
# clear auth cookie
|
||||
response.set_cookie('uid', '', expires=0, path="/")
|
||||
response.set_cookie('csrf', '', expires=0, path="/")
|
||||
# :todo show info "Logout successful."
|
||||
redirect('/')
|
||||
|
||||
|
@ -272,6 +259,7 @@ application = bottle.default_app()
|
|||
bottle.install(SessionPlugin('/'))
|
||||
|
||||
if __name__ == '__main__':
|
||||
bottle.run(host="0.0.0.0", port=config["web"]["port"])
|
||||
# testing only
|
||||
bottle.run(host=config["web"]["host"], port=config["web"]["port"])
|
||||
else:
|
||||
application.catchall = False
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
tweepy
|
||||
pytoml
|
||||
Mastodon.py
|
||||
bottle
|
||||
pyjwt
|
||||
pylibscrypt
|
||||
Markdown
|
||||
twx
|
||||
gitpython
|
|
@ -8,7 +8,7 @@ import smtplib
|
|||
from socket import getfqdn
|
||||
|
||||
|
||||
logger = logging.getLogger("main")
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def sendmail(to, subject, city=None, body=''):
|
||||
|
@ -27,5 +27,5 @@ def sendmail(to, subject, city=None, body=''):
|
|||
|
||||
# For testing:
|
||||
if __name__ == '__main__':
|
||||
sendmail(config['web']['contact'], "Test Mail",
|
||||
sendmail(config['mail']['contact'], "Test Mail",
|
||||
body="This is a test mail.")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from bottle import redirect, request, abort, response
|
||||
from bottle import redirect, request
|
||||
from db import db
|
||||
from functools import wraps
|
||||
from inspect import Signature
|
||||
|
@ -17,14 +17,10 @@ class SessionPlugin(object):
|
|||
if self.keyword in Signature.from_callable(route.callback).parameters:
|
||||
@wraps(callback)
|
||||
def wrapper(*args, **kwargs):
|
||||
uid = request.get_cookie('uid', secret=db.get_secret())
|
||||
uid = request.get_cookie('uid', secret=db.secret)
|
||||
if uid is None:
|
||||
return redirect(self.loginpage)
|
||||
kwargs[self.keyword] = User(uid)
|
||||
if request.method == 'POST':
|
||||
if request.forms['csrf'] != request.get_cookie('csrf',
|
||||
secret=db.get_secret()):
|
||||
abort(400)
|
||||
return callback(*args, **kwargs)
|
||||
|
||||
return wrapper
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
body {
|
||||
background-image: url(/static/img/ticketfrei-og-image.jpg);
|
||||
background-height: 100%;
|
||||
background-size: 50%;
|
||||
font-family: Verdana, Arial, Helvetica, sans-serif;
|
||||
font-size: 12pt;
|
||||
line-height: 1.5em;
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 628 KiB After Width: | Height: | Size: 570 KiB |
|
@ -61,7 +61,6 @@
|
|||
<option value='octodon.social'>
|
||||
<option value='soc.ialis.me'>
|
||||
</datalist>
|
||||
<input name='csrf' value='{{csrf}}' type='hidden' />
|
||||
<input name='confirm' value='Log in' type='submit'/>
|
||||
</form>
|
||||
</section>
|
||||
|
@ -83,7 +82,6 @@
|
|||
</p>
|
||||
<form action="/settings/telegram" method="post">
|
||||
<input type="text" name="apikey" placeholder="Telegram bot API key" id="apikey">
|
||||
<input name='csrf' value='{{csrf}}' type='hidden' />
|
||||
<input name='confirm' value='Login with Telegram' type='submit'/>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -108,7 +106,6 @@
|
|||
</p>
|
||||
<form action="/settings/markdown" method="post">
|
||||
<textarea id="markdown" rows="20" cols="70" name="markdown" wrap="physical">{{markdown}}</textarea>
|
||||
<input name='csrf' value='{{csrf}}' type='hidden' />
|
||||
<input name='confirm' value='Save' type='submit'/>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -126,7 +123,6 @@
|
|||
</p>
|
||||
<form action="/settings/mail_md" method="post">
|
||||
<textarea id="mail_md" rows="20" cols="70" name="mail_md" wrap="physical">{{mail_md}}</textarea>
|
||||
<input name='csrf' value='{{csrf}}' type='hidden' />
|
||||
<input name='confirm' value='Save' type='submit'/>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -141,7 +137,6 @@
|
|||
</p>
|
||||
<form action="/settings/goodlist" method="post">
|
||||
<textarea id="goodlist" rows="8" cols="70" name="goodlist" wrap="physical">{{triggerwords}}</textarea>
|
||||
<input name='csrf' value='{{csrf}}' type='hidden' />
|
||||
<input name='confirm' value='Submit' type='submit'/>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -156,7 +151,6 @@
|
|||
</p>
|
||||
<form action="/settings/blocklist" method="post">
|
||||
<textarea id="blocklist" rows="8" cols="70" name="blocklist" wrap="physical">{{badwords}}</textarea>
|
||||
<input name='csrf' value='{{csrf}}' type='hidden' />
|
||||
<input name='confirm' value='Submit' type='submit'/>
|
||||
</form>
|
||||
</div>
|
||||
|
|
127
user.py
127
user.py
|
@ -1,26 +1,16 @@
|
|||
from config import config
|
||||
from bottle import response, request
|
||||
from bottle import response
|
||||
from db import db
|
||||
import jwt
|
||||
from mastodon import Mastodon
|
||||
from pylibscrypt import scrypt_mcf, scrypt_mcf_check
|
||||
from os import urandom
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger("main")
|
||||
|
||||
class User(object):
|
||||
def __init__(self, uid):
|
||||
# set cookie
|
||||
response.set_cookie('uid', uid, secret=db.get_secret(), path='/')
|
||||
response.set_cookie('uid', uid, secret=db.secret, path='/')
|
||||
self.uid = uid
|
||||
response.set_cookie('csrf', self.get_csrf(), db.get_secret(), path='/')
|
||||
|
||||
def get_csrf(self):
|
||||
csrf_token = request.get_cookie('csrf', secret=db.get_secret())
|
||||
if not csrf_token:
|
||||
csrf_token = str(urandom(32))
|
||||
return csrf_token
|
||||
|
||||
def check_password(self, password):
|
||||
db.execute("SELECT passhash FROM user WHERE id=?;", (self.uid,))
|
||||
|
@ -65,7 +55,7 @@ class User(object):
|
|||
return jwt.encode({
|
||||
'email': email,
|
||||
'uid': self.uid
|
||||
}, db.get_secret()).decode('ascii')
|
||||
}, db.secret).decode('ascii')
|
||||
|
||||
def is_appropriate(self, report):
|
||||
db.execute("SELECT patterns FROM triggerpatterns WHERE user_id=?;",
|
||||
|
@ -76,7 +66,6 @@ class User(object):
|
|||
break
|
||||
else:
|
||||
# no pattern matched
|
||||
logger.error("Message didn't trigger goodlist: " + report.text)
|
||||
return False
|
||||
default_badwords = """
|
||||
bitch
|
||||
|
@ -96,15 +85,12 @@ schlitz
|
|||
db.execute("SELECT words FROM badwords WHERE user_id=?;",
|
||||
(self.uid, ))
|
||||
badwords = db.cur.fetchone()
|
||||
for word in report.text.lower().split():
|
||||
if word in badwords[0].splitlines():
|
||||
logger.error("Word " + word + " triggered the spam filter on message: " + report.text)
|
||||
for word in report.text.lower().splitlines():
|
||||
if word in badwords:
|
||||
return False
|
||||
for word in report.text.lower().split():
|
||||
if word in default_badwords.splitlines():
|
||||
logger.error("Word " + word + " triggered the spam filter on message: " + report.text)
|
||||
for word in default_badwords.splitlines():
|
||||
if word in badwords:
|
||||
return False
|
||||
logger.info("Valid report: " + report.text + " | username: " + report.author)
|
||||
return True
|
||||
|
||||
def get_last_twitter_request(self):
|
||||
|
@ -118,16 +104,16 @@ schlitz
|
|||
db.commit()
|
||||
|
||||
def get_telegram_credentials(self):
|
||||
db.execute("""SELECT apikey
|
||||
FROM telegram_accounts
|
||||
db.execute("""SELECT apikey
|
||||
FROM telegram_accounts
|
||||
WHERE user_id = ? AND active = 1;""",
|
||||
(self.uid,))
|
||||
row = db.cur.fetchone()
|
||||
return row[0]
|
||||
|
||||
def get_telegram_subscribers(self):
|
||||
db.execute("""SELECT subscriber_id
|
||||
FROM telegram_subscribers
|
||||
db.execute("""SELECT subscriber_id
|
||||
FROM telegram_subscribers
|
||||
WHERE user_id = ?;""",
|
||||
(self.uid,))
|
||||
rows = db.cur.fetchall()
|
||||
|
@ -140,21 +126,21 @@ schlitz
|
|||
db.commit()
|
||||
|
||||
def remove_telegram_subscribers(self, subscriber_id):
|
||||
db.execute("""DELETE
|
||||
FROM telegram_subscribers
|
||||
db.execute("""DELETE
|
||||
FROM telegram_subscribers
|
||||
WHERE user_id = ?
|
||||
AND subscriber_id = ?;""",
|
||||
(self.uid, subscriber_id))
|
||||
db.commit()
|
||||
|
||||
def get_masto_credentials(self):
|
||||
db.execute("""SELECT access_token, instance_id
|
||||
FROM mastodon_accounts
|
||||
db.execute("""SELECT access_token, instance_id
|
||||
FROM mastodon_accounts
|
||||
WHERE user_id = ? AND active = 1;""",
|
||||
(self.uid,))
|
||||
row = db.cur.fetchone()
|
||||
db.execute("""SELECT instance, client_id, client_secret
|
||||
FROM mastodon_instances
|
||||
db.execute("""SELECT instance, client_id, client_secret
|
||||
FROM mastodon_instances
|
||||
WHERE id = ?;""",
|
||||
(row[1],))
|
||||
instance = db.cur.fetchone()
|
||||
|
@ -249,7 +235,6 @@ schlitz
|
|||
# - mail_md
|
||||
# - goodlist
|
||||
# - blocklist
|
||||
# - csrf
|
||||
# - logged in with twitter?
|
||||
# - logged in with mastodon?
|
||||
# - enabled?
|
||||
|
@ -259,8 +244,7 @@ schlitz
|
|||
mail_md=citydict['mail_md'],
|
||||
triggerwords=self.get_trigger_words(),
|
||||
badwords=self.get_badwords(),
|
||||
enabled=self.enabled,
|
||||
csrf=self.get_csrf())
|
||||
enabled=self.enabled)
|
||||
|
||||
def save_request_token(self, token):
|
||||
db.execute("""INSERT INTO
|
||||
|
@ -272,11 +256,11 @@ schlitz
|
|||
db.commit()
|
||||
|
||||
def get_request_token(self):
|
||||
db.execute("""SELECT request_token, request_token_secret
|
||||
FROM twitter_request_tokens
|
||||
db.execute("""SELECT request_token, request_token_secret
|
||||
FROM twitter_request_tokens
|
||||
WHERE user_id = ?;""", (self.uid,))
|
||||
request_token = db.cur.fetchone()
|
||||
db.execute("""DELETE FROM twitter_request_tokens
|
||||
db.execute("""DELETE FROM twitter_request_tokens
|
||||
WHERE user_id = ?;""", (self.uid,))
|
||||
db.commit()
|
||||
return {"oauth_token": request_token[0],
|
||||
|
@ -287,8 +271,6 @@ schlitz
|
|||
user_id, client_id, client_secret
|
||||
) VALUES(?, ?, ?);""",
|
||||
(self.uid, access_token, access_token_secret))
|
||||
db.execute("""INSERT INTO seen_tweets(user_id, tweet_id) VALUES (?, ?);""",
|
||||
(self.uid, 0))
|
||||
db.commit()
|
||||
|
||||
def get_twitter_token(self):
|
||||
|
@ -309,8 +291,8 @@ schlitz
|
|||
db.commit()
|
||||
|
||||
def get_mastodon_app_keys(self, instance):
|
||||
db.execute("""SELECT client_id, client_secret
|
||||
FROM mastodon_instances
|
||||
db.execute("""SELECT client_id, client_secret
|
||||
FROM mastodon_instances
|
||||
WHERE instance = ?;""", (instance,))
|
||||
try:
|
||||
row = db.cur.fetchone()
|
||||
|
@ -318,7 +300,7 @@ schlitz
|
|||
client_secret = row[1]
|
||||
return client_id, client_secret
|
||||
except TypeError:
|
||||
app_name = "ticketfrei" + str(db.get_secret())[0:4]
|
||||
app_name = "ticketfrei" + str(db.secret)[0:4]
|
||||
client_id, client_secret \
|
||||
= Mastodon.create_app(app_name, api_base_url=instance)
|
||||
db.execute("""INSERT INTO mastodon_instances(
|
||||
|
@ -329,8 +311,8 @@ schlitz
|
|||
return client_id, client_secret
|
||||
|
||||
def save_masto_token(self, access_token, instance):
|
||||
db.execute("""SELECT id
|
||||
FROM mastodon_instances
|
||||
db.execute("""SELECT id
|
||||
FROM mastodon_instances
|
||||
WHERE instance = ?;""", (instance,))
|
||||
instance_id = db.cur.fetchone()[0]
|
||||
db.execute("INSERT INTO mastodon_accounts(user_id, access_token, instance_id, active) "
|
||||
|
@ -366,28 +348,25 @@ Schau einfach auf das Profil unseres Bots: """ + twit_link + """
|
|||
|
||||
Hat jemand vor kurzem etwas über Kontrolleur\*innen gepostet?
|
||||
|
||||
* Wenn ja, dann kauf dir vllt lieber ein Ticket. In Nürnberg
|
||||
* Wenn ja, dann kauf dir vllt lieber ein Ticket. In Nürnberg
|
||||
haben wir die Erfahrung gemacht, dass Kontis normalerweile
|
||||
ungefähr ne Woche aktiv sind, ein paar Stunden am Tag. Wenn es
|
||||
also in den letzten Stunden einen Bericht gab, pass lieber
|
||||
ungefähr ne Woche aktiv sind, ein paar Stunden am Tag. Wenn es
|
||||
also in den letzten Stunden einen Bericht gab, pass lieber
|
||||
auf.
|
||||
* Wenn nicht, ist es wahrscheinlich kein Problem :)
|
||||
|
||||
Wir können natürlich nicht garantieren, dass es sicher ist,
|
||||
Wir können natürlich nicht garantieren, dass es sicher ist,
|
||||
also pass trotzdem auf, wer auf dem Bahnsteig steht.
|
||||
Aber je mehr Leute mitmachen, desto eher kannst du dir sicher
|
||||
Aber je mehr Leute mitmachen, desto eher kannst du dir sicher
|
||||
sein, dass wir sie finden, bevor sie uns finden.
|
||||
|
||||
Wenn du immer direkt gewarnt werden willst, kannst du auch die
|
||||
Benachrichtigungen über E-Mail, Telegram, oder den Mastodon RSS
|
||||
feed aktivieren. Entweder:
|
||||
* Gibt hier [deine E-Mail-Adresse an](/city/mail/""" + city + """)
|
||||
* Subscribe dem Telegram-Bot [@ticketfrei_""" + city + \
|
||||
"_bot](https://t.me/ticketfrei_" + city + """_bot)
|
||||
* oder subscribe dem RSS feed von [""" + city + """](""" + masto_link + \
|
||||
""".atom?replies=false&boosts=true)
|
||||
Benachrichtigungen über E-Mail oder Telegram aktivieren. Gib
|
||||
einfach <a href="/city/mail/""" + city + """"/">hier</a> deine
|
||||
E-Mail-Adresse an oder subscribe dem Telegram-Bot [@ticketfrei_""" + city + \
|
||||
"_bot](https://t.me/ticketfrei_" + city + """_bot)
|
||||
|
||||
Also, wenn du weniger Glück hast, und der erste bist, der einen
|
||||
Also, wenn du weniger Glück hast, und der erste bist, der einen
|
||||
Kontrolleur sieht:
|
||||
|
||||
## Was mache ich, wenn ich Kontis sehe?
|
||||
|
@ -398,10 +377,10 @@ Ganz einfach, du schreibst es den anderen. Das geht entweder
|
|||
* über Twitter: [Link zu unserem Profil](""" + twit_link + """)
|
||||
* über Telegram an [@ticketfrei_""" + city + "_bot](https://t.me/ticketfrei_" \
|
||||
+ city + """_bot)
|
||||
* Oder per Mail an [""" + mailinglist + "](mailto:" + mailinglist + """), wenn
|
||||
* Oder per Mail an [""" + mailinglist + "](mailto:" + mailinglist + """), wenn
|
||||
ihr kein Social Media benutzen wollt.
|
||||
|
||||
Schreibe einfach einen Toot oder einen Tweet, der den Bot
|
||||
Schreibe einfach einen Toot oder einen Tweet, der den Bot
|
||||
mentioned, und gib an
|
||||
|
||||
* Wo du die Kontis gesehen hast
|
||||
|
@ -413,11 +392,11 @@ Zum Beispiel so:
|
|||
|
||||
![A toot ready to be shared](https://github.com/b3yond/ticketfrei/raw/stable1/guides/toot_screenshot.png)
|
||||
|
||||
Der Bot wird die Nachricht dann weiterverbreiten, auch zu den
|
||||
Der Bot wird die Nachricht dann weiterverbreiten, auch zu den
|
||||
anderen Netzwerken.
|
||||
Dann können andere Leute das lesen und sicher vor Kontis sein.
|
||||
|
||||
Danke, dass du mithilfst, öffentlichen Verkehr für alle
|
||||
Danke, dass du mithilfst, öffentlichen Verkehr für alle
|
||||
sicherzustellen!
|
||||
|
||||
## Kann ich darauf vertrauen, was random stranger from the Internet mir da erzählen?
|
||||
|
@ -426,31 +405,31 @@ Aber natürlich! Wir haben Katzenbilder!
|
|||
|
||||
![Katzenbilder!](https://lorempixel.com/550/300/cats)
|
||||
|
||||
Glaubt besser nicht, wenn jemand postet, dass die Luft da und
|
||||
Glaubt besser nicht, wenn jemand postet, dass die Luft da und
|
||||
da gerade rein ist.
|
||||
Das ist vielleicht sogar gut gemeint - aber klar könnte die
|
||||
Das ist vielleicht sogar gut gemeint - aber klar könnte die
|
||||
VAG sich hinsetzen und einfach lauter Falschmeldungen posten.
|
||||
|
||||
Aber Falschmeldungen darüber, dass gerade Kontis i-wo unterwegs
|
||||
Aber Falschmeldungen darüber, dass gerade Kontis i-wo unterwegs
|
||||
sind?
|
||||
Das macht keinen Sinn.
|
||||
Im schlimmsten Fall kauft jmd mal eine Fahrkarte mehr - aber
|
||||
Das macht keinen Sinn.
|
||||
Im schlimmsten Fall kauft jmd mal eine Fahrkarte mehr - aber
|
||||
kann sonst immer schwarz fahren.
|
||||
|
||||
Also ja - es macht Sinn, uns zu vertrauen, wenn wir sagen, wo
|
||||
Also ja - es macht Sinn, uns zu vertrauen, wenn wir sagen, wo
|
||||
gerade Kontis sind.
|
||||
|
||||
## Was ist Mastodon und warum sollte ich es benutzen?
|
||||
|
||||
Mastodon ist ein dezentrales soziales Netzwerk - so wie
|
||||
Mastodon ist ein dezentrales soziales Netzwerk - so wie
|
||||
Twitter, nur ohne Monopol und Zentralismus.
|
||||
Ihr könnt Kurznachrichten (Toots) über alles mögliche
|
||||
Ihr könnt Kurznachrichten (Toots) über alles mögliche
|
||||
schreiben, und euch mit anderen austauschen.
|
||||
|
||||
Mastodon ist Open Source, Privatsphäre-freundlich und relativ
|
||||
Mastodon ist Open Source, Privatsphäre-freundlich und relativ
|
||||
sicher vor Zensur.
|
||||
|
||||
Um Mastodon zu benutzen, besucht diese Seite:
|
||||
Um Mastodon zu benutzen, besucht diese Seite:
|
||||
[https://joinmastodon.org/](https://joinmastodon.org/)
|
||||
"""
|
||||
mail_md = """# Immer up-to-date
|
||||
|
@ -460,15 +439,15 @@ zu schauen? Kein Problem. Unsere Mail Notifications benachrichtigen dich, wenn
|
|||
irgendwo Kontis gesehen werden.
|
||||
|
||||
Wenn du uns deine E-Mail-Adresse gibst, kriegst du bei jedem Konti-Report eine
|
||||
Mail. Wenn du eine Mail-App auf dem Handy hast, so wie
|
||||
Mail. Wenn du eine Mail-App auf dem Handy hast, so wie
|
||||
[K9Mail](https://k9mail.github.io/), kriegst du sogar eine Push Notification. So
|
||||
bist du immer Up-to-date über alles, was im Verkehrsnetz passiert.
|
||||
|
||||
## Keine Sorge
|
||||
|
||||
Wir benutzen deine E-Mail-Adresse selbstverständlich für nichts anderes. Du
|
||||
Wir benutzen deine E-Mail-Adresse selbstverständlich für nichts anderes. Du
|
||||
kannst die Benachrichtigungen jederzeit deaktivieren, mit jeder Mail wird ein
|
||||
unsubscribe-link mitgeschickt.
|
||||
unsubscribe-link mitgeschickt.
|
||||
"""
|
||||
db.execute("""INSERT INTO cities(user_id, city, markdown, mail_md,
|
||||
masto_link, twit_link) VALUES(?,?,?,?,?,?)""",
|
||||
|
|
Loading…
Reference in New Issue