diff --git a/README.md b/README.md index 4642889..cbc26fa 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ $ pip3 install Mastodon.py - [ ] Mastodon: boost people - [ ] Mastodon: toot who has been retweeted on twitter - [ ] Twitter: tweet who has been boosted on mastodon -- [ ] Twitter: access the API +- [x] Twitter: access the API - [ ] Web UI that lets you easily delete toots/tweets per db id and mute the tweet author diff --git a/triggerwords.txt b/triggerwords.txt new file mode 100644 index 0000000..1463537 --- /dev/null +++ b/triggerwords.txt @@ -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 diff --git a/twitter/main.py b/twitter/main.py index 43dc5b8..bddb34d 100644 --- a/twitter/main.py +++ b/twitter/main.py @@ -1,8 +1,54 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python __author__ = "b3yond" import twitter +from time import sleep -api = twitter.Api() +""" +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 \ No newline at end of file diff --git a/twitter/share/python-wheels/CacheControl-0.11.5-py2.py3-none-any.whl b/twitter/share/python-wheels/CacheControl-0.11.5-py2.py3-none-any.whl deleted file mode 100644 index 12b34d6..0000000 Binary files a/twitter/share/python-wheels/CacheControl-0.11.5-py2.py3-none-any.whl and /dev/null differ diff --git a/twitter/share/python-wheels/chardet-2.3.0-py2.py3-none-any.whl b/twitter/share/python-wheels/chardet-2.3.0-py2.py3-none-any.whl deleted file mode 100644 index daa9a12..0000000 Binary files a/twitter/share/python-wheels/chardet-2.3.0-py2.py3-none-any.whl and /dev/null differ diff --git a/twitter/share/python-wheels/colorama-0.3.7-py2.py3-none-any.whl b/twitter/share/python-wheels/colorama-0.3.7-py2.py3-none-any.whl deleted file mode 100644 index 65328bf..0000000 Binary files a/twitter/share/python-wheels/colorama-0.3.7-py2.py3-none-any.whl and /dev/null differ diff --git a/twitter/share/python-wheels/distlib-0.2.2-py2.py3-none-any.whl b/twitter/share/python-wheels/distlib-0.2.2-py2.py3-none-any.whl deleted file mode 100644 index 827bd27..0000000 Binary files a/twitter/share/python-wheels/distlib-0.2.2-py2.py3-none-any.whl and /dev/null differ diff --git a/twitter/share/python-wheels/html5lib-0.999-py2.py3-none-any.whl b/twitter/share/python-wheels/html5lib-0.999-py2.py3-none-any.whl deleted file mode 100644 index 0f920d5..0000000 Binary files a/twitter/share/python-wheels/html5lib-0.999-py2.py3-none-any.whl and /dev/null differ diff --git a/twitter/share/python-wheels/ipaddress-0.0.0-py2.py3-none-any.whl b/twitter/share/python-wheels/ipaddress-0.0.0-py2.py3-none-any.whl deleted file mode 100644 index 9ffe578..0000000 Binary files a/twitter/share/python-wheels/ipaddress-0.0.0-py2.py3-none-any.whl and /dev/null differ diff --git a/twitter/share/python-wheels/lockfile-0.12.2-py2.py3-none-any.whl b/twitter/share/python-wheels/lockfile-0.12.2-py2.py3-none-any.whl deleted file mode 100644 index 852e2bd..0000000 Binary files a/twitter/share/python-wheels/lockfile-0.12.2-py2.py3-none-any.whl and /dev/null differ diff --git a/twitter/share/python-wheels/packaging-16.6-py2.py3-none-any.whl b/twitter/share/python-wheels/packaging-16.6-py2.py3-none-any.whl deleted file mode 100644 index 06f5b14..0000000 Binary files a/twitter/share/python-wheels/packaging-16.6-py2.py3-none-any.whl and /dev/null differ diff --git a/twitter/share/python-wheels/pip-8.1.1-py2.py3-none-any.whl b/twitter/share/python-wheels/pip-8.1.1-py2.py3-none-any.whl deleted file mode 100644 index 2c4bff4..0000000 Binary files a/twitter/share/python-wheels/pip-8.1.1-py2.py3-none-any.whl and /dev/null differ diff --git a/twitter/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl b/twitter/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl deleted file mode 100644 index 0a85026..0000000 Binary files a/twitter/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl and /dev/null differ diff --git a/twitter/share/python-wheels/progress-1.2-py2.py3-none-any.whl b/twitter/share/python-wheels/progress-1.2-py2.py3-none-any.whl deleted file mode 100644 index 892afeb..0000000 Binary files a/twitter/share/python-wheels/progress-1.2-py2.py3-none-any.whl and /dev/null differ diff --git a/twitter/share/python-wheels/pyparsing-2.0.3-py2.py3-none-any.whl b/twitter/share/python-wheels/pyparsing-2.0.3-py2.py3-none-any.whl deleted file mode 100644 index cd81204..0000000 Binary files a/twitter/share/python-wheels/pyparsing-2.0.3-py2.py3-none-any.whl and /dev/null differ diff --git a/twitter/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl b/twitter/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl deleted file mode 100644 index 091c1ec..0000000 Binary files a/twitter/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl and /dev/null differ diff --git a/twitter/share/python-wheels/retrying-1.3.3-py2.py3-none-any.whl b/twitter/share/python-wheels/retrying-1.3.3-py2.py3-none-any.whl deleted file mode 100644 index b5992ae..0000000 Binary files a/twitter/share/python-wheels/retrying-1.3.3-py2.py3-none-any.whl and /dev/null differ diff --git a/twitter/share/python-wheels/setuptools-20.7.0-py2.py3-none-any.whl b/twitter/share/python-wheels/setuptools-20.7.0-py2.py3-none-any.whl deleted file mode 100644 index 10c5ea9..0000000 Binary files a/twitter/share/python-wheels/setuptools-20.7.0-py2.py3-none-any.whl and /dev/null differ diff --git a/twitter/share/python-wheels/six-1.10.0-py2.py3-none-any.whl b/twitter/share/python-wheels/six-1.10.0-py2.py3-none-any.whl deleted file mode 100644 index 7895a74..0000000 Binary files a/twitter/share/python-wheels/six-1.10.0-py2.py3-none-any.whl and /dev/null differ diff --git a/twitter/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl b/twitter/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl deleted file mode 100644 index 7b0cd26..0000000 Binary files a/twitter/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl and /dev/null differ diff --git a/twitter/share/python-wheels/wheel-0.29.0-py2.py3-none-any.whl b/twitter/share/python-wheels/wheel-0.29.0-py2.py3-none-any.whl deleted file mode 100644 index 71f3a5c..0000000 Binary files a/twitter/share/python-wheels/wheel-0.29.0-py2.py3-none-any.whl and /dev/null differ