Created
June 3, 2017 15:24
Revisions
-
saschalalala created this gist
Jun 3, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ def admin_only(func): def check_permissions(*args, **kwargs): bot = args[0] update = args[1] admin_ids = list(Player.objects.filter(gm=True).values_list('telegram_id', flat=True)) current_user = update.message.from_user if current_user.id not in admin_ids: update.message.reply_text("You are not allowed to do this, Troubleshooter. This incident will be reported") message = "The user {} just entered a forbidden command.".format(current_user) log_channel_id = Game.objects.get(pk=1).channel_id bot.sendMessage(log_channel_id, message) return 1 return func(*args, **kwargs) return check_permissions def silent_in_group(func): def dont_process_commands_from_groups(*args, **kwargs): bot = args[0] update = args[1] if update.message.chat.id < 0: current_user = update.message.from_user bot.send_message(current_user.id, 'Commands from group chats are not supported, please repeat') return 1 return func(*args, **kwargs) return dont_process_commands_from_groups