Add /time
This commit is contained in:
parent
0238610cd1
commit
0434bf5854
|
@ -87,15 +87,16 @@ def message_handling(bot, update):
|
||||||
data=params)
|
data=params)
|
||||||
|
|
||||||
|
|
||||||
def list_cmd(bot, update):
|
def direct_cmd(bot, update, text):
|
||||||
if update.message.chat.id in config.groups:
|
if update.message.chat.id in config.groups:
|
||||||
params = {"message": "list"}
|
params = {"message": text}
|
||||||
requests.post("http://localhost:" + str(config.port) + "/post",
|
requests.post("http://localhost:" + str(config.port) + "/post",
|
||||||
data=params)
|
data=params)
|
||||||
|
|
||||||
|
|
||||||
updater = Updater(token=config.api_key)
|
updater = Updater(token=config.api_key)
|
||||||
dispatcher = updater.dispatcher
|
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))
|
dispatcher.add_handler(MessageHandler(Filters.all, message_handling))
|
||||||
updater.start_polling()
|
updater.start_polling()
|
||||||
|
|
|
@ -10,6 +10,11 @@ function send_messages(res)
|
||||||
end
|
end
|
||||||
http_api.fetch_async({url = "http://localhost:" .. port .. "/sendCode",
|
http_api.fetch_async({url = "http://localhost:" .. port .. "/sendCode",
|
||||||
post_data = {message = text}})
|
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
|
else
|
||||||
minetest.chat_send_all(message)
|
minetest.chat_send_all(message)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue