More HS commands.
This commit is contained in:
parent
f3c58f69f1
commit
6bbe91be27
1 changed files with 51 additions and 0 deletions
|
@ -16,6 +16,56 @@ plugin.AddCommand('at', 0, function(Username, Channel)
|
|||
end
|
||||
end, "Show who's at the Warsaw Hackerspace.")
|
||||
|
||||
local function SayDue(Target, Channel)
|
||||
local Body, Code, Headers, Status = https.request('https://kasownik.hackerspace.pl/api/months_due/' .. Target .. '.json')
|
||||
if Code == 404 then
|
||||
Channel:Say("No such member.")
|
||||
return
|
||||
end
|
||||
if Code ~= 200 then
|
||||
error(string.format("Status code returned: %i", Code))
|
||||
end
|
||||
|
||||
local Data = json.decode.decode(Body)
|
||||
if Data['status'] ~= 'ok' then
|
||||
error("No such member?")
|
||||
else
|
||||
local Due = Data['content']
|
||||
local Comment = ""
|
||||
if Due < 0 then
|
||||
Comment = string.format("is %i months ahead. Cool!", -Due)
|
||||
elseif Due == 0 then
|
||||
Comment = "has paid all his membership fees."
|
||||
elseif Due == 1 then
|
||||
Comment = "needs to pay one membership fee."
|
||||
else
|
||||
Comment = string.format("needs to pay %i membership fees.", Due)
|
||||
end
|
||||
Channel:Say(Target .. " " .. Comment)
|
||||
end
|
||||
end
|
||||
|
||||
plugin.AddCommand('due', 1, function(Username, Channel, Target)
|
||||
SayDue(Target, Channel)
|
||||
end, "Show months due for user.")
|
||||
|
||||
plugin.AddCommand('due-me', 0, function(Username, Channel)
|
||||
SayDue(Username, Channel)
|
||||
end, "Show months due for speaker.")
|
||||
|
||||
plugin.AddCommand('mana', 0, function(Username, Channel)
|
||||
local Body, Code, Headers, Status = https.request('https://kasownik.hackerspace.pl/api/mana.json')
|
||||
if Code ~= 200 then
|
||||
error(string.format("Status code returned: %i", Code))
|
||||
end
|
||||
|
||||
local Data = json.decode.decode(Body)
|
||||
local Required = Data['content']['required']
|
||||
local Paid = Data['content']['paid']
|
||||
local Updated = Data['modified']
|
||||
Channel:Say(string.format("%i paid, %i required (last updated %s)", Paid, Required, Updated))
|
||||
end, "Show Hackerspace mana (due fees in total.")
|
||||
|
||||
plugin.AddCommand('describe', 1, function(Username, Channel, Term)
|
||||
local db = plugin.DBOpen('main')
|
||||
local Header = false
|
||||
|
@ -53,3 +103,4 @@ end)
|
|||
plugin.AddCommand('op', 1, function(Username, Channel, Target)
|
||||
irc:_Send(string.format("MODE %s +o %s", Channel, Target))
|
||||
end, "Give operator status to someone on the channel.", 40)
|
||||
|
||||
|
|
Loading…
Reference in a new issue