forked from ticketfrei/ticketfrei
Merge branch 'master' of dl6tom.de:public/ticketfrei
This commit is contained in:
commit
e476c9b2da
13
README
13
README
|
@ -1,13 +0,0 @@
|
|||
INSTALL
|
||||
=======
|
||||
|
||||
Install python3 with your favourite package manager.
|
||||
Create and activate virtualenv
|
||||
```shell
|
||||
$ virtualenv -p python3 .
|
||||
$ . bin/activate
|
||||
```
|
||||
Install dependencies
|
||||
```shell
|
||||
$ pip3 install Mastodon.py pytoml
|
||||
```
|
53
README.md
Normal file
53
README.md
Normal file
|
@ -0,0 +1,53 @@
|
|||
# Ticketfrei micro messaging bot
|
||||
|
||||
<!-- This mastodon/twitter bot has one purpose - breaking the law. -->
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
# Install
|
||||
|
||||
Install python3 with your favourite package manager.
|
||||
Create and activate virtualenv
|
||||
```shell
|
||||
$ virtualenv -p python3 .
|
||||
$ . bin/activate
|
||||
```
|
||||
Install dependencies
|
||||
```shell
|
||||
$ pip3 install Mastodon.py pytoml
|
||||
```
|
||||
|
||||
## ideas
|
||||
|
||||
* You can only use the twitter API if you have confirmed a phone number and sacrificed a penguin in a blood ritual. So we should build it in a way that it uses the twitter web GUI. It's difficult, but maybe it works. We had another twitter bot that worked similarly, years ago: https://github.com/b3yond/twitter-bot
|
||||
* Make it for mastodon instead of twitter. Mastodon has an open API, that's way more fun. Also mastodon may profit from the network effects though it may be hard to reach the critical mass if you can only use mastodon users.
|
||||
* Bridge to mastodon, so people can use both platforms. Easier to reach the critical mass. But could be hard to do without the twitter API.
|
||||
* Build a tool that deletes wrong toots/tweets on both platforms, would work nicely with a web UI.
|
||||
* write the muted people to the db, to easily undo the mutes if necessary.
|
||||
|
||||
## research
|
||||
|
||||
- [x] How to crawl mentions with the mastodon API
|
||||
- [x] How to boost people with the mastodon API
|
||||
- [x] How to access the twitter API
|
||||
- [ ] How to crawl mentions with the twitter API
|
||||
- [ ] How to retweet people with the twitter API
|
||||
|
||||
## to do
|
||||
|
||||
- [ ] Twitter: Crawl mentions
|
||||
- [ ] Mastodon: Crawl mentions
|
||||
- [ ] Write toots/tweets to database
|
||||
- [ ] Twitter: retweet people
|
||||
- [ ] Mastodon: boost people
|
||||
- [ ] Mastodon: toot who has been retweeted on twitter
|
||||
- [ ] Twitter: tweet who has been boosted on mastodon
|
||||
- [x] Twitter: access the API
|
||||
- [ ] Web UI that lets you easily delete toots/tweets per db id and mute the tweet author
|
||||
|
||||
|
0
triggerwords
Normal file
0
triggerwords
Normal file
24
triggerwords.example
Normal file
24
triggerwords.example
Normal file
|
@ -0,0 +1,24 @@
|
|||
kontrolle
|
||||
ticketfrei
|
||||
konti
|
||||
db
|
||||
zivil
|
||||
sicherheit
|
||||
uniform
|
||||
station
|
||||
bus
|
||||
bahn
|
||||
tram
|
||||
linie
|
||||
nuernberg
|
||||
nbg
|
||||
nürnberg
|
||||
s1
|
||||
s2
|
||||
s3
|
||||
u1
|
||||
u2
|
||||
u3
|
||||
s4
|
||||
u21
|
||||
u11
|
54
twitter/main.py
Normal file
54
twitter/main.py
Normal file
|
@ -0,0 +1,54 @@
|
|||
#!/usr/bin/env python
|
||||
__author__ = "b3yond"
|
||||
|
||||
import twitter
|
||||
from time import sleep
|
||||
|
||||
"""
|
||||
How to get these keys is described in doc/twitter_api.md
|
||||
|
||||
After you received keys, store them in ../../api_keys, one at a line.
|
||||
"""
|
||||
with open("../../api_keys", "r") as file:
|
||||
keys = file.readlines()
|
||||
for i in keys:
|
||||
print i,
|
||||
|
||||
|
||||
# create an Api object
|
||||
api = twitter.Api(consumer_key = keys[0].strip(),
|
||||
consumer_secret = keys[1].strip(),
|
||||
access_token_key = keys[2].strip(),
|
||||
access_token_secret = keys[3].strip())
|
||||
|
||||
|
||||
# This counter is needed to keep track which was the last tweet you retweeted
|
||||
last_rt = ""
|
||||
|
||||
|
||||
# Words which have to be included into the tweets for the tweet to get retweeted
|
||||
with open("../triggerwords.txt", "r") as file:
|
||||
triggers = file.readlines()
|
||||
|
||||
|
||||
while 1:
|
||||
sleep(1)
|
||||
|
||||
# Store all mentions in a list of Status Objects
|
||||
mentions = api.GetMentions(since_id=last_rt)
|
||||
print mentions
|
||||
for i in mentions:
|
||||
print i.user.name, i.user.id, i.text # debug
|
||||
|
||||
# Is the Text of the Tweet in the triggerlist?
|
||||
for j in triggers:
|
||||
if i.text.lower().find(j):
|
||||
|
||||
# Retweet status, save the id so it doesn't get crawled again
|
||||
try:
|
||||
feedback = api.PostRetweet(i.id)
|
||||
print feedback
|
||||
except twitter.error.TwitterError:
|
||||
print("[ERROR] probably you already retweeted this tweet.")
|
||||
last_rt = i.id
|
||||
break
|
Loading…
Reference in a new issue