Angerstoner
6 years ago
3 changed files with 65 additions and 5 deletions
@ -0,0 +1,52 @@ |
|||
import twitter |
|||
|
|||
pepito_id = 333923305 |
|||
last_status = None |
|||
pepito_groups = [] |
|||
|
|||
|
|||
def get_twitter_instance(): |
|||
twitter_config = {} |
|||
with open("config/twitter_config") as tmp_file: |
|||
for line in tmp_file: |
|||
(key, val) = line.split('=') |
|||
twitter_config[key] = val.replace('\n', '') |
|||
|
|||
return twitter.Api(consumer_key=twitter_config['consumer_key'], |
|||
consumer_secret=twitter_config['consumer_secret'], |
|||
access_token_key=twitter_config['access_token_key'], |
|||
access_token_secret=twitter_config['access_token_secret']) |
|||
|
|||
|
|||
def toggle_pepito_for_group(bot, update): |
|||
global pepito_groups |
|||
chat_id = update.message.chat_id |
|||
|
|||
if chat_id in pepito_groups: |
|||
pepito_groups.remove(chat_id) |
|||
update.message.reply_text("Pepito is now disabled!") |
|||
else: |
|||
pepito_groups.append(update.message.chat_id) |
|||
update.message.reply_text("Pepito is now enabled!") |
|||
|
|||
|
|||
def check_pepito_and_post_auto(bot, update): |
|||
api = get_twitter_instance() |
|||
current_status = api.GetUserTimeline(pepito_id)[0] |
|||
global last_status |
|||
if last_status != current_status: |
|||
for group_id in pepito_groups: |
|||
bot.send_message(chat_id=group_id, text=current_status.AsDict()['text']) |
|||
last_status = current_status |
|||
|
|||
|
|||
def check_pepito_and_post_manually(bot, update): |
|||
api = get_twitter_instance() |
|||
current_status = api.GetUserTimeline(pepito_id)[0] |
|||
global last_status |
|||
if last_status != current_status: |
|||
for group_id in pepito_groups: |
|||
bot.send_message(chat_id=group_id, text=current_status.AsDict()['text']) |
|||
last_status = current_status |
|||
else: |
|||
update.message.reply_text(current_status.AsDict()['text']) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue