address #75
This commit is contained in:
parent
738b45cdbd
commit
f9094a73ca
9
.gitignore
vendored
9
.gitignore
vendored
@ -1,4 +1,5 @@
|
|||||||
otouto/plugins/mokubot*
|
# https://github.com/topkecleon/otouto-plugins-topkecleon
|
||||||
otouto/plugins/oubot*
|
otouto/plugins/mokubot.lua
|
||||||
*.db
|
otouto/plugins/oubot.lua
|
||||||
tg
|
otouto/plugins/qtbot.lua
|
||||||
|
otouto/plugins/weeabot.lua
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
--[[
|
--[[
|
||||||
drua-tg
|
drua-tg
|
||||||
Based on JuanPotato's lua-tg (https://github.com/juanpotato/lua-tg),
|
Based on JuanPotato's lua-tg (https://github.com/juanpotato/lua-tg),
|
||||||
modified to work more naturally from an API bot.
|
modified to work more naturally from an API bot.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
drua = require('drua-tg')
|
drua = require('drua-tg')
|
||||||
drua.IP = 'localhost' -- 'localhost' is default
|
drua.IP = 'localhost' -- 'localhost' is default
|
||||||
drua.PORT = 4567 -- 4567 is default
|
drua.PORT = 4567 -- 4567 is default
|
||||||
drua.message(chat_id, text)
|
drua.message(chat_id, text)
|
||||||
|
|
||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
@ -35,150 +35,150 @@ SOFTWARE.
|
|||||||
local SOCKET = require('socket')
|
local SOCKET = require('socket')
|
||||||
|
|
||||||
local comtab = {
|
local comtab = {
|
||||||
add = { 'chat_add_user %s %s', 'channel_invite %s %s' },
|
add = { 'chat_add_user %s %s', 'channel_invite %s %s' },
|
||||||
kick = { 'chat_del_user %s %s', 'channel_kick %s %s' },
|
kick = { 'chat_del_user %s %s', 'channel_kick %s %s' },
|
||||||
rename = { 'rename_chat %s "%s"', 'rename_channel %s "%s"' },
|
rename = { 'rename_chat %s "%s"', 'rename_channel %s "%s"' },
|
||||||
link = { 'export_chat_link %s', 'export_channel_link %s' },
|
link = { 'export_chat_link %s', 'export_channel_link %s' },
|
||||||
photo_set = { 'chat_set_photo %s %s', 'channel_set_photo %s %s' },
|
photo_set = { 'chat_set_photo %s %s', 'channel_set_photo %s %s' },
|
||||||
photo_get = { [0] = 'load_user_photo %s', 'load_chat_photo %s', 'load_channel_photo %s' },
|
photo_get = { [0] = 'load_user_photo %s', 'load_chat_photo %s', 'load_channel_photo %s' },
|
||||||
info = { [0] = 'user_info %s', 'chat_info %s', 'channel_info %s' }
|
info = { [0] = 'user_info %s', 'chat_info %s', 'channel_info %s' }
|
||||||
}
|
}
|
||||||
|
|
||||||
local format_target = function(target)
|
local function format_target(target)
|
||||||
target = tonumber(target)
|
target = tonumber(target)
|
||||||
if target < -1000000000000 then
|
if target < -1000000000000 then
|
||||||
target = 'channel#' .. math.abs(target) - 1000000000000
|
target = 'channel#' .. math.abs(target) - 1000000000000
|
||||||
return target, 2
|
return target, 2
|
||||||
elseif target < 0 then
|
elseif target < 0 then
|
||||||
target = 'chat#' .. math.abs(target)
|
target = 'chat#' .. math.abs(target)
|
||||||
return target, 1
|
return target, 1
|
||||||
else
|
else
|
||||||
target = 'user#' .. target
|
target = 'user#' .. target
|
||||||
return target, 0
|
return target, 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local escape = function(text)
|
local function escape(text)
|
||||||
text = text:gsub('\\', '\\\\')
|
text = text:gsub('\\', '\\\\')
|
||||||
text = text:gsub('\n', '\\n')
|
text = text:gsub('\n', '\\n')
|
||||||
text = text:gsub('\t', '\\t')
|
text = text:gsub('\t', '\\t')
|
||||||
text = text:gsub('"', '\\"')
|
text = text:gsub('"', '\\"')
|
||||||
return text
|
return text
|
||||||
end
|
end
|
||||||
|
|
||||||
local drua = {
|
local drua = {
|
||||||
IP = 'localhost',
|
IP = 'localhost',
|
||||||
PORT = 4567
|
PORT = 4567
|
||||||
}
|
}
|
||||||
|
|
||||||
drua.send = function(command, do_receive)
|
function drua.send(command, do_receive)
|
||||||
local s = SOCKET.connect(drua.IP, drua.PORT)
|
local s = SOCKET.connect(drua.IP, drua.PORT)
|
||||||
assert(s, '\nUnable to connect to tg session.')
|
assert(s, '\nUnable to connect to tg session.')
|
||||||
s:send(command..'\n')
|
s:send(command..'\n')
|
||||||
local output
|
local output
|
||||||
if do_receive then
|
if do_receive then
|
||||||
output = string.match(s:receive('*l'), 'ANSWER (%d+)')
|
output = string.match(s:receive('*l'), 'ANSWER (%d+)')
|
||||||
output = s:receive(tonumber(output)):gsub('\n$', '')
|
output = s:receive(tonumber(output)):gsub('\n$', '')
|
||||||
end
|
end
|
||||||
s:close()
|
s:close()
|
||||||
return output
|
return output
|
||||||
end
|
end
|
||||||
|
|
||||||
drua.message = function(target, text)
|
function drua.message(target, text)
|
||||||
target = format_target(target)
|
target = format_target(target)
|
||||||
text = escape(text)
|
text = escape(text)
|
||||||
local command = 'msg %s "%s"'
|
local command = 'msg %s "%s"'
|
||||||
command = command:format(target, text)
|
command = command:format(target, text)
|
||||||
return drua.send(command)
|
return drua.send(command)
|
||||||
end
|
end
|
||||||
|
|
||||||
drua.send_photo = function(target, photo)
|
function drua.send_photo(target, photo)
|
||||||
target = format_target(target)
|
target = format_target(target)
|
||||||
local command = 'send_photo %s %s'
|
local command = 'send_photo %s %s'
|
||||||
command = command:format(target, photo)
|
command = command:format(target, photo)
|
||||||
return drua.send(command)
|
return drua.send(command)
|
||||||
end
|
end
|
||||||
|
|
||||||
drua.add_user = function(chat, target)
|
function drua.add_user(chat, target)
|
||||||
local a
|
local a
|
||||||
chat, a = format_target(chat)
|
chat, a = format_target(chat)
|
||||||
target = format_target(target)
|
target = format_target(target)
|
||||||
local command = comtab.add[a]:format(chat, target)
|
local command = comtab.add[a]:format(chat, target)
|
||||||
return drua.send(command)
|
return drua.send(command)
|
||||||
end
|
end
|
||||||
|
|
||||||
drua.kick_user = function(chat, target)
|
function drua.kick_user(chat, target)
|
||||||
-- Get the group info so tg will recognize the target.
|
-- Get the group info so tg will recognize the target.
|
||||||
drua.get_info(chat)
|
drua.get_info(chat)
|
||||||
local a
|
local a
|
||||||
chat, a = format_target(chat)
|
chat, a = format_target(chat)
|
||||||
target = format_target(target)
|
target = format_target(target)
|
||||||
local command = comtab.kick[a]:format(chat, target)
|
local command = comtab.kick[a]:format(chat, target)
|
||||||
return drua.send(command)
|
return drua.send(command)
|
||||||
end
|
end
|
||||||
|
|
||||||
drua.rename_chat = function(chat, name)
|
function drua.rename_chat(chat, name)
|
||||||
local a
|
local a
|
||||||
chat, a = format_target(chat)
|
chat, a = format_target(chat)
|
||||||
local command = comtab.rename[a]:format(chat, name)
|
local command = comtab.rename[a]:format(chat, name)
|
||||||
return drua.send(command)
|
return drua.send(command)
|
||||||
end
|
end
|
||||||
|
|
||||||
drua.export_link = function(chat)
|
function drua.export_link(chat)
|
||||||
local a
|
local a
|
||||||
chat, a = format_target(chat)
|
chat, a = format_target(chat)
|
||||||
local command = comtab.link[a]:format(chat)
|
local command = comtab.link[a]:format(chat)
|
||||||
return drua.send(command, true)
|
return drua.send(command, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
drua.get_photo = function(chat)
|
function drua.get_photo(chat)
|
||||||
local a
|
local a
|
||||||
chat, a = format_target(chat)
|
chat, a = format_target(chat)
|
||||||
local command = comtab.photo_get[a]:format(chat)
|
local command = comtab.photo_get[a]:format(chat)
|
||||||
local output = drua.send(command, true)
|
local output = drua.send(command, true)
|
||||||
if output:match('FAIL') then
|
if output:match('FAIL') then
|
||||||
return false
|
return false
|
||||||
else
|
else
|
||||||
return output:match('Saved to (.+)')
|
return output:match('Saved to (.+)')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
drua.set_photo = function(chat, photo)
|
function drua.set_photo(chat, photo)
|
||||||
local a
|
local a
|
||||||
chat, a = format_target(chat)
|
chat, a = format_target(chat)
|
||||||
local command = comtab.photo_set[a]:format(chat, photo)
|
local command = comtab.photo_set[a]:format(chat, photo)
|
||||||
return drua.send(command)
|
return drua.send(command)
|
||||||
end
|
end
|
||||||
|
|
||||||
drua.get_info = function(target)
|
function drua.get_info(target)
|
||||||
local a
|
local a
|
||||||
target, a = format_target(target)
|
target, a = format_target(target)
|
||||||
local command = comtab.info[a]:format(target)
|
local command = comtab.info[a]:format(target)
|
||||||
return drua.send(command, true)
|
return drua.send(command, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
drua.channel_set_admin = function(chat, user, rank)
|
function drua.channel_set_admin(chat, user, rank)
|
||||||
chat = format_target(chat)
|
chat = format_target(chat)
|
||||||
user = format_target(user)
|
user = format_target(user)
|
||||||
local command = 'channel_set_admin %s %s %s'
|
local command = 'channel_set_admin %s %s %s'
|
||||||
command = command:format(chat, user, rank)
|
command = command:format(chat, user, rank)
|
||||||
return drua.send(command)
|
return drua.send(command)
|
||||||
end
|
end
|
||||||
|
|
||||||
drua.channel_set_about = function(chat, text)
|
function drua.channel_set_about(chat, text)
|
||||||
chat = format_target(chat)
|
chat = format_target(chat)
|
||||||
text = escape(text)
|
text = escape(text)
|
||||||
local command = 'channel_set_about %s "%s"'
|
local command = 'channel_set_about %s "%s"'
|
||||||
command = command:format(chat, text)
|
command = command:format(chat, text)
|
||||||
return drua.send(command)
|
return drua.send(command)
|
||||||
end
|
end
|
||||||
|
|
||||||
drua.block = function(user)
|
function drua.block(user)
|
||||||
return drua.send('block_user user#' .. user)
|
return drua.send('block_user user#' .. user)
|
||||||
end
|
end
|
||||||
|
|
||||||
drua.unblock = function(user)
|
function drua.unblock(user)
|
||||||
return drua.send('unblock_user user#' .. user)
|
return drua.send('unblock_user user#' .. user)
|
||||||
end
|
end
|
||||||
|
|
||||||
return drua
|
return drua
|
||||||
|
@ -50,17 +50,7 @@ function administration:init(config)
|
|||||||
|
|
||||||
administration.flags = administration.init_flags(config.cmd_pat)
|
administration.flags = administration.init_flags(config.cmd_pat)
|
||||||
administration.init_command(self, config)
|
administration.init_command(self, config)
|
||||||
administration.antiflood = config.administration.antiflood or {
|
administration.antiflood = config.administration.antiflood
|
||||||
text = 5,
|
|
||||||
voice = 5,
|
|
||||||
audio = 5,
|
|
||||||
contact = 5,
|
|
||||||
photo = 10,
|
|
||||||
video = 10,
|
|
||||||
location = 10,
|
|
||||||
document = 10,
|
|
||||||
sticker = 20
|
|
||||||
}
|
|
||||||
|
|
||||||
administration.doc = 'Returns a list of administrated groups.\nUse '..config.cmd_pat..'ahelp for more administrative commands.'
|
administration.doc = 'Returns a list of administrated groups.\nUse '..config.cmd_pat..'ahelp for more administrative commands.'
|
||||||
administration.command = 'groups [query]'
|
administration.command = 'groups [query]'
|
||||||
|
@ -34,7 +34,7 @@ function bible:action(msg, config)
|
|||||||
output, res = HTTP.request(url)
|
output, res = HTTP.request(url)
|
||||||
end
|
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
|
output = config.errors.results
|
||||||
end
|
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 = {}
|
local data = {}
|
||||||
for k,v in pairs(userdata) do
|
for k,v in pairs(userdata) do
|
||||||
table.insert(data, string.format(
|
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(k),
|
||||||
utilities.html_escape(v)
|
utilities.html_escape(v)
|
||||||
))
|
))
|
||||||
|
@ -13,7 +13,7 @@ Example (forty pidgeys and three hundred pidgey candies):
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- This function written by Juan Potato. MIT-licensed.
|
-- 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 transferred = 0;
|
||||||
local evolved = 0;
|
local evolved = 0;
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ local pidgey_calc = function(candies_to_evolve, mons, candies)
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
local single_job = function(input)
|
local function single_job(input)
|
||||||
local req_candy, mons, candies = input:match('^(%d+) (%d+) (%d+)$')
|
local req_candy, mons, candies = input:match('^(%d+) (%d+) (%d+)$')
|
||||||
req_candy = tonumber(req_candy)
|
req_candy = tonumber(req_candy)
|
||||||
mons = tonumber(mons)
|
mons = tonumber(mons)
|
||||||
|
@ -6,79 +6,79 @@ local utilities = require('otouto.utilities')
|
|||||||
pokemon_go.command = 'pokego <team>'
|
pokemon_go.command = 'pokego <team>'
|
||||||
|
|
||||||
function pokemon_go:init(config)
|
function pokemon_go:init(config)
|
||||||
pokemon_go.triggers = utilities.triggers(self.info.username, config.cmd_pat)
|
pokemon_go.triggers = utilities.triggers(self.info.username, config.cmd_pat)
|
||||||
:t('pokego', true):t('pokégo', true)
|
:t('pokego', true):t('pokégo', true)
|
||||||
:t('pokemongo', true):t('pokémongo', true)
|
:t('pokemongo', true):t('pokémongo', true)
|
||||||
:t('pogo', true):t('mongo', true).table
|
:t('pogo', true):t('mongo', true).table
|
||||||
pokemon_go.doc = config.cmd_pat .. [[pokego <team>
|
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.]]
|
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
|
local db = self.database.pokemon_go
|
||||||
if not db then
|
if not db then
|
||||||
self.database.pokemon_go = {}
|
self.database.pokemon_go = {}
|
||||||
db = self.database.pokemon_go
|
db = self.database.pokemon_go
|
||||||
end
|
end
|
||||||
if not db.membership then
|
if not db.membership then
|
||||||
db.membership = {}
|
db.membership = {}
|
||||||
end
|
end
|
||||||
for _, set in pairs(db.membership) do
|
for _, set in pairs(db.membership) do
|
||||||
setmetatable(set, utilities.set_meta)
|
setmetatable(set, utilities.set_meta)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local team_ref = {
|
local team_ref = {
|
||||||
mystic = "Mystic",
|
mystic = "Mystic",
|
||||||
m = "Mystic",
|
m = "Mystic",
|
||||||
valor = "Valor",
|
valor = "Valor",
|
||||||
v = "Valor",
|
v = "Valor",
|
||||||
instinct = "Instinct",
|
instinct = "Instinct",
|
||||||
i = "Instinct",
|
i = "Instinct",
|
||||||
blue = "Mystic",
|
blue = "Mystic",
|
||||||
b = "Mystic",
|
b = "Mystic",
|
||||||
red = "Valor",
|
red = "Valor",
|
||||||
r = "Valor",
|
r = "Valor",
|
||||||
yellow = "Instinct",
|
yellow = "Instinct",
|
||||||
y = "Instinct"
|
y = "Instinct"
|
||||||
}
|
}
|
||||||
|
|
||||||
function pokemon_go:action(msg, config)
|
function pokemon_go:action(msg, config)
|
||||||
local output
|
local output
|
||||||
local input = utilities.input(msg.text_lower)
|
local input = utilities.input(msg.text_lower)
|
||||||
|
|
||||||
if input then
|
if input then
|
||||||
local team = team_ref[input]
|
local team = team_ref[input]
|
||||||
if not team then
|
if not team then
|
||||||
output = 'Invalid team.'
|
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)
|
|
||||||
else
|
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
|
||||||
end
|
else
|
||||||
|
local db = self.database.pokemon_go
|
||||||
|
local db_membership = db.membership
|
||||||
|
|
||||||
output = 'Your team is now '..team..'.'
|
local output_temp = {'Membership:'}
|
||||||
end
|
for t, set in pairs(db_membership) do
|
||||||
else
|
table.insert(output_temp, t..': '..#set)
|
||||||
local db = self.database.pokemon_go
|
end
|
||||||
local db_membership = db.membership
|
|
||||||
|
|
||||||
local output_temp = {'Membership:'}
|
output = table.concat(output_temp, '\n')
|
||||||
for t, set in pairs(db_membership) do
|
|
||||||
table.insert(output_temp, t..': '..#set)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
output = table.concat(output_temp, '\n')
|
utilities.send_reply(self, msg, output)
|
||||||
end
|
|
||||||
|
|
||||||
utilities.send_reply(self, msg, output)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return pokemon_go
|
return pokemon_go
|
||||||
|
@ -67,7 +67,7 @@ local puns = {
|
|||||||
"I don't trust people with graph paper. They're always plotting something",
|
"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.",
|
"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.",
|
"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.",
|
"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.",
|
"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.",
|
"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 reactions = {}
|
||||||
|
|
||||||
local utilities = require('otouto.utilities')
|
local utilities = require('otouto.utilities')
|
||||||
@ -13,15 +5,13 @@ local utilities = require('otouto.utilities')
|
|||||||
reactions.command = 'reactions'
|
reactions.command = 'reactions'
|
||||||
reactions.doc = 'Returns a list of "reaction" emoticon commands.'
|
reactions.doc = 'Returns a list of "reaction" emoticon commands.'
|
||||||
|
|
||||||
local help
|
|
||||||
|
|
||||||
function reactions:init(config)
|
function reactions:init(config)
|
||||||
-- Generate a "help" message triggered by "/reactions".
|
-- Generate a command list message triggered by "/reactions".
|
||||||
help = 'Reactions:\n'
|
reactions.help = 'Reactions:\n'
|
||||||
reactions.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('reactions').table
|
reactions.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('reactions').table
|
||||||
local username = self.info.username:lower()
|
local username = self.info.username:lower()
|
||||||
for trigger,reaction in pairs(config.reactions) do
|
for trigger, reaction in pairs(config.reactions) do
|
||||||
help = help .. '• ' .. config.cmd_pat .. trigger .. ': ' .. reaction .. '\n'
|
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)
|
||||||
table.insert(reactions.triggers, '^'..config.cmd_pat..trigger..'@'..username)
|
table.insert(reactions.triggers, '^'..config.cmd_pat..trigger..'@'..username)
|
||||||
table.insert(reactions.triggers, config.cmd_pat..trigger..'$')
|
table.insert(reactions.triggers, config.cmd_pat..trigger..'$')
|
||||||
@ -35,12 +25,12 @@ end
|
|||||||
|
|
||||||
function reactions:action(msg, config)
|
function reactions:action(msg, config)
|
||||||
if string.match(msg.text_lower, config.cmd_pat..'reactions') then
|
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
|
return
|
||||||
end
|
end
|
||||||
for trigger,reaction in pairs(config.reactions) do
|
for trigger,reaction in pairs(config.reactions) do
|
||||||
if string.match(msg.text_lower, config.cmd_pat..trigger) then
|
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
|
return
|
||||||
end
|
end
|
||||||
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'
|
Aliases: ]] .. config.cmd_pat .. 'r, /r/subreddit'
|
||||||
end
|
end
|
||||||
|
|
||||||
local format_results = function(posts)
|
local function format_results(posts)
|
||||||
local output = ''
|
local output = ''
|
||||||
for _,v in ipairs(posts) do
|
for _,v in ipairs(posts) do
|
||||||
local post = v.data
|
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
|
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>
|
remind.doc = config.cmd_pat .. [[remind <duration> <message>
|
||||||
Repeats a message after a duration of time, in minutes.
|
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.]]
|
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