plugins and stuff
This commit is contained in:
parent
f3c58f69f1
commit
f50a311864
2 changed files with 84 additions and 0 deletions
|
@ -16,6 +16,80 @@ plugin.AddCommand('at', 0, function(Username, Channel)
|
||||||
end
|
end
|
||||||
end, "Show who's at the Warsaw Hackerspace.")
|
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.")
|
||||||
|
|
||||||
|
-- hax
|
||||||
|
os = {}
|
||||||
|
os.time = table.time
|
||||||
|
|
||||||
|
Nagged = {}
|
||||||
|
plugin.AddHook('irc.Message', 'nag', function(Username, Channel, Message)
|
||||||
|
local Target = Username:lower()
|
||||||
|
if Target == 'enleth' then return end
|
||||||
|
if Nagged[Target] == nil or Nagged[Target] < os.time() then
|
||||||
|
local Body, Code, Headers, Status = https.request('https://kasownik.hackerspace.pl/api/months_due/' .. Target .. '.json')
|
||||||
|
if Code == 200 then
|
||||||
|
local Data = json.decode.decode(Body)
|
||||||
|
if Data['content'] > 0 then
|
||||||
|
Nagged[Target] = os.time() + 60 * 60 * 24
|
||||||
|
local Months = 'months'
|
||||||
|
if Data['content'] == 0 then
|
||||||
|
Months = 'month'
|
||||||
|
end
|
||||||
|
Channel:Say(string.format('%s: pay your membership fees! you are %i %s behind!', Username, Data['content'], Months))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
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)
|
plugin.AddCommand('describe', 1, function(Username, Channel, Term)
|
||||||
local db = plugin.DBOpen('main')
|
local db = plugin.DBOpen('main')
|
||||||
local Header = false
|
local Header = false
|
||||||
|
|
10
plugins/wolfram.lua
Normal file
10
plugins/wolfram.lua
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
plugin.AddCommand('c', -1, function(Username, Channel, Line)
|
||||||
|
local Body, Code = https.request('https://www.wolframalpha.com/input/?i=' .. Line)
|
||||||
|
if Code == 200 then
|
||||||
|
Body:gsub('{"stringified": "([^"]+)"', function(m)
|
||||||
|
Channel:Say(m)
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
Channel:Say('Got weird status code from WA: ' .. tostring(Code))
|
||||||
|
end
|
||||||
|
end, 'Calculate something on Wolfram Alpha')
|
Loading…
Reference in a new issue