minor changes
This commit is contained in:
parent
cf8dc26d42
commit
4c6be5b899
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,3 +4,4 @@ console.lua
|
|||||||
*.json
|
*.json
|
||||||
plugins/owm.lua
|
plugins/owm.lua
|
||||||
plugins/liberblock.lua
|
plugins/liberblock.lua
|
||||||
|
plugins/dgmp.lua
|
||||||
|
4
bot.lua
4
bot.lua
@ -15,7 +15,7 @@ function on_msg_receive(msg)
|
|||||||
|
|
||||||
msg = process_msg(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 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
|
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
|
counter[msg.from.id] = counter[msg.from.id] + 1
|
||||||
print(msg.from.first_name, msg.from.id, counter[msg.from.id])
|
print(msg.from.first_name, msg.from.id, counter[msg.from.id])
|
||||||
if v.typing then
|
if v.typing then
|
||||||
send_chat_action(msg.from.id, 'typing')
|
send_chat_action(msg.chat.id, 'typing')
|
||||||
end
|
end
|
||||||
local a,b = pcall(function() -- Janky error handling
|
local a,b = pcall(function() -- Janky error handling
|
||||||
v.action(msg)
|
v.action(msg)
|
||||||
|
92
plugins/dgmp.lua
Executable file
92
plugins/dgmp.lua
Executable file
@ -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
|
||||||
|
}
|
@ -21,7 +21,7 @@ function PLUGIN.action(msg)
|
|||||||
end
|
end
|
||||||
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 jstr, res = HTTP.request(url)
|
||||||
local jdat = JSON.decode(jstr)
|
local jdat = JSON.decode(jstr)
|
||||||
|
|
||||||
|
@ -7,7 +7,8 @@ PLUGIN.doc = [[
|
|||||||
]]
|
]]
|
||||||
|
|
||||||
PLUGIN.triggers = {
|
PLUGIN.triggers = {
|
||||||
'^/pun'
|
'^/pun$',
|
||||||
|
'^/pun@'
|
||||||
}
|
}
|
||||||
|
|
||||||
PLUGIN.puns = {
|
PLUGIN.puns = {
|
||||||
|
@ -8,7 +8,8 @@ local triggers = {
|
|||||||
['( ͡° ͜ʖ ͡°)'] = '/lenny$',
|
['( ͡° ͜ʖ ͡°)'] = '/lenny$',
|
||||||
['(╯°□°)╯︵ ┻━┻'] = '/flip$',
|
['(╯°□°)╯︵ ┻━┻'] = '/flip$',
|
||||||
['┌(┌ ^o^)┐'] = '/homo$',
|
['┌(┌ ^o^)┐'] = '/homo$',
|
||||||
['ಠ_ಠ'] = '/look$'
|
['ಠ_ಠ'] = '/look$',
|
||||||
|
['SHOTS FIRED'] = '/shot$'
|
||||||
}
|
}
|
||||||
|
|
||||||
local action = function(msg)
|
local action = function(msg)
|
||||||
|
@ -45,7 +45,7 @@ function PLUGIN.getSlap(slapper, victim)
|
|||||||
victim .. " was fragged by " .. slapper .. ".",
|
victim .. " was fragged by " .. slapper .. ".",
|
||||||
victim .. " was desynchronized.",
|
victim .. " was desynchronized.",
|
||||||
victim .. " was wasted.",
|
victim .. " was wasted.",
|
||||||
victim .. " was busted by " .. slapper .. ".",
|
victim .. " was busted.",
|
||||||
victim .. "'s bones are scraped clean by the desolate wind.",
|
victim .. "'s bones are scraped clean by the desolate wind.",
|
||||||
victim .. " has died of dysentery.",
|
victim .. " has died of dysentery.",
|
||||||
victim .. " fainted.",
|
victim .. " fainted.",
|
||||||
|
Reference in New Issue
Block a user