def __init__(self): locale.setlocale(locale.LC_ALL, '') self.translator = Translater() self.translator.set_key(YANDEX_API_KEY) self.mode = 'EN-->RU' self.default_markup = rkm([['Exit']])
def first_query(self, bot, update): self.__init__() self.mode = rkm([['EN-->RU'], ['RU-->EN']], one_time_keyboard=True) bot.sendMessage( chat_id=update.message.chat.id, text="Select languages:", reply_markup=self.mode )
def set_difficulty(self, query, bot, update): if query == "Easy": self.difficulty = 1 if query == "Medium": self.difficulty = 3 if query == "Hard": self.difficulty = 9 choice = rkm([['Sure!'], ['No, thanks']]) bot.sendMessage(chat_id=update.message.chat.id, text="Ok, " + query + "\nDo you want to play first?", reply_markup=choice)
def __play(self, bot, update): if self.board.get_turn().value == self.wish: choice = rkm([['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']]) bot.sendMessage(chat_id=update.message.chat.id, text="Your turn :)", reply_markup=choice) else: bot.sendMessage(chat_id=update.message.chat.id, text="Well, my turn ... ") self.abp.run(self.board.get_turn(), self.board, self.difficulty) if self.board.get_turn().value == self.wish: self.__status(bot, update) if self.board.is_game_over(): self.__print_winner(bot, update) self.__try_again_check(bot, update) else: self.__play(bot, update)
def __init__(self, bot, message, board_size=10): self.board = Board(board_size) self.bot = bot self.chat_id = message.chat_id player1 = AI(bot, self.chat_id) player2 = Player(bot, self.chat_id, message.from_user.first_name) self.players = dict({'1': player1, '-1': player2}) player1.set_game(self) player1.set_type(PLAYER_TYPE['x']) player2.set_game(self) player2.set_type(PLAYER_TYPE['o']) self.finished = False self.winner = None self.current_player = self.current_player = PLAYER_TYPE['x'] self.again_choice = rkm([['One more time!'], ['Exit']])
def __init__(self): self.start_choice = rkm([['Yes, I start'], ['After you']]) self.again_choice = rkm([['One more time!'], ['Exit']]) self.three_choice = rkm([['1 match'], ['2 matches'], ['3 matches']]) self.current_number = 21
#from search_engine.index import SearchEngine from config import BOT_API_TOKEN from update2text import update2text #from yolo_predictor import YoloPredictor print(os.path.join(os.getcwd(), 'darknet/')) #YOLO = YoloPredictor(os.path.join(os.getcwd(), 'darknet/')) SEARCH_ENGINE = None USERS = {} MAIN_MENU = rkm([ ['tic-tac-toe'], ['5 in a row'], ['matches'], ['wolfram'], ['translator'], ['detect objects'] ], one_time_keyboard=True) MAIN_MENU_AUTH = rkm([ ['question time toggle'] ]) QUEUE = [ ] isQuestionTime = False admins = [32038583]
def __init__(self): self.API = "http://api.wolframalpha.com/v2/query?input={}&appid={}" self.exit = rkm([['Exit']])
def __init__(self, preffix): # prepare model for usage self.cfg, self.weights, metap = self.prepare_all_paths(preffix, "cfg/yolov3.cfg", "yolov3.weights", "cfg/coco.data") self.meta = load_meta(metap) self.net = load_net(self.cfg, self.weights, 0) self.exit = rkm([['Exit']])
def start(self, bot, update): choice = rkm([["Easy"], ["Medium"], ["Hard"]]) bot.sendMessage(chat_id=update.message.chat.id, text="Select difficulty level:", reply_markup=choice)
def __try_again_check(self, bot, update): choice = rkm([['Yes!'], ['Exit']]) bot.sendMessage(chat_id=update.message.chat.id, text="Will play again?", reply_markup=choice)