Add /time

This commit is contained in:
Ceda EI 2019-01-29 02:57:31 +05:30
parent 0238610cd1
commit 0434bf5854
2 changed files with 9 additions and 3 deletions

View File

@ -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()

View File

@ -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