Improved triggers for many plugins.
Redone README to match the website. Bot now supports deep linking / start payloads. lastfm.lua now notifies a user when his default username is saved. antisquig is now part of moderation.lua.
This commit is contained in:
@@ -1,49 +0,0 @@
|
||||
-- An extension to moderation.lua. This plugin is useless without it.
|
||||
-- Put this at the very top of your plugin list, even before blacklist.lua.
|
||||
|
||||
-- Developed by the incredible JuanPotato, creator of the Python CLI bot Botato.
|
||||
|
||||
antisquig = {}
|
||||
|
||||
local triggers = {
|
||||
'[\216-\219][\128-\191]'
|
||||
}
|
||||
|
||||
local action = function(msg)
|
||||
|
||||
local moddat = load_data('moderation.json')
|
||||
|
||||
if not moddat[msg.chat.id_str] then
|
||||
return true
|
||||
end
|
||||
|
||||
if moddat[msg.chat.id_str][msg.from.id_str] or config.moderation.admins[msg.from.id_str] then
|
||||
return true
|
||||
end
|
||||
|
||||
if antisquig[msg.from.id] == true then
|
||||
return
|
||||
end
|
||||
antisquig[msg.from.id] = true
|
||||
|
||||
sendReply(msg, config.errors.antisquig)
|
||||
sendMessage(config.moderation.admin_group, '/kick ' .. msg.from.id .. ' from ' .. math.abs(msg.chat.id))
|
||||
sendMessage(config.moderation.admin_group, 'ANTISQUIG: ' .. msg.from.first_name .. ' kicked from ' .. msg.chat.title .. '.')
|
||||
|
||||
end
|
||||
|
||||
-- When a user is kicked for squigglies, his ID is added to this table.
|
||||
-- That user will not be kicked again as long as his ID is in the table.
|
||||
-- The table is emptied every five seconds.
|
||||
-- Thus the bot will not spam the group or admin group when a user posts more than one infringing messages.
|
||||
local cron = function()
|
||||
|
||||
antisquig = {}
|
||||
|
||||
end
|
||||
|
||||
return {
|
||||
action = action,
|
||||
triggers = triggers,
|
||||
cron = cron
|
||||
}
|
||||
@@ -10,8 +10,9 @@ local doc = [[
|
||||
]]
|
||||
|
||||
local triggers = {
|
||||
'^/b[ible]*[@'..bot.username..']*$',
|
||||
'^/b[ible]*[@'..bot.username..']* '
|
||||
'^/bible*[@'..bot.username..']*',
|
||||
'^/b[@'..bot.username..']* ',
|
||||
'^/b[@'..bot.username..']*$'
|
||||
}
|
||||
|
||||
local action = function(msg)
|
||||
|
||||
@@ -47,7 +47,7 @@ local action = function(msg)
|
||||
|
||||
local message
|
||||
|
||||
if msg.text_lower:match('y/n%p?$') then
|
||||
if msg.text:lower():match('y/n%p?$') then
|
||||
message = yesno_answers[math.random(#yesno_answers)]
|
||||
else
|
||||
message = ball_answers[math.random(#ball_answers)]
|
||||
|
||||
@@ -17,8 +17,10 @@ local doc = [[
|
||||
]]
|
||||
|
||||
local triggers = {
|
||||
'^/i[mage]*[nsfw]*[@'..bot.username..']*$',
|
||||
'^/i[mage]*[nsfw]*[@'..bot.username..']* '
|
||||
'^/image[@'..bot.username..']*',
|
||||
'^/i[@'..bot.username..']* ',
|
||||
'^/i[@'..bot.username..']*$',
|
||||
'^/insfw[@'..bot.username..']*'
|
||||
}
|
||||
|
||||
local action = function(msg)
|
||||
|
||||
@@ -4,8 +4,9 @@ local doc = [[
|
||||
]]
|
||||
|
||||
triggers = {
|
||||
'^/loc[ation]*[@'..bot.username..']*$',
|
||||
'^/loc[ation]*[@'..bot.username..']* '
|
||||
'^/location[@'..bot.username..']*',
|
||||
'^/loc[@'..bot.username..']* ',
|
||||
'^/loc[@'..bot.username..']*$'
|
||||
}
|
||||
|
||||
local action = function(msg)
|
||||
|
||||
@@ -4,8 +4,10 @@ local doc = [[
|
||||
]]
|
||||
|
||||
local triggers = {
|
||||
'^/g[oogle]*[nsfw]*[@'..bot.username..']*$',
|
||||
'^/g[oogle]*[nsfw]*[@'..bot.username..']* '
|
||||
'^/g[@'..bot.username..']*$',
|
||||
'^/g[@'..bot.username..']* ',
|
||||
'^/google[@'..bot.username..']*',
|
||||
'^/gnsfw[@'..bot.username..']*'
|
||||
}
|
||||
|
||||
local action = function(msg)
|
||||
|
||||
@@ -25,7 +25,9 @@ local doc = [[
|
||||
]]
|
||||
|
||||
local triggers = {
|
||||
'^/h[earth]*s[tone]*[@'..bot.username..']*'
|
||||
'^/hearthstone[@'..bot.username..']*',
|
||||
'^/hs[@'..bot.username..']*$',
|
||||
'^/hs[@'..bot.username..']* '
|
||||
}
|
||||
|
||||
local format_card = function(card)
|
||||
|
||||
@@ -13,7 +13,8 @@ end
|
||||
local help_text = help_text .. 'Arguments: <required> [optional]'
|
||||
|
||||
local triggers = {
|
||||
'^/h[elp]*[@'..bot.username..']*$',
|
||||
'^/help[@'..bot.username..']*',
|
||||
'^/h[@'..bot.username..']*$',
|
||||
'^/start[@'..bot.username..']*'
|
||||
}
|
||||
|
||||
|
||||
@@ -43,12 +43,16 @@ local action = function(msg)
|
||||
local url = 'http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&format=json&limit=1&api_key=' .. config.lastfm_api_key .. '&user='
|
||||
|
||||
local username
|
||||
local output = ''
|
||||
if input then
|
||||
username = input
|
||||
elseif lastfm[msg.from.id_str] then
|
||||
username = lastfm[msg.from.id_str]
|
||||
elseif msg.from.username then
|
||||
username = msg.from.username
|
||||
output = '\n\nYour username has been set to ' .. username .. '.\nTo change it, use /fmset <username>.'
|
||||
lastfm[msg.from.id_str] = username
|
||||
save_data('lastfm.json', lastfm)
|
||||
else
|
||||
sendReply(msg, 'Please specify your last.fm username or set it with /fmset.')
|
||||
return
|
||||
@@ -64,13 +68,13 @@ local action = function(msg)
|
||||
|
||||
local jdat = JSON.decode(jstr)
|
||||
if jdat.error then
|
||||
sendReply(msg, jdat.error)
|
||||
sendReply(msg, config.errors.results)
|
||||
return
|
||||
end
|
||||
|
||||
local jdat = jdat.recenttracks.track[1] or jdat.recenttracks.track
|
||||
if not jdat then
|
||||
sendReply(msg, 'No history for this user.')
|
||||
sendReply(msg, 'No history for this user.' .. output)
|
||||
return
|
||||
end
|
||||
|
||||
@@ -89,7 +93,7 @@ local action = function(msg)
|
||||
artist = jdat.artist['#text']
|
||||
end
|
||||
|
||||
message = message .. title .. ' - ' .. artist
|
||||
message = message .. title .. ' - ' .. artist .. output
|
||||
sendMessage(msg.chat.id, message)
|
||||
|
||||
end
|
||||
|
||||
@@ -3,24 +3,13 @@
|
||||
-- Put this near the top, after blacklist.
|
||||
-- If you want to enable antisquig, put that at the top, before blacklist.
|
||||
|
||||
local triggers = {
|
||||
'^/modhelp[@'..bot.username..']*$',
|
||||
'^/modlist[@'..bot.username..']*$',
|
||||
'^/modcast[@'..bot.username..']*',
|
||||
'^/modadd[@'..bot.username..']*$',
|
||||
'^/modrem[@'..bot.username..']*$',
|
||||
'^/modprom[@'..bot.username..']*$',
|
||||
'^/moddem[@'..bot.username..']*',
|
||||
'^/modkick[@'..bot.username..']*',
|
||||
'^/modban[@'..bot.username..']*',
|
||||
}
|
||||
moddat = load_data('moderation.json')
|
||||
antisquig = {}
|
||||
|
||||
local commands = {
|
||||
|
||||
['^/modhelp[@'..bot.username..']*$'] = function(msg)
|
||||
|
||||
local moddat = load_data('moderation.json')
|
||||
|
||||
if not moddat[msg.chat.id_str] then
|
||||
return config.errors.moderation
|
||||
end
|
||||
@@ -31,10 +20,10 @@ local commands = {
|
||||
/modkick - Kick a user from this group.
|
||||
/modban - Ban a user from this group.
|
||||
Administrator commands:
|
||||
/add - Add this group to the moderation system.
|
||||
/remove - Remove this group from the moderation system.
|
||||
/promote - Promote a user to a moderator.
|
||||
/demote - Demote a moderator to a user.
|
||||
/modadd - Add this group to the moderation system.
|
||||
/modrem - Remove this group from the moderation system.
|
||||
/modprom - Promote a user to a moderator.
|
||||
/moddem - Demote a moderator to a user.
|
||||
/modcast - Send a broadcast to every moderated group.
|
||||
]]
|
||||
|
||||
@@ -44,8 +33,6 @@ local commands = {
|
||||
|
||||
['^/modlist[@'..bot.username..']*$'] = function(msg)
|
||||
|
||||
local moddat = load_data('moderation.json')
|
||||
|
||||
if not moddat[msg.chat.id_str] then
|
||||
return config.errors.moderation
|
||||
end
|
||||
@@ -84,8 +71,6 @@ local commands = {
|
||||
return config.errors.not_admin
|
||||
end
|
||||
|
||||
local moddat = load_data('moderation.json')
|
||||
|
||||
for k,v in pairs(moddat) do
|
||||
sendMessage(k, message)
|
||||
end
|
||||
@@ -100,8 +85,6 @@ local commands = {
|
||||
return config.errors.not_admin
|
||||
end
|
||||
|
||||
local moddat = load_data('moderation.json')
|
||||
|
||||
if moddat[msg.chat.id_str] then
|
||||
return 'I am already moderating this group.'
|
||||
end
|
||||
@@ -118,8 +101,6 @@ local commands = {
|
||||
return config.errors.not_admin
|
||||
end
|
||||
|
||||
local moddat = load_data('moderation.json')
|
||||
|
||||
if not moddat[msg.chat.id_str] then
|
||||
return config.errors.moderation
|
||||
end
|
||||
@@ -132,8 +113,6 @@ local commands = {
|
||||
|
||||
['^/modprom[@'..bot.username..']*$'] = function(msg)
|
||||
|
||||
local moddat = load_data('moderation.json')
|
||||
|
||||
if not moddat[msg.chat.id_str] then
|
||||
return config.errors.moderation
|
||||
end
|
||||
@@ -166,8 +145,6 @@ local commands = {
|
||||
|
||||
['^/moddem[@'..bot.username..']*'] = function(msg)
|
||||
|
||||
local moddat = load_data('moderation.json')
|
||||
|
||||
if not moddat[msg.chat.id_str] then
|
||||
return config.errors.moderation
|
||||
end
|
||||
@@ -204,8 +181,6 @@ local commands = {
|
||||
|
||||
['/modkick[@'..bot.username..']*'] = function(msg)
|
||||
|
||||
local moddat = load_data('moderation.json')
|
||||
|
||||
if not moddat[msg.chat.id_str] then
|
||||
return config.errors.moderation
|
||||
end
|
||||
@@ -240,8 +215,6 @@ local commands = {
|
||||
|
||||
['^/modban[@'..bot.username..']*'] = function(msg)
|
||||
|
||||
local moddat = load_data('moderation.json')
|
||||
|
||||
if not moddat[msg.chat.id_str] then
|
||||
return config.errors.moderation
|
||||
end
|
||||
@@ -276,21 +249,61 @@ local commands = {
|
||||
|
||||
}
|
||||
|
||||
if config.antisquig then
|
||||
commands['[\216-\219][\128-\191]'] = function(msg)
|
||||
|
||||
if not moddat[msg.chat.id_str] then return true end
|
||||
if config.moderation.admins[msg.from.id_str] then return true end
|
||||
if moddat[msg.chat.id_str][msg.from.id_str] then return true end
|
||||
|
||||
if antisquig[msg.from.id] == true then
|
||||
return
|
||||
end
|
||||
antisquig[msg.from.id] = true
|
||||
|
||||
sendReply(msg, config.errors.antisquig)
|
||||
sendMessage(config.moderation.admin_group, '/kick ' .. msg.from.id .. ' from ' .. math.abs(msg.chat.id))
|
||||
sendMessage(config.moderation.admin_group, 'ANTISQUIG: ' .. msg.from.first_name .. ' kicked from ' .. msg.chat.title .. '.')
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
local triggers = {}
|
||||
for k,v in pairs(commands) do
|
||||
table.insert(triggers, k)
|
||||
end
|
||||
|
||||
local action = function(msg)
|
||||
|
||||
for k,v in pairs(commands) do
|
||||
if string.match(msg.text_lower, k) then
|
||||
local output = v(msg)
|
||||
if output then
|
||||
if output == true then
|
||||
return true
|
||||
elseif output then
|
||||
sendReply(msg, output)
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
|
||||
end
|
||||
|
||||
-- When a user is kicked for squigglies, his ID is added to this table.
|
||||
-- That user will not be kicked again as long as his ID is in the table.
|
||||
-- The table is emptied every five seconds.
|
||||
-- Thus the bot will not spam the group or admin group when a user posts more than one infringing messages.
|
||||
local cron = function()
|
||||
|
||||
antisquig = {}
|
||||
|
||||
end
|
||||
|
||||
return {
|
||||
action = action,
|
||||
triggers = triggers
|
||||
triggers = triggers,
|
||||
cron = cron
|
||||
}
|
||||
|
||||
@@ -4,7 +4,8 @@ local doc = [[
|
||||
]]
|
||||
|
||||
local triggers = {
|
||||
'^/[poke]*dex[@'..bot.username..']*'
|
||||
'^/pokedex[@'..bot.username..']*',
|
||||
'^/dex[@'..bot.username..']*'
|
||||
}
|
||||
|
||||
local action = function(msg)
|
||||
|
||||
@@ -9,13 +9,13 @@ local triggers = {
|
||||
['(╯°□°)╯︵ ┻━┻'] = '/flip$',
|
||||
['┌(┌ ^o^)┐'] = '/homo$',
|
||||
['ಠ_ಠ'] = '/look$',
|
||||
['SHOTS FIRED'] = '/shot$'
|
||||
['SHOTS FIRED'] = '/shots?$'
|
||||
}
|
||||
|
||||
-- Generate a "help" message triggered by "/reactions".
|
||||
local help = ''
|
||||
for k,v in pairs(triggers) do
|
||||
help = help .. v:gsub('%$', ': ') .. k .. '\n'
|
||||
help = help .. v:gsub('%$', ': '):gsub('?', '') .. k .. '\n'
|
||||
end
|
||||
triggers[help] = '^/reactions$'
|
||||
|
||||
|
||||
@@ -4,8 +4,9 @@ local doc = [[
|
||||
]]
|
||||
|
||||
local triggers = {
|
||||
'^/r[eddit]*[@'..bot.username..']*$',
|
||||
'^/r[eddit]*[@'..bot.username..']* ',
|
||||
'^/reddit[@'..bot.username..']*',
|
||||
'^/r[@'..bot.username..']*$',
|
||||
'^/r[@'..bot.username..']* ',
|
||||
'^/r/'
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,9 @@ local doc = [[
|
||||
]]
|
||||
|
||||
local triggers = {
|
||||
'^/u[rban]*d[ictionary]*[@'..bot.username..']*',
|
||||
'^/urbandictionary[@'..bot.username..']*',
|
||||
'^/ud[@'..bot.username..']*$',
|
||||
'^/ud[@'..bot.username..']* ',
|
||||
'^/urban[@'..bot.username..']*'
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,10 @@ local doc = [[
|
||||
]]
|
||||
|
||||
local triggers = {
|
||||
'^/w[iki[pedia]*]*[@'..bot.username..']*$',
|
||||
'^/w[iki[pedia]*]*[@'..bot.username..']* '
|
||||
'^/wikipedia[@'..bot.username..']*',
|
||||
'^/wiki[@'..bot.username..']*',
|
||||
'^/w[@'..bot.username..']*$',
|
||||
'^/w[@'..bot.username..']* '
|
||||
}
|
||||
|
||||
local action = function(msg)
|
||||
|
||||
@@ -6,7 +6,9 @@ local doc = [[
|
||||
]]
|
||||
|
||||
local triggers = {
|
||||
'^/y[ou]*t[ube]*[@'..bot.username..']*'
|
||||
'^/youtube[@'..bot.username..']*',
|
||||
'^/yt[@'..bot.username..']*$',
|
||||
'^/yt[@'..bot.username..']* '
|
||||
}
|
||||
|
||||
local action = function(msg)
|
||||
|
||||
Reference in New Issue
Block a user