Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F623329
lua.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
2 KB
Referenced Files
None
Subscribers
None
lua.lua
View Options
--[[
Based on a plugin by topkecleon. Licensed under GNU AGPLv3
https://github.com/topkecleon/otouto/blob/master/LICENSE.
Copyright 2020 Matthew Hesketh <matthew@matthewhesketh.com>
This code is licensed under the MIT. See LICENSE for details.
]]
local
lua
=
{}
local
mattata
=
require
(
'mattata'
)
local
json
=
require
(
'dkjson'
)
function
lua
:
init
()
lua
.
commands
=
mattata
.
commands
(
self
.
info
.
username
):
command
(
'lua'
).
table
lua
.
error_message
=
function
(
error_message
)
return
'Error:
\n
'
..
tostring
(
error_message
)
end
end
function
lua
:
on_message
(
message
,
configuration
,
language
)
if
not
mattata
.
is_global_admin
(
message
.
from
.
id
)
then
return
end
local
input
=
mattata
.
input
(
message
.
text
)
if
not
input
then
local
text
=
language
[
'lua'
][
'1'
]
return
mattata
.
send_reply
(
message
,
text
)
end
local
output
,
success
=
load
(
"local mattata = require('mattata')
\n\z
local configuration = require('configuration')
\n\z
local api = require('telegram-bot-lua.core').configure(configuration.bot_token)
\n\z
local tools = require('telegram-bot-lua.tools')
\n\z
local https = require('ssl.https')
\n\z
local http = require('socket.http')
\n\z
local url = require('socket.url')
\n\z
local ltn12 = require('ltn12')
\n\z
local json = require('dkjson')
\n\z
local utf8 = require('lua-utf8')
\n\z
local socket = require('socket')
\n\z
local redis = require('libs.redis')
\n\z
return function (self, message, configuration)
\n
"
..
input
..
'
\n
end'
)
if
output
==
nil
then
output
=
success
else
success
,
output
=
xpcall
(
output
(),
lua
.
error_message
,
self
,
message
,
configuration
)
end
if
output
~=
nil
and
type
(
output
)
==
'table'
then
output
=
json
.
encode
(
output
,
{
[
'indent'
]
=
true
})
elseif
output
==
nil
then
return
false
end
return
mattata
.
send_message
(
message
.
chat
.
id
,
'<pre>'
..
mattata
.
escape_html
(
tostring
(
output
)
)
..
'</pre>'
,
'html'
)
end
return
lua
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 14, 9:07 PM (1 d, 3 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
128610
Default Alt Text
lua.lua (2 KB)
Attached To
Mode
R69 mattata
Attached
Detach File
Event Timeline