address #75
This commit is contained in:
@ -50,17 +50,7 @@ function administration:init(config)
|
||||
|
||||
administration.flags = administration.init_flags(config.cmd_pat)
|
||||
administration.init_command(self, config)
|
||||
administration.antiflood = config.administration.antiflood or {
|
||||
text = 5,
|
||||
voice = 5,
|
||||
audio = 5,
|
||||
contact = 5,
|
||||
photo = 10,
|
||||
video = 10,
|
||||
location = 10,
|
||||
document = 10,
|
||||
sticker = 20
|
||||
}
|
||||
administration.antiflood = config.administration.antiflood
|
||||
|
||||
administration.doc = 'Returns a list of administrated groups.\nUse '..config.cmd_pat..'ahelp for more administrative commands.'
|
||||
administration.command = 'groups [query]'
|
||||
|
@ -34,7 +34,7 @@ function bible:action(msg, config)
|
||||
output, res = HTTP.request(url)
|
||||
end
|
||||
|
||||
if not output or res ~= 200 or output:len() == 0 then
|
||||
if not output or res ~= 200 or output:len() == 0 then
|
||||
output = config.errors.results
|
||||
end
|
||||
|
||||
|
40
otouto/plugins/druasay.lua
Normal file
40
otouto/plugins/druasay.lua
Normal file
@ -0,0 +1,40 @@
|
||||
--[[
|
||||
This plugin causes the bot to respond to certain triggers over the owner's
|
||||
account, via drua-tg.
|
||||
It's basically the greetings plugin with drua instead of bot output.
|
||||
It will also uppercase the output if the input is entirely uppercase.
|
||||
]]
|
||||
|
||||
local drua = require('otouto.drua-tg')
|
||||
|
||||
local druasay = {}
|
||||
|
||||
function druasay:init(config)
|
||||
druasay.triggers = {}
|
||||
for _, triggers in pairs(config.druasay) do
|
||||
for i = 1, #triggers do
|
||||
table.insert(druasay.triggers, triggers[i])
|
||||
end
|
||||
end
|
||||
druasay.error = false
|
||||
end
|
||||
|
||||
function druasay:action(msg, config)
|
||||
if msg.from.id == config.admin or msg.chat.type == 'private' then return end
|
||||
for response, triggers in pairs(config.druasay) do
|
||||
for _, trigger in ipairs(triggers) do
|
||||
if msg.text_lower:match(trigger) then
|
||||
local output
|
||||
if msg.text == msg.text:upper() then
|
||||
output = response:upper()
|
||||
else
|
||||
output = response
|
||||
end
|
||||
drua.message(msg.chat.id, output)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return druasay
|
@ -41,7 +41,7 @@ function me:action(msg, config)
|
||||
local data = {}
|
||||
for k,v in pairs(userdata) do
|
||||
table.insert(data, string.format(
|
||||
'<b>%s</b> <code>%s</code>\n',
|
||||
'<b>%s:</b> <code>%s</code>\n',
|
||||
utilities.html_escape(k),
|
||||
utilities.html_escape(v)
|
||||
))
|
||||
|
@ -13,7 +13,7 @@ Example (forty pidgeys and three hundred pidgey candies):
|
||||
end
|
||||
|
||||
-- This function written by Juan Potato. MIT-licensed.
|
||||
local pidgey_calc = function(candies_to_evolve, mons, candies)
|
||||
local function pidgey_calc(candies_to_evolve, mons, candies)
|
||||
local transferred = 0;
|
||||
local evolved = 0;
|
||||
|
||||
@ -52,7 +52,7 @@ local pidgey_calc = function(candies_to_evolve, mons, candies)
|
||||
}
|
||||
end
|
||||
|
||||
local single_job = function(input)
|
||||
local function single_job(input)
|
||||
local req_candy, mons, candies = input:match('^(%d+) (%d+) (%d+)$')
|
||||
req_candy = tonumber(req_candy)
|
||||
mons = tonumber(mons)
|
||||
|
@ -6,79 +6,79 @@ local utilities = require('otouto.utilities')
|
||||
pokemon_go.command = 'pokego <team>'
|
||||
|
||||
function pokemon_go:init(config)
|
||||
pokemon_go.triggers = utilities.triggers(self.info.username, config.cmd_pat)
|
||||
:t('pokego', true):t('pokégo', true)
|
||||
:t('pokemongo', true):t('pokémongo', true)
|
||||
:t('pogo', true):t('mongo', true).table
|
||||
pokemon_go.doc = config.cmd_pat .. [[pokego <team>
|
||||
pokemon_go.triggers = utilities.triggers(self.info.username, config.cmd_pat)
|
||||
:t('pokego', true):t('pokégo', true)
|
||||
:t('pokemongo', true):t('pokémongo', true)
|
||||
:t('pogo', true):t('mongo', true).table
|
||||
pokemon_go.doc = config.cmd_pat .. [[pokego <team>
|
||||
Set your Pokémon Go team for statistical purposes. The team must be valid, and can be referred to by name or color (or the first letter of either). Giving no team name will show statistics.]]
|
||||
local db = self.database.pokemon_go
|
||||
if not db then
|
||||
self.database.pokemon_go = {}
|
||||
db = self.database.pokemon_go
|
||||
end
|
||||
if not db.membership then
|
||||
db.membership = {}
|
||||
end
|
||||
for _, set in pairs(db.membership) do
|
||||
setmetatable(set, utilities.set_meta)
|
||||
end
|
||||
local db = self.database.pokemon_go
|
||||
if not db then
|
||||
self.database.pokemon_go = {}
|
||||
db = self.database.pokemon_go
|
||||
end
|
||||
if not db.membership then
|
||||
db.membership = {}
|
||||
end
|
||||
for _, set in pairs(db.membership) do
|
||||
setmetatable(set, utilities.set_meta)
|
||||
end
|
||||
end
|
||||
|
||||
local team_ref = {
|
||||
mystic = "Mystic",
|
||||
m = "Mystic",
|
||||
valor = "Valor",
|
||||
v = "Valor",
|
||||
instinct = "Instinct",
|
||||
i = "Instinct",
|
||||
blue = "Mystic",
|
||||
b = "Mystic",
|
||||
red = "Valor",
|
||||
r = "Valor",
|
||||
yellow = "Instinct",
|
||||
y = "Instinct"
|
||||
mystic = "Mystic",
|
||||
m = "Mystic",
|
||||
valor = "Valor",
|
||||
v = "Valor",
|
||||
instinct = "Instinct",
|
||||
i = "Instinct",
|
||||
blue = "Mystic",
|
||||
b = "Mystic",
|
||||
red = "Valor",
|
||||
r = "Valor",
|
||||
yellow = "Instinct",
|
||||
y = "Instinct"
|
||||
}
|
||||
|
||||
function pokemon_go:action(msg, config)
|
||||
local output
|
||||
local input = utilities.input(msg.text_lower)
|
||||
local output
|
||||
local input = utilities.input(msg.text_lower)
|
||||
|
||||
if input then
|
||||
local team = team_ref[input]
|
||||
if not team then
|
||||
output = 'Invalid team.'
|
||||
else
|
||||
local id_str = tostring(msg.from.id)
|
||||
local db = self.database.pokemon_go
|
||||
local db_membership = db.membership
|
||||
if not db_membership[team] then
|
||||
db_membership[team] = utilities.new_set()
|
||||
end
|
||||
|
||||
for t, set in pairs(db_membership) do
|
||||
if t ~= team then
|
||||
set:remove(id_str)
|
||||
if input then
|
||||
local team = team_ref[input]
|
||||
if not team then
|
||||
output = 'Invalid team.'
|
||||
else
|
||||
set:add(id_str)
|
||||
local id_str = tostring(msg.from.id)
|
||||
local db = self.database.pokemon_go
|
||||
local db_membership = db.membership
|
||||
if not db_membership[team] then
|
||||
db_membership[team] = utilities.new_set()
|
||||
end
|
||||
|
||||
for t, set in pairs(db_membership) do
|
||||
if t ~= team then
|
||||
set:remove(id_str)
|
||||
else
|
||||
set:add(id_str)
|
||||
end
|
||||
end
|
||||
|
||||
output = 'Your team is now '..team..'.'
|
||||
end
|
||||
end
|
||||
else
|
||||
local db = self.database.pokemon_go
|
||||
local db_membership = db.membership
|
||||
|
||||
output = 'Your team is now '..team..'.'
|
||||
end
|
||||
else
|
||||
local db = self.database.pokemon_go
|
||||
local db_membership = db.membership
|
||||
local output_temp = {'Membership:'}
|
||||
for t, set in pairs(db_membership) do
|
||||
table.insert(output_temp, t..': '..#set)
|
||||
end
|
||||
|
||||
local output_temp = {'Membership:'}
|
||||
for t, set in pairs(db_membership) do
|
||||
table.insert(output_temp, t..': '..#set)
|
||||
output = table.concat(output_temp, '\n')
|
||||
end
|
||||
|
||||
output = table.concat(output_temp, '\n')
|
||||
end
|
||||
|
||||
utilities.send_reply(self, msg, output)
|
||||
utilities.send_reply(self, msg, output)
|
||||
end
|
||||
|
||||
return pokemon_go
|
||||
|
@ -67,7 +67,7 @@ local puns = {
|
||||
"I don't trust people with graph paper. They're always plotting something",
|
||||
"I had a friend who was addicted to brake fluid. He says he can stop anytime.",
|
||||
"The form said I had Type A blood, but it was a Type O.",
|
||||
"I went to to the shop to buy eight Sprites - I came home and realised I'd picked 7Up.",
|
||||
"I went to to the shop to buy eight Sprites - I came home and realised I'd picked 7Up.",
|
||||
"There was an explosion at a pie factory. 3.14 people died.",
|
||||
"A man drove his car into a tree and found out how a Mercedes bends.",
|
||||
"The experienced carpenter really nailed it, but the new guy screwed everything up.",
|
||||
|
@ -1,11 +1,3 @@
|
||||
-- Never change this plugin. It was not meant to be changed.
|
||||
-- You may add reactions. You must never remove reactions.
|
||||
-- You must never restructure. You must never disable this plugin.
|
||||
-- - Drew, creator, a year later.
|
||||
|
||||
-- Nevermind, Brayden changed it.
|
||||
-- - Drew, just now.
|
||||
|
||||
local reactions = {}
|
||||
|
||||
local utilities = require('otouto.utilities')
|
||||
@ -13,15 +5,13 @@ local utilities = require('otouto.utilities')
|
||||
reactions.command = 'reactions'
|
||||
reactions.doc = 'Returns a list of "reaction" emoticon commands.'
|
||||
|
||||
local help
|
||||
|
||||
function reactions:init(config)
|
||||
-- Generate a "help" message triggered by "/reactions".
|
||||
help = 'Reactions:\n'
|
||||
-- Generate a command list message triggered by "/reactions".
|
||||
reactions.help = 'Reactions:\n'
|
||||
reactions.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('reactions').table
|
||||
local username = self.info.username:lower()
|
||||
for trigger,reaction in pairs(config.reactions) do
|
||||
help = help .. '• ' .. config.cmd_pat .. trigger .. ': ' .. reaction .. '\n'
|
||||
for trigger, reaction in pairs(config.reactions) do
|
||||
reactions.help = reactions.help .. '• ' .. config.cmd_pat .. trigger .. ': ' .. reaction .. '\n'
|
||||
table.insert(reactions.triggers, '^'..config.cmd_pat..trigger)
|
||||
table.insert(reactions.triggers, '^'..config.cmd_pat..trigger..'@'..username)
|
||||
table.insert(reactions.triggers, config.cmd_pat..trigger..'$')
|
||||
@ -35,12 +25,12 @@ end
|
||||
|
||||
function reactions:action(msg, config)
|
||||
if string.match(msg.text_lower, config.cmd_pat..'reactions') then
|
||||
utilities.send_message(self, msg.chat.id, help)
|
||||
utilities.send_message(self, msg.chat.id, reactions.help, true, nil, 'html')
|
||||
return
|
||||
end
|
||||
for trigger,reaction in pairs(config.reactions) do
|
||||
if string.match(msg.text_lower, config.cmd_pat..trigger) then
|
||||
utilities.send_message(self, msg.chat.id, reaction)
|
||||
utilities.send_message(self, msg.chat.id, reaction, true, nil, 'html')
|
||||
return
|
||||
end
|
||||
end
|
||||
|
@ -14,7 +14,7 @@ Returns the top posts or results for a given subreddit or query. If no argument
|
||||
Aliases: ]] .. config.cmd_pat .. 'r, /r/subreddit'
|
||||
end
|
||||
|
||||
local format_results = function(posts)
|
||||
local function format_results(posts)
|
||||
local output = ''
|
||||
for _,v in ipairs(posts) do
|
||||
local post = v.data
|
||||
|
@ -9,9 +9,6 @@ function remind:init(config)
|
||||
|
||||
remind.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('remind', true).table
|
||||
|
||||
config.remind = config.remind or {}
|
||||
setmetatable(config.remind, { __index = function() return 1000 end })
|
||||
|
||||
remind.doc = config.cmd_pat .. [[remind <duration> <message>
|
||||
Repeats a message after a duration of time, in minutes.
|
||||
The maximum length of a reminder is %s characters. The maximum duration of a timer is %s minutes. The maximum number of reminders for a group is %s. The maximum number of reminders in private is %s.]]
|
||||
|
Reference in New Issue
Block a user