diff --git a/bindings.lua b/bindings.lua index 07e0e97..82a631a 100644 --- a/bindings.lua +++ b/bindings.lua @@ -77,3 +77,11 @@ function send_location(chat_id, latitude, longitude, reply_to_message_id) return send_request(url) end + +function forward_message(chat_id, from_chat_id, message_id) + + local url = BASE_URL .. 'forwardMessage?chat_id=' .. chat_id .. '&from_chat_id=' .. from_chat_id .. '&message_id=' .. message_id + + return send_request(url) + +end diff --git a/bot.lua b/bot.lua index 7ed4591..341b0a8 100644 --- a/bot.lua +++ b/bot.lua @@ -20,7 +20,9 @@ function on_msg_receive(msg) for i,v in pairs(plugins) do for j,w in pairs(v.triggers) do if string.match(lower, w) then - send_chat_action(msg.chat.id, 'typing') + if not v.no_typing then + send_chat_action(msg.chat.id, 'typing') + end v.action(msg) end end @@ -41,6 +43,9 @@ function bot_init() print('\nFetching bot information...') bot = get_me().result + if not bot then + error('Failure fetching bot information.') + end for k,v in pairs(bot) do print('',k,v) end @@ -102,11 +107,11 @@ reminders = {} last_update = 0 while is_started == true do - local result = get_updates(last_update) - if not result then + local res = get_updates(last_update) + if not res then print('Error getting updates.') else - for i,v in ipairs(get_updates(last_update).result) do + for i,v in ipairs(res.result) do if v.update_id > last_update then last_update = v.update_id on_msg_receive(v.message) @@ -124,3 +129,4 @@ while is_started == true do end end +print('Halted.') diff --git a/config.lua.default b/config.lua.default index d7b2a54..5b25508 100644 --- a/config.lua.default +++ b/config.lua.default @@ -3,7 +3,7 @@ return { biblia_api_key = '', giphy_api_key = 'dc6zaTOxFJmzC', time_offset = 0, - locale = dofile('loc.en'), + locale = dofile('loc/en.lua'), admins = { 0 }, @@ -41,7 +41,7 @@ return { 'whoami.lua', 'lmgtfy.lua' }, - people = { -- For interactions.lua; ID number and nickname + people = { ['55994550'] = 'topkecleon' } } diff --git a/plugins/interactions.lua b/plugins/interactions.lua index 16b9093..f7a0b64 100644 --- a/plugins/interactions.lua +++ b/plugins/interactions.lua @@ -5,6 +5,8 @@ local PLUGIN = {} +PLUGIN.no_typing = true + PLUGIN.triggers = { bot.first_name .. '%p?$', '@' .. bot.username .. '%p?$',