def start(message): try: resources = int(message.text.split()[1]) chat = chat_main.get_chat(message.chat.id) chat.add_resources(resources) except: return False
def __init__(self, chat, user_id, call=None, target_chat=None): ChatAction.__init__(self, chat, user_id, call=call) if target_chat is None: self.target_chat = get_chat(call.data.split('_')[-1]) else: self.target_chat = target_chat from chat_wars.chat_war import current_war self.current_war = current_war
def handle(call): call_data = call.data.split('_') user_id = call.from_user.id chat = get_chat(call_data[1]) action = call_data[2] if not chat.is_admin(user_id): answer_callback_query(call, 'Вы не админ в этом чате!') return False chat_action_dict[action](chat, user_id, call).func()
def handle(call): call_data = call.data.split('_') action = call_data[2] try: lobby = dynamic_dicts.lobby_list[call_data[1]] except: return False if action == 'startlobby': dynamic_dicts.lobby_list[call_data[1]].start() elif action == 'equipment': user_id = call.from_user.id unit_dict = lobby[user_id]['unit_dict'] user = get_user(call.from_user.id) chat = get_chat(lobby.chat_id) item_type = call_data[3] item_name = call_data[-1] item = standart_actions.object_dict[item_name]() if item_name not in ['reset', 'ready'] else None if item_name == 'reset': if item_type == 'armor': for armor in unit_dict['armor']: chat.delete_used_item(armor['name']) unit_dict['armor'] = [] elif item_type == 'item': for item_unit in unit_dict['inventory'].values(): chat.delete_used_item(item_unit[0]['name'], value=item_unit[1]) unit_dict['inventory'] = {} user.send_equipment_choice(call_data[1], chat.chat_id, item_type, message_id=call.message.message_id) elif item_name == 'ready': lobby[user_id]['equipment_choice'].pop() lobby.run_next_step(user_id, message_id=call.message.message_id) elif item_name not in chat.get_free_armory(): bot_methods.answer_callback_query(call, 'Этого предмета уже нет на складе') user.send_equipment_choice(call_data[1], chat.chat_id, item_type, message_id=call.message.message_id) elif not item.try_placement(unit_dict): bot_methods.answer_callback_query(call, 'Вы не можете это экипировать.') elif item_type == 'weapon': chat.use_item(item_name) unit_dict['weapon'] = item.to_dict() lobby[user_id]['equipment_choice'].pop() lobby.run_next_step(user_id, message_id=call.message.message_id) elif item_type == 'armor': chat.use_item(item_name) unit_dict['armor'].append(item.to_dict()) user.send_equipment_choice(call_data[1], chat.chat_id, item_type, message_id=call.message.message_id) elif item_type == 'item': chat.use_item(item_name) test = list(k for k, v in unit_dict['inventory'].items() if v[0]['name'] == item['name']) if test: unit_dict['inventory'][test[0]][1] += 1 else: unit_dict['inventory'][engine.rand_id()] = [item.to_dict(), 1] user.send_equipment_choice(call_data[1], chat.chat_id, item_type, message_id=call.message.message_id)
def __init__(self, chat, user_id, call=None): ChatAction.__init__(self, chat, user_id, call=call) self.target_chat = get_chat(call.data.split('_')[-2]) self.current_war_id = call.data.split('_')[-1] from chat_wars.chat_war import current_war self.current_war = current_war
def __init__(self, chat, user_id, call=None, target_chat=None): ChatMenuPage.__init__(self, chat, user_id, call=call) if target_chat is None: self.target_chat = get_chat(call.data.split('_')[-1]) else: self.target_chat = target_chat
def start(message): chat = chat_main.get_chat(message.chat.id) chat.ask_craft(message.from_user.id)
def start(message): chat = chat_main.get_chat(message.chat.id) chat.print_items()
def start(message): chat = chat_main.get_chat(message.chat.id) chat.print_receipts()
def start(message): chat = chat_main.get_chat(message.chat.id) chat.add_resources(500)
def start(message): chat = chat_main.get_chat(message.chat.id) chat.print_resources()
def start(message): chat = chat_main.get_chat(message.chat.id) chat_menu.chat_action_dict['main'](chat, message.from_user.id, call=None).func()
def start(message): chat = chat_main.get_chat(message.chat.id) chat.show_chat_stats('rus')