This repository has been archived on 2021-04-24. You can view files and clone it, but cannot push or open issues or pull requests.
Mikubot-2/otouto/plugins/pokemon-go.lua
topkecleon acc7046d64 administration 1.13.1
Added optional target for kick/ban logs. Added flag 7 to use default log
 per group. This way, a realm can have a public kick/ban log but governors
 are able to opt out. Added flag 8, antilink. Kicks for Telegram join links
 which do not refer to groups within the realm. Added flag 9, modrights, to
 give moderators access to changing the group photo, title, link, and motd
 (config option is deprecated. RIP). /unban will reset the target's autokick
 counter. Added configuration for default flag settings.

Revision to bindings.lua.
BASE_URL has been moved to bindings. There is no real reason for it to remain
in instance. Token is passed to bindings.init at load. All plugins have been
updated accordingly.
2016-08-23 00:16:32 -04:00

85 lines
2.4 KiB
Lua

-- For some reason you can't have an é in variable names. :(
local pokemon_go = {}
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>
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
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"
}
function pokemon_go:action(msg, config)
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)
else
set:add(id_str)
end
end
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
output = table.concat(output_temp, '\n')
end
utilities.send_reply(msg, output)
end
return pokemon_go