diff --git a/plugins/hackernews.lua b/plugins/hackernews.lua new file mode 100644 index 0000000..284a03f --- /dev/null +++ b/plugins/hackernews.lua @@ -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 diff --git a/plugins/magic8ball.lua b/plugins/magic8ball.lua new file mode 100644 index 0000000..c592d66 --- /dev/null +++ b/plugins/magic8ball.lua @@ -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