コード例 #1
0
 def get_state_menu_if_user_is_not_in_operation_memory(self, message):
     id = message.chat.id
     is_user_id = False
     for key in self.user_menu:
         if key == id:
             is_user_id = True
     if is_user_id == False:
         state = self.userdata.find_user_statemenu(id)
         if CONSTANT.SHOW_DEV_DATA:
             self.bot.send_message(id, "Користувача знайдено, id: " + str(id))
             self.bot.send_message(id, "Загуржено із пам'яті стан меню: " + state)
         if state == CONSTANT.NAME_START_MENU:
             self.user_menu[id] = Start_menu(message, self.userdata, self.bot)
         elif state == CONSTANT.NAME_HELP_MENU:
             self.user_menu[id] = Help_menu(message, self.userdata, self.bot)
         elif state == CONSTANT.NAME_GENERAL_MENU:
             self.user_menu[id] = General_menu(message, self.userdata, self.bot)
         elif state == CONSTANT.NAME_HOME_MENU:
             self.user_menu[id] = Home_menu(message, self.userdata, self.bot)
         elif state == CONSTANT.NAME_CASINO_MENU:
             self.user_menu[id] = Casino_menu(message, self.userdata, self.bot)
         elif state == CONSTANT.NAME_AUTOMAT_MENU:
             self.user_menu[id] = Automat_menu(message, self.userdata, self.bot)
         elif state == CONSTANT.NAME_ROULETTE_MENU:
             self.user_menu[id] = Roulette_menu(message, self.userdata, self.bot)
         elif state == CONSTANT.NAME_LOTTERY_MENU:
             self.user_menu[id] = Lottery_menu(message, self.userdata, self.bot)
         else:
             self.user_menu[id] = General_menu(message, self.userdata, self.bot)
コード例 #2
0
    def press0(self, message):
        for key, i in zip(self.bets, range(len(self.bets))):
            if "❌ Ставка {}".format(i + 1) in message.text:
                del self.bets[key]
                self.update_keyboard(message)
                break
            if "{0}{1}\nСтавка {2}".format(CONSTANT.SYMBOL_MONEY,
                                           self.bets[key],
                                           i + 1) == message.text:
                self.update_need_to_change_money(message)
                self.key_to_change = key
                self.etap = 1
                return self

        if message.text == "❌":
            self.bets = {}
            self.bot.send_message(self.regular_id, "Скинуто всі ставки")
            self.update_inline(message)
            self.update_keyboard(message)
        elif "Сума" in message.text:
            sum = 0
            for key in self.bets:
                sum += self.bets[key]
            self.bot.send_message(
                self.regular_id,
                "Сума всіх ставок - {}{}".format(CONSTANT.SYMBOL_MONEY, sum))
        elif "Ставка" in message.text:
            info = "Всі ставки:\n"
            for key in self.bets:
                info += "Ставка {0}, сума {1}{2}\n".format(
                    key, CONSTANT.SYMBOL_MONEY, self.bets[key])
            self.bot.send_message(self.regular_id, info)

        elif '💸Крутити' in message.text:
            self.spin_roulette(message)

        elif 'Назад' in message.text:
            from Menu.Casino.Casino_menu import Casino_menu
            menu = Casino_menu(message, self.userdata, self.bot)
            return menu
        elif 'На головне меню' in message.text:
            from Menu.General_menu import General_menu
            menu = General_menu(message, self.userdata, self.bot)
            return menu
        return self
コード例 #3
0
 def press(self, message):
     self.lottery_ticket = self.userdata.find_user_lottery_ticket(
         self.regular_id)
     if 'Лотерея' in message.text and self.lottery_ticket > 0:
         from Menu.Casino.Lottery_menu import Lottery_menu
         menu = Lottery_menu(message, self.userdata, self.bot)
         return menu
     elif message.text == 'Рулетка':
         from Menu.Casino.Roulette_menu import Roulette_menu
         menu = Roulette_menu(message, self.userdata, self.bot)
         return menu
     elif message.text == 'Автомат':
         from Menu.Casino.Automat_menu import Automat_menu
         menu = Automat_menu(message, self.userdata, self.bot)
         return menu
     elif message.text == 'Назад':
         from Menu.General_menu import General_menu
         menu = General_menu(message, self.userdata, self.bot)
         return menu
     return self
