Skip to content

Commit a25e7a0

Browse files
iammarco11Aniketh01
authored andcommitted
Telegram Bot: Restrict the retweet function to admins
1 parent a4ceebc commit a25e7a0

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

tg_bot.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,14 @@ def display_tweet(self, context):
4848
pass
4949
url = 'https://twitter.com/' + \
5050
username + '/status/' + str(line)
51-
keyboard = [[InlineKeyboardButton(
52-
"Retweet", callback_data=int(line))]]
53-
reply_markup = InlineKeyboardMarkup(keyboard)
51+
52+
if job.context in config.tg_admin_id:
53+
keyboard = [[InlineKeyboardButton("Retweet", callback_data=int(line)),InlineKeyboardButton("View", url=url)]]
54+
reply_markup = InlineKeyboardMarkup(keyboard)
55+
else:
56+
keyboard = [[InlineKeyboardButton(
57+
"View", url=url)]]
58+
reply_markup = InlineKeyboardMarkup(keyboard)
5459
if KILL_SIGNAL == 0:
5560
context.bot.send_message(job.context, text=str(url), reply_markup = reply_markup)
5661
#time.sleep(10)
@@ -61,7 +66,7 @@ def display_tweet(self, context):
6166

6267
def start(self, update, context):
6368
print('starting bot')
64-
chat_id = update.message.chat_id
69+
chat_id = int(update.message.chat_id)
6570
try:
6671
if 'job' in context.chat_data:
6772
old_job = context.chat_data['job']

0 commit comments

Comments
 (0)