示例#1
0
 def ask_attack(self, user_id, message_id):
     if current_war.stage == 'siege':
         string = 'Выберите чат для начала осады'
         targets = self.get_target_chats()
         buttons = []
         for target in targets:
             buttons.append(
                 keyboards.Button(target.name + ' - ' +
                                  str(self.get_attack_price(target)),
                                  callback_data='_'.join(
                                      ['mngt', 'attack', target.chat_id])))
         keyboard = keyboards.form_keyboard(*buttons)
     elif current_war.stage == 'attack':
         string = 'Выберите чат на атаки'
         targets = self.get_target_chats()
         buttons = []
         for target in targets:
             buttons.append(
                 keyboards.Button(target.name,
                                  callback_data='_'.join(
                                      ['mngt', 'attack', target.chat_id])))
         keyboard = keyboards.form_keyboard(*buttons)
     else:
         delete_message(user_id, message_id)
         return False
     if self.ask_rights(user_id) == 'admin':
         edit_message(user_id, message_id, string, reply_markup=keyboard)
     else:
         self.send_message('У вас нет прав. Вы бесправный.')
示例#2
0
 def handle(self, call):
     call_data = call.data.split('_')
     action = call_data[2]
     if action == 'craft':
         chat = get_chat(call_data[1])
         item_name = call_data[-1]
         item_class = standart_actions.get_class(item_name)
         name = standart_actions.get_name(item_name, 'rus')
         chat.add_resources(-item_class.price)
         chat.add_item(item_name)
         chat.delete_receipt(item_name)
         edit_message(call.message.chat.id, call.message.message_id,
                      name + ' - произведено.')
     elif action == 'cancel':
         delete_message(call.message.chat.id, call.message.message_id)
示例#3
0
    def act(self):
        if self.current_war.id != self.current_war_id:
            self.refuse('Ошибка! Вы пытаетесь воспользоваться неактуальной кнопкой!')
            delete_message(call=self.call)

        elif self.chat.chat_id in self.target_chat.get_current_war_data()['attacked_by_chats']:
            self.refuse('Ошибка! Вы уже атаковали этот чат!')
            delete_message(call=self.call)
        else:
            self.chat.marauder(self.target_chat.chat_id)
            delete_message(call=self.call)
示例#4
0
 def act(self):
     if self.current_war.id != self.current_war_id:
         self.refuse('Ошибка! Вы пытаетесь воспользоваться неактуальной кнопкой!')
         delete_message(call=self.call)
     elif str(self.chat.chat_id) in self.chat.get_current_war_data()['chats_besieged']:
         self.refuse('Ошибка! Вы уже осадили этот чат!')
         delete_message(call=self.call)
     else:
         self.current_war.release_attack_lobby(self.chat.chat_id, self.target_chat.chat_id)
         self.chat.win_siege(self.target_chat.chat_id)
         delete_message(call=self.call)
示例#5
0
 def act(self):
     message_id = self.call.message.message_id
     delete_message(self.call.message.chat.id, message_id)
示例#6
0
 def delete_message(self):
     bot_methods.delete_message(self.chat_id, self.message_id)
示例#7
0
 def attack_chat(self, call, target_chat):
     delete_message(call.from_user.id, call.message.message_id)
     from chat_wars.chat_lobbies import AttackLobby
     action = AttackAction()
     action.mode = current_war.stage
     AttackLobby(self, action, target_chat).send_lobby()
示例#8
0
 def handle(self, call):
     call_data = call.data.split('_')
     bot_methods.delete_message(call=call)
     MobFight(int(call_data[-1]), mob_list=[call_data[-2]]).send_lobby()
示例#9
0
 def delete_map(self):
     if self.party.leader.message_id is not None:
         for member in self.party.members:
             bot_methods.delete_message(message_id=member.message_id,
                                        chat_id=member.chat_id)
             member.message_id = None