コード例 #4
0
ファイル: Lottery_menu.py プロジェクト: NukeLeg/GameBot
 def press(self, message):
     self.lottery_ticket = self.userdata.find_user_lottery_ticket(
         self.regular_id)
     if 'Використати один білет' in message.text and self.lottery_ticket > 0:
         self.poll_task = self.bot.send_poll(
             self.regular_id,
             "Виберіть одне із: ",
             ["коробка", 'бутилка', 'ящік', 'носок', "мішок", "пачка"],
             is_anonymous=False)
         self.change_and_write(lottery_ticket=-1)
         self.update1(message)
     elif 'Назад' in message.text:
         if self.poll_task != None:
             self.bot.stop_poll(self.regular_id, self.poll_task.message_id)
         from Menu.Casino.Casino_menu import Casino_menu
         menu = Casino_menu(message, self.userdata, self.bot)
         return menu
     elif 'На головне меню' in message.text:
         if self.poll_task != None:
             self.bot.stop_poll(self.regular_id, self.poll_task.message_id)
         from Menu.General_menu import General_menu
         menu = General_menu(message, self.userdata, self.bot)
         return menu
     return self
コード例 #5
0
ファイル: Start_menu.py プロジェクト: NukeLeg/GameBot
 def press(self, message):
     if message.text == 'Старт':
         from Menu.General_menu import General_menu
         menu = General_menu(message, self.userdata, self.bot)
         return menu
     return self
コード例 #6
0
 def press(self, message):
     self.read_money()
     if message.text == 'Крихітна ставка' and self.money + self.my_stavka >= self.types_of_stavka[
             0]:
         self.money = self.money + self.my_stavka
         self.my_stavka = self.types_of_stavka[0]
         self.money = self.money - self.types_of_stavka[0]
         self.write_money()
         self.update1(message)
     elif message.text == 'Крихітна ставка' and self.money + self.my_stavka < self.types_of_stavka[
             0]:
         self.not_enough()
     elif message.text == 'Мала ставка' and self.money + self.my_stavka >= self.types_of_stavka[
             1]:
         self.money = self.money + self.my_stavka
         self.my_stavka = self.types_of_stavka[1]
         self.money = self.money - self.types_of_stavka[1]
         self.write_money()
         self.update1(message)
     elif message.text == 'Мала ставка' and self.money + self.my_stavka < self.types_of_stavka[
             1]:
         self.not_enough()
     elif message.text == 'Середня ставка' and self.money + self.my_stavka >= self.types_of_stavka[
             2]:
         self.money = self.money + self.my_stavka
         self.my_stavka = self.types_of_stavka[2]
         self.money = self.money - self.types_of_stavka[2]
         self.write_money()
         self.update1(message)
     elif message.text == 'Середня ставка' and self.money + self.my_stavka < self.types_of_stavka[
             2]:
         self.not_enough()
     elif message.text == 'Велика ставка' and self.money + self.my_stavka >= self.types_of_stavka[
             3]:
         self.money = self.money + self.my_stavka
         self.my_stavka = self.types_of_stavka[3]
         self.money = self.money - self.types_of_stavka[3]
         self.write_money()
         self.update1(message)
     elif message.text == 'Велика ставка' and self.money + self.my_stavka < self.types_of_stavka[
             3]:
         self.not_enough()
     elif message.text == 'Гіганська ставка' and self.money + self.my_stavka >= self.types_of_stavka[
             4]:
         self.money = self.money + self.my_stavka
         self.my_stavka = self.types_of_stavka[4]
         self.money = self.money - self.types_of_stavka[4]
         self.write_money()
         self.update1(message)
     elif message.text == 'Гіганська ставка' and self.money + self.my_stavka < self.types_of_stavka[
             4]:
         self.not_enough()
     elif message.text == 'Нереальна ставка' and self.money + self.my_stavka >= self.types_of_stavka[
             5]:
         self.money = self.money + self.my_stavka
         self.my_stavka = self.types_of_stavka[5]
         self.money = self.money - self.types_of_stavka[5]
         self.write_money()
         self.update1(message)
     elif message.text == 'Нереальна ставка' and self.money + self.my_stavka < self.types_of_stavka[
             5]:
         self.not_enough()
     elif message.text == "Крутити 🎰" and self.my_stavka > 0:
         self.spin()
         self.last_stavka = self.my_stavka
         self.my_stavka = 0
         if self.last_stavka <= self.money:
             self.update2(message)
         else:
             self.update(message)
     elif message.text == "Крутити знову 🎰" and self.last_stavka > 0 and self.money >= self.last_stavka:
         self.my_stavka = self.last_stavka
         self.money = self.money - self.my_stavka
         self.bot.send_message(
             self.regular_id, 'Ставка зроблена ' + CONSTANT.SYMBOL_MONEY +
             str(self.my_stavka) + "\nНа рахунку " + CONSTANT.SYMBOL_MONEY +
             str(self.money))
         self.spin()
         self.last_stavka = self.my_stavka
         self.my_stavka = 0
         if self.last_stavka <= self.money:
             self.update2(message)
         else:
             self.update(message)
     elif message.text == 'Інфо':
         self.bot.send_message(self.regular_id, self.automat.info())
     elif message.text == 'Піти в банк і взяти кредит щоб відігратися':
         self.bot.send_message(self.regular_id,
                               "Поки банк не доступний, не побудували")
     elif message.text == 'Назад🚪':
         from Menu.Casino.Casino_menu import Casino_menu
         menu = Casino_menu(message, self.userdata, self.bot)
         self.money = self.money + self.my_stavka
         self.write_money()
         return menu
     elif message.text == 'На головне меню❌':
         from Menu.General_menu import General_menu
         menu = General_menu(message, self.userdata, self.bot)
         self.money = self.money + self.my_stavka
         self.write_money()
         return menu
     return self
