This repository has been archived on 2021-04-24. You can view files and clone it, but cannot push or open issues or pull requests.
Mikubot-2/plugins/fortune.lua

30 lines
686 B
Lua
Raw Normal View History

-- Requires that the "fortune" program is installed on your computer.
2015-07-03 00:15:52 +02:00
local fortune = {}
local bindings = require('bindings')
local utilities = require('utilities')
function fortune:init()
local s = io.popen('fortune'):read('*all')
if s:match('not found$') then
print('fortune is not installed on this computer.')
print('fortune.lua will not be enabled.')
return
end
fortune.triggers = utilities.triggers(self.info.username):t('fortune').table
end
2015-07-03 00:15:52 +02:00
fortune.command = 'fortune'
fortune.doc = '`Returns a UNIX fortune.`'
2015-07-03 00:15:52 +02:00
function fortune:action(msg)
local message = io.popen('fortune'):read('*all')
bindings.sendMessage(self, msg.chat.id, message)
2015-07-03 00:15:52 +02:00
end
return fortune