def main(): level = 0 menu.main_menu() while level != 21: i = 0 if level == 5 or level == 10 or level == 15: board = shop_map() map(board, level) elif level == 20: board = turorial_map() map(board, level) elif level > 0: board = generate_board(level) map(board, level) elif level == 0: board = turorial_map() map(board, level) while i != 1: i = get_input(board, level) map(board, level) enemy_move(board, level) map(board, level) if i == 1: level += 1 win()
def main(): L = [] # 输入学生信息 while True: main_menu() num = input('请选择菜单操作:') if num == '1': L += input_student() # 添加学生信息 elif num == '2': output_student(L) # 查看所有学生信息 elif num == '3': revise_info(L) # 修改学生信息 elif num == '4': delete_info(L) # 删除学生信息 elif num == '5': sort_score1(L) elif num == '6': sort_score2(L) elif num == '7': sort_age1(L) elif num == '8': sort_age2(L) elif num == '9': write_info(L) elif num == '10': L = read_info() elif num == 'q': return # 退出 else: print('输入有误!')
def main(): if args.download: if args.limit: fetch.d_limit = int(args.limit) fetch.wall_dl() else: fetch.wall_dl() elif args.change: if args.any: wall_set.random_any() wall_set.set_wallpaper() elif args.recent: wall_set.random_recent() wall_set.set_wallpaper() else: wall_set.sequetial() wall_set.set_wallpaper() elif args.all: if args.limit: fetch.d_limit = int(args.limit) fetch.wall_dl() wall_set.sequetial() wall_set.set_wallpaper() else: main_menu()
def Run(): t2 = threading.Thread(target=Sound) t2.daemon = True t2.start() menu.main_menu() print("Done!")
def ask_card(message): flag = True count = 0 telegram_id = message.chat.id payment = user_payment[telegram_id] card_num = message.text[:message.text.find(':')] payment.card_number = card_num file_client = f'.\\storage\\{telegram_id}.json' with open(file_client) as file: client = json.load(file) cards = client['cards'] for item in cards.items(): if card_num == item[0]: flag = False card.subtracting_from_card(bot, message.chat.id, payment.card_number, payment.payment_sum) a = time.strftime("%H:%M:%S %d-%m-%Y", time.localtime()) card.save(bot, telegram_id, card_num, payment.payment_sum, payment.payment_type, payment.phone_number, a) msg = f'Спасибо! \nВы заплатили за {payment.payment_type} {payment.payment_sum} руб. по номеру {payment.phone_number} в {a}.' msg_out = bot.send_message(message.chat.id, msg) menu.main_menu(bot, message.chat.id) break if flag == True: msg = 'Внимательнее! Выберите номер карты, из перечисленных ниже' msg_out = bot.send_message(message.chat.id, msg) bot.register_next_step_handler(msg_out, ask_card)
def start_handler(message): msg = 'Hallo, nice to meet you' msg_out = bot.send_message(message.chat.id, msg) menu.main_menu(bot, message.chat.id) bot.send_sticker( message.chat.id, 'CAACAgIAAxkBAALkol7SyB5mKbDNttoXDpNTD9zihqqaAAK4AAPA-wgAAU2SSZjfsZSOGQQ' )
def start(): # Pygame screen pygame.init() pygame.display.set_caption("Treasure Quest") pygame.display.set_icon(config.SPRITE.entity_dict["sword"]) # Repeat keys when held down pygame.key.set_repeat(350, 75) menu.main_menu()
def show(self, state): """Show main menu""" if self.owner is None: raise SystemError("MainMenuStage is detached from render") main_menu(self.owner.con, self.main_menu_background_image, CONFIG.get('WIDTH'), CONFIG.get('HEIGHT')) if state.error: message_box(self.owner.con, 'No save game to load', 50, CONFIG.get('WIDTH'), CONFIG.get('HEIGHT')) tcod.console_flush()
def GameOverVictory(score, text, foxImg): pygame.mixer.music.load("Assets/Sound/menu.mp3") size = [constants.SCREEN_WIDTH, constants.SCREEN_HEIGHT] win = pygame.display.set_mode(size) font = "Dynamix.ttf" green2 = (20, 90, 50) black = (0, 0, 0) bg = pygame.image.load('Assets/Levels/Menu/Menu.png') bg = pygame.transform.scale(bg, size) if foxImg is not None: foxImg = pygame.transform.scale(foxImg, size) for event in pygame.event.get(): if event.type == pygame.QUIT: # If user clicked close done = True if event.type == pygame.USEREVENT: if event.command == constants.C_OUT: menu.main_menu() if event.command == constants.C_RESTART: main() if event.type == pygame.KEYDOWN: if event.key == pygame.K_s: menu.main_menu() if event.key == pygame.K_r: main() Text = text_format(str(text), font, 70, green2) RestartText = text_format("REINICIAR 'R'", font, 40, black) ExitText = text_format("SALIR 'S'", font, 40, black) ScoreText = text_format("PUNTAJE: " + str(score), font, 40, black) win.blit(bg, (0, 0)) if foxImg is not None: if text == "HAS GANADO": win.blit(pygame.transform.scale(foxImg, (280, 250)), (80, 240)) else: win.blit(pygame.transform.scale(foxImg, (280, 250)), (50, 265)) win.blit(Text, (constants.SCREEN_WIDTH / 2 - int(Text.get_rect()[2] / 2), 80)) win.blit( ScoreText, (constants.SCREEN_WIDTH / 2 - int(ScoreText.get_rect()[2] / 2), 210)) win.blit( RestartText, (constants.SCREEN_WIDTH / 2 - int(RestartText.get_rect()[2] / 2), 345)) win.blit( ExitText, (constants.SCREEN_WIDTH / 2 - int(ExitText.get_rect()[2] / 2), 410)) pygame.display.update()
def player_action(): # Presents information and player action options print( f"\n-- You are at the {colour.purple}{player.location}{colour.end} --" ) #shows the player's current location describe_area( ) # prints the description from game_map corresponding to the current player location print("") print(f" // {game_map[player.location][grid]} //") # prints grid map print(f" // {game_map[player.location][grid2]} //") # prints grid map print(f" // {game_map[player.location][grid3]} //") # prints grid map print("") print(f"-- Player: {colour.purple}{player.name}{colour.end}" ) #print current player name print( f"-- Stats: {colour.red}Health{colour.end}: {player.hp} {colour.red}Power{colour.end}: {player.power}" ) #print current player health and power print(f"-- Inventory:{colour.yellow}{player.inventory}{colour.end}" ) #print current player inventory print("") print("\nWhat do you want to do?") #shows player choices print("") print(f" -- {colour.blue}move{colour.end} -- ") print(f" -- {colour.blue}search{colour.end} -- ") print(f" -- {colour.blue}use{colour.end} -- ") print(f" -- {colour.blue}quit{colour.end} -- ") print(f" -- {colour.blue}save{colour.end} -- ") print("") action = input("> ") allowed = ['move', 'quit', 'search', 'use', 'save'] #valid inputs while action.lower() not in allowed: #if input is not in valid inputs print( f"{colour.red}Invalid commmand.{colour.end} Enter '{colour.blue}move{colour.end}', '{colour.blue}search{colour.end}', '{colour.blue}use{colour.end}', '{colour.blue}save{colour.end}', '{colour.blue}quit{colour.end}' \n" ) action = input("> ") #ask for input again if action.lower() == 'quit': os.system('cls') sure_quit = input( f"Enter '{colour.blue}quit{colour.end}' again to go to the {colour.purple}main menu{colour.end} or any key to cancel\n> " ) #quit check if sure_quit.lower() == 'quit': #quit to main menu os.system('cls') menu.main_menu() #back to main menu else: os.system('cls') #anything other than quit takes you back player_action() elif action.lower() == 'move': player_move(action.lower()) #calls move function elif action.lower() == 'search': player_search() #calls search function elif action.lower() == 'use': player_use() #calls use functioon elif action.lower() == 'save': save_game() # calls save function
def main(self): """ just a main menu wrapper, and level selector """ while self.game.level != -1: if self.game.level == 1: Level1(self.game).run_level() elif self.game.level == 2: Level2(self.game).run_level() elif self.game.level == 0: main_menu(self.game)
def volta_main_menu(): """ Encerra o programa SQL e volta para o menu principal. """ print("Todas as alterações não salvas serão permanentemente perdidas.") print("Tem certeza que deseja sair?") reiterando = input("sim / nao: ") if reiterando.lower() == 'sim': v.FLAG = True m.main_menu() else: inicia_sql()
def main(win): main_menu(win) conv = Database().get() draw(win, user.get_words(), conv) timer = time.time() delay = 1 run = True clock = pygame.time.Clock() while run: clock.tick(60) conv = Database().get() if len(Database().get()) > 43: Database().remove() conv = Database().get() if len(user.get_conv()) != 0: Database().add(user.get_conv()[-1]) user.set_conv([]) events = pygame.event.get() for event in events: if event.type == pygame.QUIT: pygame.quit() run = False if event.type == pygame.KEYDOWN: if not event.key == pygame.K_BACKSPACE: if not event.key == pygame.K_LSHIFT: if not event.key == pygame.K_LCTRL: if not event.key == pygame.K_RETURN: user.add_word() if event.key == pygame.K_BACKSPACE and user.get_words() > 0: user.remove_word() if user.get_words() > 30: textinput.input_string = ( textinput. input_string[:max(textinput.cursor_position - 1, 0)] + textinput.input_string[textinput.cursor_position:]) textinput.cursor_position = max( textinput.cursor_position - 1, 0) user.remove_word() if event.key == pygame.K_RETURN and time.time() - timer > delay: user.reset_words() write_to_conv( user.get_name() + ': ' + textinput.get_text(), user) print(textinput.get_text()) textinput.clear_text() timer = time.time() textinput.update(events) draw(win, user.get_words(), conv) pygame.quit()
def run(self): """ Main game loop """ show_main_menu = True show_load_error_message = False main_menu_background_image = tcod.image_load('menu_background.png') key = tcod.Key() mouse = tcod.Mouse() while not tcod.console_is_window_closed(): tcod.sys_check_for_event(tcod.EVENT_KEY_PRESS | tcod.EVENT_MOUSE, key, mouse) if show_main_menu: main_menu(self.main_console, main_menu_background_image, self.constants['screen_width'], self.constants['screen_height']) if show_load_error_message: message_box(self.main_console, 'No save game to load', 50, self.constants['screen_width'], self.constants['screen_height']) tcod.console_flush() action = handle_main_menu(key) a_new_game = action.get('new_game') a_load_saved_game = action.get('load_game') a_exit_game = action.get('exit') if show_load_error_message and (a_new_game or a_load_saved_game or a_exit_game): show_load_error_message = False elif a_new_game: self.reset_game() show_main_menu = False elif a_load_saved_game: try: self.load_saved_game() show_main_menu = False except FileNotFoundError: show_load_error_message = True elif a_exit_game: break else: tcod.console_clear(self.main_console) self.play_game() show_main_menu = True
def ask_card_adding(message): telegram_id = message.chat.id payment = user_payment[telegram_id] message.text.find(':') payment_card = message.text[0:message.text.find(':')] payment.payment_card = payment_card card.subtracting_from_card(bot, telegram_id, payment_card, -int(payment.payment_amount)) msg = f"Thanks!\nUser: {payment.telegram_id}\n{payment.payment_type}:\n" msg += f"Sum is {payment.payment_amount}" msg_out = bot.send_message(message.chat.id, msg) menu.main_menu(bot, message.chat.id)
def ask_currency(message): if not message.text in ('BY', 'USD', 'EUR', 'RUB'): msg = 'Выберите валюту из предложенных ниже!' msg_out = bot.send_message(message.chat.id, msg) bot.register_next_step_handler(msg_out, ask_currency) return user_card[message.chat.id].currency = message.text new_card = card.new_card(bot, message.chat.id, user_card[message.chat.id].amount, user_card[message.chat.id].currency, user_card[message.chat.id].card_num) msg = f"Карта успешно создана \nНомер карты: {new_card['card_num']}\nСумма: {new_card['amount']} {new_card['currency']}" msg_out = bot.send_message(message.chat.id, msg) menu.main_menu(bot, message.chat.id)
def perform_action(self, input_command, action_list): """Perform an action. Check player's input and compare it with the command list. Arguments: input_command -- command entered by the user action_list -- available actions for the scenario """ # Check if the user wants to leave if input_command == 'MENU': # Go to main menu menu.main_menu() # Check the actions for action in action_list: # Check if default action if action.get_input_type() == 'default': # Save in case it needs to be executed default_action = action continue # Check the commands for command in action.get_command_list(): # Check if player's input is in the command list # Attempt to prevent decoding errors if sys.platform.startswith('win'): is_equal = unicode(input_command.lower(), sys.stdin.encoding) == command.lower() else: is_equal = input_command.lower().decode('utf8') == command.lower() if is_equal: # Command match found if action.get_action_type() == 'text': # Print text print action.get_content() return else: # Jump self.update_scenario(action.get_content()) # Did not perform any action if default_action.get_action_type() == 'text': # Print text print default_action.get_content() return else: # Jump self.update_scenario(default_action.get_content())
def main(): graphics = graph.init_video() graphics.screen.fill((32, 0, 64)) pygame.mouse.set_visible(0) pygame.display.flip() level = game.load_level() mygame = game.init_game(level) graphics.tilemap = level.tilemap graphics.tilemap_height = level.height graphics.tilemap_width = level.width next = "title" mygame.ingame = 0 while next != "quit": if next == "menu": next = menu.main_menu(mygame, level, graphics) if next == "edit": next = "menu" edit.edit(level, graphics) if next == "play": next = game.game(mygame, level, graphics) if next == "title": mygame.sound_12.play() next = menu.title_screen(graphics) if next == "intro": mygame.sound_12.play() next = menu.intro(graphics) if next == "win": mygame.sound_0.play() next = menu.win(graphics) graph.free_video()
def func_history_menu(message): try: bot.send_message(message.chat.id, "Ты нажал кнопку {}".format(message.text)) if message.text == content.BUTTON_MAIN_MENU: menu.first_menu(message) # показать 15 переводов elif message.text == content.BUTTON_LOW: menu.history_menu(message) data = database.Database.show_transaction(database.DATABASE_NAME, content.BUTTON_LOW) for dat in data: bot.send_message(message.chat.id, "Индекс: {}; Simline: {}; Сумма: {};\n Дата: {}; Реквизиты: {}\n Описание: {}".format(dat['id'], dat['simline'], dat['summ'], dat['date'], dat['destination'], dat['description'])) # показать 30 переводов elif message.text == content.BUTTON_MIDDLE: menu.history_menu(message) data = database.Database.show_transaction(database.DATABASE_NAME, content.BUTTON_MIDDLE) for dat in data: bot.send_message(message.chat.id, "Индекс: {}; Simline: {}; Сумма: {};\n Дата: {}; Реквизиты: {}\n Описание: {}".format(dat['id'], dat['simline'], dat['summ'], dat['date'], dat['destination'], dat['description'])) # показать 50 переводов elif message.text == content.BUTTON_HIGH: menu.history_menu(message) data = database.Database.show_transaction(database.DATABASE_NAME, content.BUTTON_HIGH) print(data) for dat in data: bot.send_message(message.chat.id, "Индекс: {}; Simline: {}; Сумма: {};\n Дата: {}; Реквизиты: {}\n Описание: {}".format(dat['id'], dat['simline'], dat['summ'], dat['date'], dat['destination'], dat['description'])) else: menu.history_menu(message) except Exception as e: bot.reply_to(message, 'Error history button. Contact the administrator and please DONT use bot.') menu.main_menu(message)
def pausa(): size = [constants.SCREEN_WIDTH, constants.SCREEN_HEIGHT] win = pygame.display.set_mode(size) font = "Dynamix.ttf" green2 = (20, 90, 50) black = (0, 0, 0) bg = pygame.image.load('Assets/Levels/Menu/Menu.png') bg = pygame.transform.scale(bg, size) foxImg = pygame.image.load( 'Assets/Sprites/personage/Fox/Slide/Slide(5).png') foxImg = pygame.transform.scale(foxImg, size) win = pygame.display.set_mode(size) pausado = True while pausado: for event in pygame.event.get(): if event.type == pygame.QUIT: # If user clicked close done = True if event.type == pygame.USEREVENT: if event.command == constants.C_CONTINUE: pausado = False if event.command == constants.C_OUT: menu.main_menu() if event.type == pygame.KEYDOWN: if event.key == pygame.K_c: pausado = False if event.key == pygame.K_s: menu.main_menu() pausaText = text_format("PAUSA", font, 60, green2) continuarText = text_format("CONTINUAR 'C'", font, 45, black) quitarText = text_format("SALIR 'S'", font, 45, black) win.blit(bg, (0, 0)) win.blit(pygame.transform.scale(foxImg, (280, 250)), (100, 240)) win.blit(pausaText, (360, 150)) win.blit(continuarText, (300, 300)) win.blit(quitarText, (360, 370)) pygame.display.update()
def ask_card_num2(message): now = datetime.now() date_time = now.strftime("%m/%d/%Y,%H:%M:%S") telegram_id = message.chat.id payment = user_payment[telegram_id] message.text.find(':') payment_card = message.text[0:message.text.find(':')] payment.payment_card = payment_card payment.payment_date = date_time card.subtracting_from_card(bot, telegram_id, payment.payment_card, int(payment.payment_sum)) # funcc that draws money card.save(telegram_id, payment.payment_card, int(payment.payment_sum), ['phone', payment.payment_detail]) msg = f"Thanks!\nUser: {payment.telegram_id}\n{payment.payment_type}:\n" msg += f"{payment.payment_detail} \n{payment.payment_sum}\n{payment.payment_date}" msg_out = bot.send_message(message.chat.id, msg) menu.main_menu(bot, message.chat.id)
def main(): """ Bootstrap or main function Initializing PYGAME, create game loop and other features """ logging.basicConfig(filename=LOG_FILE, level=logging.DEBUG) logging.info(datetime.datetime.now()) logging.info('Loading pygame...') pygame.init() logging.info('Initializing pygame...') logging.info('FPS frequency : %s' % FPS_FREQUENCY) window = pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT), 0, 32) pygame.display.set_caption('BATTLE-STORY') cat = Cat(window) jukebox = Jukebox() logging.info('Running game') while True: menu.main_menu(window)
def play(): saves = os.listdir() saves.append("Create a new save") saves.append("Quit") questions = [ { "type": "list", "name": "save_num", "message": "Which save file do you want to load?", "choices": [{"name": i.capitalize()} for i in saves] } ] x = prompt(questions)["save_num"] if x == saves[-2]: main_menu(create_player()) elif x == saves[-1]: print(colored("Thanks for playing!","red")) quit() else: main_menu(read_savefile(x))
def game_end( ): #called to end the game if player dies, boss dies or boss is reasoned with. print(f"{colour.purple}Thank you for playing!{colour.end}") print("") print("\n**Tasks completed**" ) #shows which tasks were completed during the playthrough print("") print(f"{task1.description} = {task1.done}") print(f"{task2.description} = {task2.done}") print(f"{task3.description} = {task3.done}") print(f"{task4.description} = {task4.done}") print(f"{task5.description} = {task5.done}") print(f"{task6.description} = {task6.done}") print(f"{task7.description} = {task7.done}") print("") end = input(f"Enter {colour.blue}quit{colour.end} to exit\n> ") if end.lower() == 'quit': os.system('cls') menu.main_menu() else: end = input(f"Enter {colour.blue}quit{colour.end} to exit\n> ")
def ask_phone_sum(message): if not message.text.isdigit(): msg = 'Сумма должна быть целым числом!' msg_out = bot.send_message(message.chat.id, msg) bot.register_next_step_handler(msg_out, ask_phone_sum) return user_payment[message.chat.id].payment_sum = message.text count = 0 file_client = f'.\\storage\\{message.chat.id}.json' with open(file_client) as file: client = json.load(file) cards = client['cards'] for item in cards.items(): if int(item[1]['amount']) >= int(message.text): count = 1 if count == 0: msg = 'Извините! У Вас недостаточно средств на карте/картах. Создайте новую карту.' msg_out = bot.send_message(message.chat.id, msg) menu.main_menu(bot, message.chat.id) else: msg_out = menu.card_menu(bot, message.chat.id, int(message.text)) bot.register_next_step_handler(msg_out, ask_card)
def main(): """Main Function Refrences all other functions and accepts user input""" db.connect() menu.main_menu() while True: command_main = input("Please choose a menu: ").rstrip() if command_main == "script": menu.display_menu() while True: command_script = input("Enter Command: ").rstrip() if command_script == "main": misc_func.powershell() misc_func.remove_bom() db.logs() elif command_script == "delete": misc_func.delete_disabled() elif command_script == "refresh": misc_func.refresh_list() elif command_script == "disabled": misc_func.get_disabled() elif command_script == "read": misc_func.read_text() elif command_script == "back": menu.main_menu() break continue elif command_main == "query": menu.display_query_menu() while True: command_query = input("Choose a query: ").rstrip() if command_query == "all": print("Filler Text") elif command_query == "os": misc_func.format_select_os() elif command_query == "delete": db.delete_computer() elif command_query == "test": db.test() elif command_query == "back": menu.main_menu() break continue elif command_main == "exit": break else: print("Not a Valid Command") menu.main_menu() db.close() print("The application has closed succesfully")
def main(): """ Executes the main menu from the menu module, and initializes the game, if the user selected play. """ pyconio.settitle("Tetris") draw.cursor(False) selected = menu.main_menu() if selected is None or selected == False: draw.cursor(True) return else: (mode, fieldsize, level) = selected game_init(mode, fieldsize, level)
def login(): welcome = input("Do you have an acount? y/n: ") if welcome == "n": while True: username = input("Enter a username: "******"Enter a password: "******"Confirm password: "******".txt", "wb") pickle.dump({'username': username, 'password': password}, file) file.close() welcome = "y" break print("Passwords do NOT match!") login() if welcome == "y": while True: login1 = input("Login: "******"Password: "******".txt", "rb") as file: data = pickle.load(file) if data['username'] == login1 and data['password'] == login2: name = login1 file = open("currentaccount.txt", "wb") pickle.dump({'Account': name}, file) file.close() menu.main_menu(name) break else: print("Incorrect username or password.") login() except FileNotFoundError: print('Your account is not found, please try again') login()
def load_game(): #load function os.system('cls') load = input( "Load whose game?\n > " ) #asks player for the name of the save file (players chosen name) if os.path.exists(f"{load}.txt"): #if a file of that name exists.. loadGame = open(f'{load}.txt', 'rb') #...open it loadValues = pickle.load(loadGame) #deserialize player.name = loadValues[ 0] #set player.name to index 0 of saveValues(from save function) player.hp = loadValues[ 1] #set player.hp to index 1 of saveValues(from save function) player.power = loadValues[2] player.trait = loadValues[3] player.inventory = loadValues[4] player.location = loadValues[5] task1.done = loadValues[6] task2.done = loadValues[7] task3.done = loadValues[8] task4.done = loadValues[9] task5.done = loadValues[10] game_map['ditch'] = loadValues[11] game_map['thicket'] = loadValues[12] game_map['big tree'] = loadValues[13] game_map['clearing'] = loadValues[14] game_map['hut'] = loadValues[15] game_map['pond'] = loadValues[16] loadGame.close() os.system('cls') print(f"Loaded {colour.purple}{load}'s{colour.end} saved game" ) #print what file has been loaded player_action #player action choices else: print("No save with that name exists!") menu.main_menu( ) #if no save under that name exists, go back to main menu
def main(): g = Game() game_difficulty = menu.main_menu() game_graphic.screen.fill(game_graphic.BACKGROUND) game_graphic.lines_draw() g.play(game_difficulty) while True: scoreX = g.scoreX score0 = g.score0 winner = g.winner if score.main_menu(scoreX, score0, winner) == 2: main() else: g.initialize_game() game_graphic.screen.fill(game_graphic.BACKGROUND) game_graphic.lines_draw() g.play(game_difficulty)
import menu import os # start of programme execution if __name__ == '__main__': os.system('clear') menu.main_menu() pass
def text_handler(message): if message.text == 'Новая карта': card_num = card.new_card_num() telegram_id = message.chat.id new_card = Card(telegram_id, card_num) user_card[telegram_id] = new_card msg = 'Введите сумму' msg_out = bot.send_message(message.chat.id, msg) bot.register_next_step_handler(msg_out, ask_sum) elif message.text == 'Курсы валют': try: response = res.get('https://belarusbank.by/api/kursExchange') curs = json.loads(response.text) usd = curs[0] usd_in = usd['USD_in'] usd_out = usd['USD_out'] eur_in = usd['EUR_in'] eur_out = usd['EUR_out'] rub_in = usd['RUB_in'] rub_out = usd['RUB_out'] msg = 'Курсы валют на сегодня:\nПокупка / продажа \nДоллар - ' + usd_in + ' / ' + usd_out + '\nЕвро - ' + eur_in + ' / ' + eur_out + '\nРоссийский рубль - ' + rub_in + ' / ' + rub_out msg_out = bot.send_message(message.chat.id, msg) except Exception: msg = 'Извините! Возникли проблемы с сайтом. Обратитесь позже.' bot.send_message(message.chat.id, msg) elif message.text == 'Мои карты': card.get_cards(bot, message.chat.id) elif message.text == 'Платежи': try: if not os.path.exists( f'.\\storage\\{message.chat.id}.json') or os.stat( f'.\\storage\\{message.chat.id}.json').st_size == 0: msg = 'У Вас нет созданных карт, которыми можно было бы оплатить операцию. Создайте новую.' msg_out = bot.send_message(message.chat.id, msg) menu.main_menu(bot, message.chat.id) else: menu.payment_menu(bot, message.chat.id) except Exception: msg = 'Извините! Что-то пошло не так. Обратитесь позже.' bot.send_message(message.chat.id, msg) elif message.text == 'Главное меню': menu.main_menu(bot, message.chat.id) elif message.text == 'История платежей': telegram_id = message.chat.id card.get_pay(bot, telegram_id) elif message.text == 'Мобильный телефон' or message.text == 'Домашний интернет': if message.text == 'Мобильный телефон': msg = 'Введите номер телефона' else: msg = 'Введите номер лицевого счёта' new_payment = Payment(message.chat.id, message.text) user_payment[message.chat.id] = new_payment msg_out = bot.send_message(message.chat.id, msg) bot.register_next_step_handler(msg_out, ask_phone_number)
def start_handler(message): msg = 'Привет!' msg_out = bot.send_message(message.chat.id, msg) menu.main_menu(bot, message.chat.id)
def main(args): os.chdir(os.path.dirname(os.path.realpath(__file__))) desired_lang = os.environ.get('LANGUAGE', 'en')[:2] cfg = config.Parse() if 'language' in cfg: desired_lang = cfg['language'] else: cfg['language'] = desired_lang language.select(desired_lang) # Hint the window manager to put the window in the center of the screen os.putenv('SDL_VIDEO_CENTERED', '1') pygame.init() pygame.joystick.init() for i in range(pygame.joystick.get_count()): pygame.joystick.Joystick(i).init() # Ignore mouse motion (greatly reduces resources when not needed) pygame.event.set_blocked(pygame.MOUSEMOTION) pygame.mouse.set_visible(False) available_maps = glob.glob(os.path.join(MAPS_DIR, '*.map')) available_maps = [os.path.basename(m) for m in available_maps] available_maps.sort() selected = { 'players_count': 1, 'map': available_maps[0], 'exit': False, 'toggle_fullscreen': None, 'language': None, 'fullscreen': False, 'new_settings_applied': False, } render = Render(fullscreen=cfg.get('fullscreen', False)) if args.debug: render.show_fps = True while 42: selected['new_settings_applied'] = False selected = menu.main_menu(cfg, render, available_maps, selected) if selected['exit']: break if selected['toggle_fullscreen'] is not None: render.toggle_full_screen(selected['toggle_fullscreen']) selected['toggle_fullscreen'] = None continue if selected['language'] is not None: language.select(selected['language']) selected['language'] = None continue if selected['new_settings_applied']: continue pygame.mixer.init(buffer=512) game_loop( cfg, render, players_count=selected['players_count'], map_name=selected['map'] ) pygame.mixer.stop() render.quit() pygame.quit() sys.exit(0)
def main(): menu.start_menu() global private_key_name print("Please enter key name, or leave blank for the default (stephencoady)") private_key_name = input(" >>> ") if private_key_name == "": private_key_name = "stephencoady" decision = None # this while loop controls the "Main Menu" while decision != "0": menu.main_menu() decision = input("Please enter your choice >>> ") if decision == "1": new_instance() if decision == "2": print("Gathering information about your instances, please wait.") instance_choice = view_all_instances() global my_instances global instance if instance_choice != "x": submenu = None try: instance = my_instances[int(instance_choice)] except Exception as e: error = str(e) print("Please choose an instance from the list!") logger.status_log(error) submenu = "0" # this while loop controls the "Instance Manager" menu while submenu != "0": menu.instance_manager() submenu = input("Please enter your choice >>> ") if submenu == "1": start_instance() if submenu == "2": stop_instance() if submenu == "3": terminate_instance() if submenu == "4": install_python() if submenu == "6": run_user_command() if submenu == "5": # This while loop cntrols the "Nginx Manager" menu nginx_choice = None while nginx_choice != "0": menu.nginx_manager() nginx_choice = input("Please enter your choice >>> ") if nginx_choice == "1": install_nginx() if nginx_choice == "2": copy_web_script() if nginx_choice == "3": run_nginx_check() if nginx_choice == "4": visit_website() if nginx_choice == "5": view_access_log() if nginx_choice == "6": view_error_log() print("\nExiting! Goodbye!")
def admin_html(): html = html_template_start('/admin', c.read_app_config_value('title'), c.read_config_value('firmware_version'), main_menu('/admin')) html += '<form action="/admin_submit" method="post" onsubmit="select_all_options(\'languages\');">' + c.CR html += display_fieldsets(data.ADMIN_FIELDSETS) html += '<input type="submit" value="' + _('Save') + '" name="submit"/>' + c.CR html += '<input type="reset" value="' + _('Cancel changes') + '" name="cancel" style="margin-top:10px;"/>' + c.CR html += '</form>' + c.CR html += html_template_end() return html
def __call__(self): # Check the action type if self.action == 'main': # Main menu if self.char == 'n': # New game menu menu.newgame_menu() elif self.char == 'l': # Load game menu menu.load_menu() elif self.char == 'o': # Options menu menu.options_menu() elif self.char == 'h': # Help menu menu.help_menu() elif self.char == 'a': # About menu menu.about_menu() elif self.char == 'e': # Exit program sys.exit() elif self.action == 'load': # Load menu if self.char == 'b': # Back to main menu menu.main_menu() elif self.char == 'c': # Choose game return self.char elif self.action == 'options': # Load menu if self.char == 'b': # Back to main menu menu.main_menu() elif self.char == 'c': # Choose language return self.char elif self.action == 'new': # New game menu if self.char == 'b': # Back to main menu menu.main_menu() elif self.char == 'c': # Choose game return self.char elif self.action == 'help': # Help menu if self.char == 'b': # Back to main menu menu.main_menu() elif self.action == 'about': # About menu if self.char == 'l': menu.show_license() elif self.char == 'b': # Back to main menu menu.main_menu() elif self.action == 'license': # License if self.char == 'b': # Back to About menu menu.about_menu()
def backup_restore_html(): html = html_template_start('/backup_restore', c.read_app_config_value('title'), c.read_config_value('firmware_version'), main_menu('/backup_restore')) html += '<form action="/backup_restore_submit" method="post" enctype="multipart/form-data">' + c.CR html += open_fieldset(_('Download/Upload')) html += button_row(_('Backup'), '', 'button', _('Download a copy'), 'onclick="download_configuration(\'' + get_config_file_name() + '\');"') + c.CR html += input_row(_('Restore'), 'uploaded_file', 'file') + c.CR html += '<tr><td><input type="submit" value="' + _('Upload') + '" name="submit"/></td><td></td></tr>' + c.CR html += close_fieldset() + '<br/>' html += open_fieldset(_('File content')) html += '<tr><td class="display_file">' html += display_config_file() html += '</td></tr>' html += close_fieldset() html += '</form>' + c.CR html += html_template_end() return html
def configure_html(): html = html_template_start('/configure', c.read_app_config_value('title'), c.read_config_value('firmware_version'), main_menu('/configure'), c.read_config_value('connection_type')) html += '<form action="/configure_submit" method="post" enctype="multipart/form-data">' + c.CR html += display_fieldsets(data.CONFIG_FIELDSETS) html += '<input type="submit" value="' + _('Save configuration') + '" name="submit"/>' + c.CR html += '<input type="reset" value="' + _('Cancel all changes') + '" name="cancel" style="margin-top:10px;"/>' + c.CR html += '</form>' + c.CR html += html_template_end() return html