def main(): args = parse_args() configure_logger() event_loop = asyncio.get_event_loop() game_config = GameConfig.from_file(args.game_config) game_controller = GameController(game_config, args.state_files_directory) if args.server_port is not None: remote_commands_handler = RemoteCommandsHandler(game_controller) remote_commander_server = RemoteCommanderServer( args.server_port, remote_commands_handler.handle_command) event_loop.create_task(remote_commander_server.start()) if args.bot_config is not None: bot_config = json.load(args.bot_config) ad_twitch_bot = AdBot(bot_config, event_loop) TwitchGameMediator(ad_twitch_bot, game_controller).run() else: Commander(game_controller).run()
def main(): init() Commander().start()
'user_id': user_id, 'message': message, "random_id": random.randint(0, 1000) }) # API-ключ созданный ранее token = "5d1d08c4b4b739b6718b5a9a09aa71332ba4f687aa58321344f706b4351c2a470d3a9011ad64e312dad30" # Авторизуемся как сообщество vk = vk_api.VkApi(token=token) # Работа с сообщениями longpoll = VkLongPoll(vk) commander = Commander() print("Server started") for event in longpoll.listen(): if event.type == VkEventType.MESSAGE_NEW: if event.to_me: print('New message:') print(f'For me by: {event.user_id}', end='') bot = VkBot(event.user_id) if event.text[0] == "/": write_msg(event.user_id, commander.do(event.text[1::])) else: