minor changes

This commit is contained in:
topkecleon 2015-07-19 16:46:06 -04:00
parent f7f2fa5eed
commit 02d30f8451
4 changed files with 22 additions and 6 deletions

View File

@ -77,3 +77,11 @@ function send_location(chat_id, latitude, longitude, reply_to_message_id)
return send_request(url) return send_request(url)
end 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

12
bot.lua
View File

@ -20,7 +20,9 @@ function on_msg_receive(msg)
for i,v in pairs(plugins) do for i,v in pairs(plugins) do
for j,w in pairs(v.triggers) do for j,w in pairs(v.triggers) do
if string.match(lower, w) then if string.match(lower, w) then
if not v.no_typing then
send_chat_action(msg.chat.id, 'typing') send_chat_action(msg.chat.id, 'typing')
end
v.action(msg) v.action(msg)
end end
end end
@ -41,6 +43,9 @@ function bot_init()
print('\nFetching bot information...') print('\nFetching bot information...')
bot = get_me().result bot = get_me().result
if not bot then
error('Failure fetching bot information.')
end
for k,v in pairs(bot) do for k,v in pairs(bot) do
print('',k,v) print('',k,v)
end end
@ -102,11 +107,11 @@ reminders = {}
last_update = 0 last_update = 0
while is_started == true do while is_started == true do
local result = get_updates(last_update) local res = get_updates(last_update)
if not result then if not res then
print('Error getting updates.') print('Error getting updates.')
else 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 if v.update_id > last_update then
last_update = v.update_id last_update = v.update_id
on_msg_receive(v.message) on_msg_receive(v.message)
@ -124,3 +129,4 @@ while is_started == true do
end end
end end
print('Halted.')

View File

@ -3,7 +3,7 @@ return {
biblia_api_key = '', biblia_api_key = '',
giphy_api_key = 'dc6zaTOxFJmzC', giphy_api_key = 'dc6zaTOxFJmzC',
time_offset = 0, time_offset = 0,
locale = dofile('loc.en'), locale = dofile('loc/en.lua'),
admins = { admins = {
0 0
}, },
@ -41,7 +41,7 @@ return {
'whoami.lua', 'whoami.lua',
'lmgtfy.lua' 'lmgtfy.lua'
}, },
people = { -- For interactions.lua; ID number and nickname people = {
['55994550'] = 'topkecleon' ['55994550'] = 'topkecleon'
} }
} }

View File

@ -5,6 +5,8 @@
local PLUGIN = {} local PLUGIN = {}
PLUGIN.no_typing = true
PLUGIN.triggers = { PLUGIN.triggers = {
bot.first_name .. '%p?$', bot.first_name .. '%p?$',
'@' .. bot.username .. '%p?$', '@' .. bot.username .. '%p?$',