Skip to content

Commit

Permalink
Merge pull request #79 from jmatheusbueno/fix/telegram-message-userid
Browse files Browse the repository at this point in the history
adding validation when requesting commands by telegram
  • Loading branch information
newerton authored Feb 2, 2022
2 parents 79ecb03 + caa21dc commit dd1d5d1
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

2 comments on commit dd1d5d1

@rafilckz
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good afternoon, there is a forecast to update the bot to the most recent version of BOMBECRYPTO

@newerton
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rafilckz The bot is always up to date. If your bot is not able to list the heroes, and why you need to change the theme in your config.yaml to default.

https://github.com/newerton/bombcrypto-bot/#themes

Please sign in to comment.