Skip to content

Commit

Permalink
platforms: telegram: Send message to add member to a Group
Browse files Browse the repository at this point in the history
  • Loading branch information
harshithpabbati committed Jun 11, 2020
1 parent 1ea0207 commit 9013715
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions framework/platforms/telegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,18 @@ def removeUser(self):

def addUser(self):
TELEGRAM_BOT_TOKEN = Token.objects.values().get(key='TELEGRAM_BOT_TOKEN')['value']
TELEGRAM_CHAT_ID = Token.objects.values().get(key='TELEGRAM_CHAT_ID')['value']
ACCESS_TELEGRAM_GROUP_CHAT_ID = Token.objects.values().get(key='ACCESS_TELEGRAM_GROUP_CHAT_ID')['value']
bot = telegram.Bot(token=TELEGRAM_BOT_TOKEN)
user = bot.get_chat(chat_id=self.telegram_id)
message = 'Hi Admin, \n\n'
message += 'Please add @' + user['username'] + ' to amFOSS-2019 Telegram Group, \n\n'
message = 'Hi, \n\n'
message += 'Please add @' + user['username'] + ' to amFOSS Official Telegram Group, \n\n'
message += '<i>This is an automatically generated request powered by the CMS on </i>' \
+ '<i>' + date.today().strftime('%d %B %Y') + '.</i>'
admins = bot.get_chat_administrators(chat_id=TELEGRAM_CHAT_ID)
for admin in admins:
if admin['status'] == "creator":
bot.send_message(
chat_id=admin['user']['id'],
text=message,
parse_mode=telegram.ParseMode.HTML
)
bot.send_message(
chat_id=ACCESS_TELEGRAM_GROUP_CHAT_ID,
text=message,
parse_mode=telegram.ParseMode.HTML
)

def checkIfUserExists(self):
TELEGRAM_BOT_TOKEN = Token.objects.values().get(key='TELEGRAM_BOT_TOKEN')['value']
Expand Down

0 comments on commit 9013715

Please sign in to comment.