Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F145281
lmgtfy.lua
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
lmgtfy.lua
View Options
--[[
Copyright 2020 Matthew Hesketh <matthew@matthewhesketh.com>
This code is licensed under the MIT. See LICENSE for details.
]]
local
lmgtfy
=
{}
local
mattata
=
require
(
'mattata'
)
local
url
=
require
(
'socket.url'
)
local
redis
=
require
(
'libs.redis'
)
function
lmgtfy
:
init
()
lmgtfy
.
commands
=
mattata
.
commands
(
self
.
info
.
username
):
command
(
'lmgtfy'
).
table
lmgtfy
.
help
=
'/lmgtfy [anything] - Helps that special someone out. Input can be given via an argument or using the replied-to person
\'
s message text.'
end
function
lmgtfy
:
on_message
(
message
)
local
input
=
mattata
.
input
(
message
.
text
)
if
not
input
then
if
not
message
.
reply
then
return
mattata
.
send_reply
(
message
,
lmgtfy
.
help
)
end
input
=
message
.
reply
.
text
end
if
message
.
reply
then
message
.
message_id
=
message
.
reply
.
message_id
-- if we're sending in reply to a reply, we need it to trick it!
end
input
=
'https://lmgtfy.com/?q='
..
url
.
escape
(
input
)
local
output
=
redis
:
get
(
'chat:'
..
message
.
chat
.
id
..
':lmgtfy'
)
or
'Here you go, idiot.'
output
=
mattata
.
escape_html
(
output
)
output
=
string.format
(
'<a href="%s">%s</a>'
,
input
,
output
)
if
message
.
reply
then
return
mattata
.
send_reply
(
message
,
output
,
'html'
)
end
return
mattata
.
send_message
(
message
.
chat
.
id
,
output
,
'html'
)
end
return
lmgtfy
File Metadata
Details
Attached
Mime Type
text/html
Expires
Sun, Aug 16, 8:49 AM (1 d, 22 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
77438
Default Alt Text
lmgtfy.lua (1 KB)
Attached To
Mode
R69 mattata
Attached
Detach File
Event Timeline