Skip to content

Commit

Permalink
adding validation when requesting commands by telegram
Browse files Browse the repository at this point in the history
  • Loading branch information
João Matheus committed Feb 2, 2022
1 parent 79ecb03 commit caa21dc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions config/version.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version:
app: "1.5.20"
config_file: "1.5.20"
app: "1.5.21"
config_file: "1.5.21"
emergency: "false"

19 changes: 11 additions & 8 deletions src/services/telegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,32 +84,35 @@ def start(self):
self.bot = Bot(botFatherToken)
self.bot.set_my_commands(Commands, language_code='en')

def userHasPermission(self, update: Update):
return True if f'{update.message.from_user.id}' in self.telegramConfig['chat_ids'] else False

def sendPrint(update: Update, context: CallbackContext) -> None:
if f'{update.message.from_user.id}' in self.telegramConfig['chat_ids']:
self.commandSendPrint(update)
if userHasPermission(self, update):
self.commandSendPrint(update)

def sendChatId(update: Update, context: CallbackContext) -> None:
if f'{update.message.from_user.id}' in self.telegramConfig['chat_ids']:
if userHasPermission(self, update):
self.commandSendChatId(update)

def sendMap(update: Update, context: CallbackContext) -> None:
if f'{update.message.from_user.id}' in self.telegramConfig['chat_ids']:
if userHasPermission(self, update):
self.commandSendMap(update)

def sendBcoin(update: Update, context: CallbackContext) -> None:
if f'{update.message.from_user.id}' in self.telegramConfig['chat_ids']:
if userHasPermission(self, update):
self.commandSendBcoin(update)

def sendDonation(update: Update, context: CallbackContext) -> None:
if f'{update.message.from_user.id}' in self.telegramConfig['chat_ids']:
if userHasPermission(self, update):
self.commandSendDonation(update)

def sendAllHeroesToWork(update: Update, context: CallbackContext) -> None:
if f'{update.message.from_user.id}' in self.telegramConfig['chat_ids']:
if userHasPermission(self, update):
self.commandAllHeroesToWork(update)

def sendAllHeroesToRest(update: Update, context: CallbackContext) -> None:
if f'{update.message.from_user.id}' in self.telegramConfig['chat_ids']:
if userHasPermission(self, update):
self.commandAllHeroesToRest(update)

commands = [
Expand Down

0 comments on commit caa21dc

Please sign in to comment.