Пример #1
0
 def process_deop(self, update, command, params):
     chat_id = update.message.chat_id
     params = params.replace(" ", "").lower()
     moderator = Moderator.select().where(Moderator.username == params)
     if moderator.count():
         moderator[0].delete_instance()
     self.bot.sendChatAction(chat_id=chat_id, action=telegram.ChatAction.TYPING)
     self.bot.sendMessage(chat_id=chat_id, text="Removed permissions for %s" % params)
Пример #2
0
 def _wrapper(self, update, command, params):
     chat_id = update.message.chat_id
     request_username = update.message.from_user.username
     if request_username == MAIN_ADMIN or Moderator.select().where(Moderator.username==request_username).count():
         func(self, update, command, params)
     else:
         self.bot.sendChatAction(chat_id=chat_id, action=telegram.ChatAction.TYPING)
         self.bot.sendMessage(chat_id=chat_id, text="You don't have permissions for this command")
Пример #3
0
 def process_op(self, update, command, params):
     chat_id = update.message.chat_id
     if params:
         params = params.replace(" ", "").lower()
         moderator = Moderator.get_or_create(username=params)
         self.bot.sendChatAction(chat_id=chat_id, action=telegram.ChatAction.TYPING)
         self.bot.sendMessage(chat_id=chat_id, text="Added permissions for %s" % params)
     else:
         moderators = Moderator.select()
         moderators = map(lambda x: x.username, moderators)
         moderators = "\r\n".join(moderators)
         self.bot.sendChatAction(chat_id=chat_id, action=telegram.ChatAction.TYPING)
         self.bot.sendMessage(chat_id=chat_id, text="Ops:\r\n%s" % (moderators or "-----"))