コード例 #7
0
    def press1(self, message):
        if '10' == message.text:
            self.etap = 0
            self.bets[self.key_to_change] = 10
            self.bot.send_message(self.regular_id, "Ставка стала 10")
            self.update_keyboard(message)
        elif '50' == message.text:
            self.etap = 0
            self.bets[self.key_to_change] = 50
            self.bot.send_message(self.regular_id, "Ставка стала 50")
            self.update_keyboard(message)
        elif '100' == message.text:
            self.etap = 0
            self.bets[self.key_to_change] = 100
            self.bot.send_message(self.regular_id, "Ставка стала 100")
            self.update_keyboard(message)
        elif '1000' == message.text:
            self.etap = 0
            self.bets[self.key_to_change] = 1000
            self.bot.send_message(self.regular_id, "Ставка стала 1000")
            self.update_keyboard(message)
        elif '10000' == message.text:
            self.etap = 0
            self.bets[self.key_to_change] = 10000
            self.bot.send_message(self.regular_id, "Ставка стала 10000")
            self.update_keyboard(message)
        elif 'Скинути ставку' in message.text:
            self.etap = 0
            del self.bets[self.key_to_change]
            self.key_to_change = None
            self.bot.send_message(self.regular_id, "Ставку скинуто")
            self.update_keyboard(message)
        elif 'x5' in message.text:
            self.etap = 0
            self.bets[self.key_to_change] = self.bets[self.key_to_change] * 5
            self.bot.send_message(self.regular_id, "Ставку збільшено впятеро")
            self.update_keyboard(message)
        elif 'x2' in message.text:
            self.etap = 0
            self.bets[self.key_to_change] = self.bets[self.key_to_change] * 2
            self.bot.send_message(self.regular_id, "Ставку подвоєно")
            self.update_keyboard(message)
        elif 'Відміна' in message.text:
            self.etap = 0
            self.bot.send_message(self.regular_id, "Нічого не змінено")
            self.update_keyboard(message)

        elif 'Назад' in message.text:
            from Menu.Casino.Casino_menu import Casino_menu
            menu = Casino_menu(message, self.userdata, self.bot)
            return menu
        elif 'На головне меню' in message.text:
            from Menu.General_menu import General_menu
            menu = General_menu(message, self.userdata, self.bot)
            return menu
        else:
            try:
                money = int(message.text)
                self.bets[self.key_to_change] = money
                self.bot.send_message(self.regular_id,
                                      "Ставку змінено до {}".format(money))
                self.etap = 0
                self.update_keyboard(message)
            except:
                self.bot.send_message(
                    self.regular_id,
                    "Некоректний ввод. Спробуйте ввести знову")
        return self