Ejemplo n.º 1
0
 def send_page(self):
     self.form_actions()
     text = self.get_menu_string()
     if self.call is None:
         send_message(self.user_id, text, reply_markup=self.get_menu_keyboard())
     else:
         edit_message(self.user_id, self.call.message.message_id, text, reply_markup=self.get_menu_keyboard())
Ejemplo n.º 2
0
 def edit_message(self, lang_tuple, reply_markup=None):
     if isinstance(lang_tuple, str):
         return bot_methods.edit_message(self.chat_id, self.message_id,
                                         lang_tuple, reply_markup=reply_markup)
     else:
         return bot_methods.edit_message(self.chat_id, self.message_id,
                                         lang_tuple.translate(self.lang), reply_markup=reply_markup)
Ejemplo n.º 3
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('У вас нет прав. Вы бесправный.')
Ejemplo n.º 4
0
 def actor_error(self, call):
     bot_methods.edit_message(call.message.chat.id,
                              call.message.message_id,
                              call.message.text,
                              reply_markup=types.InlineKeyboardMarkup())
     bot.answer_callback_query(callback_query_id=call.id,
                               show_alert=False,
                               text="Turn error!")
Ejemplo n.º 5
0
 def update_lobby(self, keyboard=True):
     message = self.create_lobby()
     if self.image is None:
         bot_methods.edit_message(
             self.chat_id,
             message_id=self.message_id,
             message_text=message,
             reply_markup=self.keyboard() if keyboard else None)
     else:
         bot_methods.bot.edit_message_caption(
             caption=message,
             chat_id=self.chat_id,
             message_id=self.message_id,
             reply_markup=self.keyboard() if keyboard else None)
Ejemplo n.º 6
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)
Ejemplo n.º 7
0
 def send_equipment_choice(self,
                           lobby_id,
                           chat_id,
                           equipment_type,
                           message_id=None):
     message = self.form_equipment_message(lobby_id, equipment_type)
     buttons = self.create_choice_equipment(lobby_id, chat_id,
                                            equipment_type)
     for button in self.choice_button(lobby_id, equipment_type):
         buttons.append(button)
     keyboard = keyboards.form_keyboard(*buttons)
     if message_id is None:
         send_message(self.user_id, message, reply_markup=keyboard)
     else:
         edit_message(chat_id=self.user_id,
                      message_id=message_id,
                      message_text=message,
                      reply_markup=keyboard)
Ejemplo n.º 8
0
 def get_ready_message(self, user_id, message_id):
     bot_methods.edit_message(user_id, message_id, 'Вы готовы.')
Ejemplo n.º 9
0
 def update_lobby(self, keyboard=True):
     message = self.create_lobby()
     bot_methods.edit_message(self.chat_id, message_id=self.message_id, message_text=message,
                              reply_markup=self.keyboard() if keyboard else None)
Ejemplo n.º 10
0
 def edit_message(self, text, reply_markup=None):
     return bot_methods.edit_message(self.chat_id,
                                     self.message_id,
                                     text,
                                     reply_markup=reply_markup)