From 0434bf5854a85b02c5dfe77b6399c509bfc12a42 Mon Sep 17 00:00:00 2001 From: Ceda EI Date: Tue, 29 Jan 2019 02:57:31 +0530 Subject: [PATCH] Add /time --- bot/bot.py | 7 ++++--- chat_mod/init.lua | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/bot/bot.py b/bot/bot.py index 8c9f44f..66dba24 100644 --- a/bot/bot.py +++ b/bot/bot.py @@ -87,15 +87,16 @@ def message_handling(bot, update): data=params) -def list_cmd(bot, update): +def direct_cmd(bot, update, text): if update.message.chat.id in config.groups: - params = {"message": "list"} + params = {"message": text} requests.post("http://localhost:" + str(config.port) + "/post", data=params) updater = Updater(token=config.api_key) dispatcher = updater.dispatcher -dispatcher.add_handler(CommandHandler('list', list_cmd)) +dispatcher.add_handler(CommandHandler('list', lambda x, y: direct_cmd(x, y, "list"))) +dispatcher.add_handler(CommandHandler('time', lambda x, y: direct_cmd(x, y, "time"))) dispatcher.add_handler(MessageHandler(Filters.all, message_handling)) updater.start_polling() diff --git a/chat_mod/init.lua b/chat_mod/init.lua index 15e86e4..fb530d4 100644 --- a/chat_mod/init.lua +++ b/chat_mod/init.lua @@ -10,6 +10,11 @@ function send_messages(res) end http_api.fetch_async({url = "http://localhost:" .. port .. "/sendCode", post_data = {message = text}}) + elseif message == "time" then + local x = minetest.get_timeofday() + local text = string.format("%02d:%02d", math.floor(x*24), math.floor((x*24*60) % 60)) + http_api.fetch_async({url = "http://localhost:" .. port .. "/sendCode", + post_data = {message = text}}) else minetest.chat_send_all(message) end