From 4e4dff87ac4513d88e59403e02623b0343bee496 Mon Sep 17 00:00:00 2001 From: rajat404 <404rajat@gmail.com> Date: Mon, 17 Aug 2015 18:36:02 +0530 Subject: [PATCH 1/3] load blacklisted words & users from config file --- config.sample | 8 ++++++++ retweet.py | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/config.sample b/config.sample index f05ee1b..2f0607b 100644 --- a/config.sample +++ b/config.sample @@ -9,3 +9,11 @@ consumer_key: consumer_secret: access_token: access_token_secret: + +# Leave blank if you don't want to blacklist any users or words +[preferences] +# blacklisted_users = ['example_user_1','example_user_2'] +blacklisted_users = [] + +# blacklisted_words = ["example_word_1", "example_word_2"] +blacklisted_words = [] diff --git a/retweet.py b/retweet.py index c1902f6..d97da4c 100644 --- a/retweet.py +++ b/retweet.py @@ -14,8 +14,9 @@ tweetLanguage = config.get("settings","tweet_language") # blacklisted users and words -userBlacklist = [] -wordBlacklist = ["RT", u"♺"] +userBlacklist = ast.literal_eval(config.get("preferences", "blacklisted_users")) +wordBlacklist = ast.literal_eval(config.get("preferences", "blacklisted_words")) +wordBlacklist.extend(["RT", u"♺"]) # build savepoint path + file hashedHashtag = hashlib.md5(hashtag).hexdigest() From 84c133e8fc66af1ba912d84dd178d2a771be289e Mon Sep 17 00:00:00 2001 From: rajat404 <404rajat@gmail.com> Date: Mon, 17 Aug 2015 18:37:24 +0530 Subject: [PATCH 2/3] removed empty line --- config.sample | 1 - 1 file changed, 1 deletion(-) diff --git a/config.sample b/config.sample index 2f0607b..42e8102 100644 --- a/config.sample +++ b/config.sample @@ -14,6 +14,5 @@ access_token_secret: [preferences] # blacklisted_users = ['example_user_1','example_user_2'] blacklisted_users = [] - # blacklisted_words = ["example_word_1", "example_word_2"] blacklisted_words = [] From 619a6ed4aca70abb7cd0a8b29be380bcb5cf2409 Mon Sep 17 00:00:00 2001 From: rajat404 <404rajat@gmail.com> Date: Mon, 17 Aug 2015 18:43:43 +0530 Subject: [PATCH 3/3] imported `ast` module --- retweet.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retweet.py b/retweet.py index d97da4c..400df9c 100644 --- a/retweet.py +++ b/retweet.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -import os, ConfigParser, tweepy, inspect, hashlib +import os, ConfigParser, tweepy, inspect, hashlib, ast path = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))