Merge pull request #94 from StateOfTheArt89/master

Added two plugins: hackernews, magic 8ball
This commit is contained in:
Yago 2015-04-04 22:37:17 +02:00
commit 4b0cecec64
2 changed files with 46 additions and 0 deletions

24
plugins/hackernews.lua Normal file
View 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
View 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