Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F627745
catfact.lua
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
801 B
Referenced Files
None
Subscribers
None
catfact.lua
View Options
--[[
Copyright 2020 Matthew Hesketh <matthew@matthewhesketh.com>
This code is licensed under the MIT. See LICENSE for details.
]]
local
catfact
=
{}
local
mattata
=
require
(
'mattata'
)
local
https
=
require
(
'ssl.https'
)
local
json
=
require
(
'dkjson'
)
function
catfact
:
init
()
catfact
.
commands
=
mattata
.
commands
(
self
.
info
.
username
):
command
(
'catfact'
):
command
(
'cfact'
).
table
catfact
.
help
=
'/catfact - Returns a random cat fact. Alias: /cfact.'
end
function
catfact
.
on_message
(
_
,
message
,
_
,
language
)
local
jstr
,
res
=
https
.
request
(
'https://catfact.ninja/fact'
)
if
res
~=
200
then
return
mattata
.
send_reply
(
message
,
language
.
errors
.
connection
)
end
local
jdat
=
json
.
decode
(
jstr
)
return
mattata
.
send_message
(
message
.
chat
.
id
,
jdat
.
fact
)
end
return
catfact
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 15, 2:39 AM (1 d, 22 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
121026
Default Alt Text
catfact.lua (801 B)
Attached To
Mode
R69 mattata
Attached
Detach File
Event Timeline