Merge pull request #94 from StateOfTheArt89/master
Added two plugins: hackernews, magic 8ball
This commit is contained in:
commit
4b0cecec64
24
plugins/hackernews.lua
Normal file
24
plugins/hackernews.lua
Normal file
@ -0,0 +1,24 @@
|
||||
do
|
||||
|
||||
function run(msg, matches)
|
||||
local result = 'Hacker News Top5:\n'
|
||||
local top_stories_json, code = https.request('https://hacker-news.firebaseio.com/v0/topstories.json')
|
||||
if code ~=200 then return nil end
|
||||
local top_stories = json:decode(top_stories_json)
|
||||
for i = 1, 5 do
|
||||
local story_json, code = https.request('https://hacker-news.firebaseio.com/v0/item/'..top_stories[i]..'.json')
|
||||
if code ~=200 then return nil end
|
||||
local story = json:decode(story_json)
|
||||
result = result .. i .. '. ' .. story.title .. ' - ' .. story.url .. '\n'
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
return {
|
||||
description = "Show top 5 hacker news (ycombinator.com)",
|
||||
usage = "!hackernews",
|
||||
patterns = {"^!hackernews$"},
|
||||
run = run
|
||||
}
|
||||
|
||||
end
|
22
plugins/magic8ball.lua
Normal file
22
plugins/magic8ball.lua
Normal file
@ -0,0 +1,22 @@
|
||||
do
|
||||
|
||||
function run(msg, matches)
|
||||
local answers = {'It is certain','It is decidedly so','Without a doubt',
|
||||
'Yes definitely','You may rely on it','As I see it, yes',
|
||||
'Most likely','Outlook good','Yes','Signs point to yes',
|
||||
'Reply hazy try again','Ask again later',
|
||||
'Better not tell you now','Cannot predict now',
|
||||
'Concentrate and ask again','Don\'t count on it',
|
||||
'My reply is no','My sources say no','Outlook not so good',
|
||||
'Very doubtful'}
|
||||
return answers[math.random(#answers)]
|
||||
end
|
||||
|
||||
return {
|
||||
description = "Magic 8Ball",
|
||||
usage = "!magic8ball",
|
||||
patterns = {"^!magic8ball$"},
|
||||
run = run
|
||||
}
|
||||
|
||||
end
|
Reference in New Issue
Block a user