diff --git a/.gitignore b/.gitignore index 60fc9aa..e72bf0f 100755 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ console.lua *.json plugins/owm.lua plugins/liberblock.lua +plugins/dgmp.lua diff --git a/bot.lua b/bot.lua index e45f691..2fa5e8e 100755 --- a/bot.lua +++ b/bot.lua @@ -15,7 +15,7 @@ function on_msg_receive(msg) msg = process_msg(msg) - if msg.date < os.time() - 5 then return end -- don't react to old messages + if msg.date < os.time() - 10 then return end -- don't react to old messages if not msg.text then return end -- don't react to media messages if msg.forward_from then return end -- don't react to forwarded messages @@ -27,7 +27,7 @@ function on_msg_receive(msg) counter[msg.from.id] = counter[msg.from.id] + 1 print(msg.from.first_name, msg.from.id, counter[msg.from.id]) if v.typing then - send_chat_action(msg.from.id, 'typing') + send_chat_action(msg.chat.id, 'typing') end local a,b = pcall(function() -- Janky error handling v.action(msg) diff --git a/plugins/dgmp.lua b/plugins/dgmp.lua new file mode 100755 index 0000000..99d83c4 --- /dev/null +++ b/plugins/dgmp.lua @@ -0,0 +1,92 @@ +local triggers = { + '^/index', + '^/listgroups' +} + +local dgmp_index = function(msg) + + local dgmp = load_data('dgmp.json') + + local input = get_input(msg.text) + if not input then return end + + input = JSON.decode(input) + if not input then return end + + local id = tostring(input.chatid) + + if not dgmp[id] then + dgmp[id] = {} + end + group = dgmp[id] + + group.chatname = input.chatname + if input.usercount then + group.usercount = input.usercount + end + if input.description then + group.description = input.description + end + if input.joininstructions then + group.joininstructions = input.joininstructions + end + + save_data('dgmp.json', dgmp) + +end + +local dgmp_list = function(msg) + + local dgmp = load_data('dgmp.json') + + local input = get_input(msg.text) + if not input then + input = '' + else + input = string.lower(input) + end + + local output = '' + for k,v in pairs(dgmp) do + if string.find(string.lower(v.chatname), input) then + output = output .. v.chatname .. ' (' .. k .. ')\n' + if v.description then + output = output .. v.description .. '\n' + end + if v.usercount then + output = output .. 'Users: ' .. v.usercount .. '\n' + end + if v.joininstructions then + output = output .. 'How to join: ' .. v.joininstructions .. '\n' + end + output = output .. '\n' + end + end + + if string.len(output) > 4000 then + output = 'List is too long! Please use a (better) search query.' + end + + output = trim_string(output) + if string.len(output) == 0 then + output = 'No results found.' + end + + send_msg(msg, output) + +end + +local action = function(msg) + + if string.match(msg.text, '^/index') then + dgmp_index(msg) + elseif string.match(msg.text, '^/listgroups') then + dgmp_list(msg) + end + +end + +return { + triggers = triggers, + action = action +} diff --git a/plugins/imdb.lua b/plugins/imdb.lua index f593bcd..0f2cab3 100755 --- a/plugins/imdb.lua +++ b/plugins/imdb.lua @@ -21,7 +21,7 @@ function PLUGIN.action(msg) end end - local url = 'http://www.imdbapi.com/?t=' .. URL.escape(input) + local url = 'http://www.omdbapi.com/?t=' .. URL.escape(input) local jstr, res = HTTP.request(url) local jdat = JSON.decode(jstr) diff --git a/plugins/pun.lua b/plugins/pun.lua index 0741f46..030603e 100755 --- a/plugins/pun.lua +++ b/plugins/pun.lua @@ -7,7 +7,8 @@ PLUGIN.doc = [[ ]] PLUGIN.triggers = { - '^/pun' + '^/pun$', + '^/pun@' } PLUGIN.puns = { diff --git a/plugins/reaction.lua b/plugins/reaction.lua index 4c04451..34808e9 100755 --- a/plugins/reaction.lua +++ b/plugins/reaction.lua @@ -8,7 +8,8 @@ local triggers = { ['( ͡° ͜ʖ ͡°)'] = '/lenny$', ['(╯°□°)╯︵ ┻━┻'] = '/flip$', ['┌(┌ ^o^)┐'] = '/homo$', - ['ಠ_ಠ'] = '/look$' + ['ಠ_ಠ'] = '/look$', + ['SHOTS FIRED'] = '/shot$' } local action = function(msg) diff --git a/plugins/slap.lua b/plugins/slap.lua index e2aa2a6..a618878 100755 --- a/plugins/slap.lua +++ b/plugins/slap.lua @@ -45,7 +45,7 @@ function PLUGIN.getSlap(slapper, victim) victim .. " was fragged by " .. slapper .. ".", victim .. " was desynchronized.", victim .. " was wasted.", - victim .. " was busted by " .. slapper .. ".", + victim .. " was busted.", victim .. "'s bones are scraped clean by the desolate wind.", victim .. " has died of dysentery.", victim .. " fainted.",