From fe2ea3fe2bde60164c4017ec791f12ac88ba127b Mon Sep 17 00:00:00 2001 From: Jerry Date: Sun, 30 Dec 2018 21:00:54 +0800 Subject: [PATCH] Add readme and minor change --- README.md | 9 +++++++++ tgmsbot.py | 10 ++++------ 2 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..07aec9f --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# Python Telegram Minesweeper Bot +[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](./LICENSE) + +It's a python clone of [@mine_sweeper_bot](https://github.com/hczhcz/telegram-kuso-bots/blob/master/minesweeper.js) +The bot is currently running as [@archcnmsbot](http://telegram.me/archcnmsbot). + +To run the bot yourself, you will need: +- Python3 +- The [python-telegram-bot](https://github.com/python-telegram-bot/python-telegram-bot) module diff --git a/tgmsbot.py b/tgmsbot.py index 65c0cbf..c271586 100644 --- a/tgmsbot.py +++ b/tgmsbot.py @@ -27,12 +27,12 @@ WIN_TEXT_TEMPLATE = "哇所有奇怪的地方都被你打开啦…好羞羞\n" \ "地图:Op {s_op} / Is {s_is} / 3bv {s_3bv}\n操作总数 {ops_count}\n" \ "统计:\n{ops_list}\n{last_player} 你要对人家负责哟/// ///\n\n" \ "用时{time}秒,超时{timeouts}次\n\n" \ - "/mine@{bot_username} 开始新游戏" + "/mine 开始新游戏" LOSE_TEXT_TEMPLATE = "一道火光之后,你就在天上飞了呢…好奇怪喵\n" \ "地图:Op {s_op} / Is {s_is} / 3bv {s_3bv}\n操作总数 {ops_count}\n" \ "统计:\n{ops_list}\n{last_player} 是我们中出的叛徒!\n\n" \ "用时{time}秒,超时{timeouts}次\n\n" \ - "/mine@{bot_username} 开始新游戏" + "/mine 开始新游戏" def display_username(user, atuser=True, shorten=False, markdown=True): @@ -153,7 +153,7 @@ def send_keyboard(bot, update, args): def send_help(bot, update): msg = update.message - msg.reply_text("这是一个扫雷bot\n\n/mine@{} 开始新游戏".format(bot.username)) + msg.reply_text("这是一个扫雷bot\n\n/mine 开始新游戏") logger.debug("Start from {0}".format(update.message.from_user.id)) def send_source(bot, update): @@ -229,7 +229,6 @@ def handle_button_click(bot, update): ops_count = game.actions_sum() ops_list = game.get_actions() last_player = game.get_last_player() - bot_username = bot.username time_used = time.time() - game.start_time timeouts = game.extra["timeout"] if board.state == 2: @@ -238,8 +237,7 @@ def handle_button_click(bot, update): template = LOSE_TEXT_TEMPLATE myreply = template.format(s_op=s_op, s_is=s_is, s_3bv=s_3bv, ops_count=ops_count, ops_list=ops_list, last_player=last_player, - time=round(time_used, 4), timeouts=timeouts, - bot_username=bot_username) + time=round(time_used, 4), timeouts=timeouts) msg.reply_text(myreply, parse_mode="Markdown") game_manager.remove(bhash) else: