1
0
forked from MTSR/telegram

Support short bot command syntax

This commit is contained in:
neko259 2019-01-20 23:06:56 +02:00
parent 572c2bb2cf
commit 0172e7e740

View File

@ -90,10 +90,21 @@ function telegram.send_message(chat_id, text)
make_request("sendMessage", request_body, nil)
end
local function get_command(msg)
local comm = nil
local bot_name = nil
comm, bot_name = string.match(msg.text, "/(%a+)@(.+)")
if not comm then
comm = string.match(msg.text, "/(%a+)")
end
-- TODO Check the bot name if using full command
return COMMANDS[comm]
end
function telegram.on_text_receive(msg)
local comm, bot_name = string.match(msg.text, "/(%a+)@(.+)")
-- TODO Check the bot name
local command = COMMANDS[comm]
local command = get_command(msg)
if command then
command(msg)
else