Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F627500
addcommand.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
1 KB
Referenced Files
None
Subscribers
None
addcommand.lua
View Options
--[[
Copyright 2020 Matthew Hesketh <matthew@matthewhesketh.com>
This code is licensed under the MIT. See LICENSE for details.
]]
local
addcommand
=
{}
local
mattata
=
require
(
'mattata'
)
function
addcommand
:
init
()
addcommand
.
commands
=
mattata
.
commands
(
self
.
info
.
username
):
command
(
'addcommand'
).
table
end
function
addcommand
.
on_message
(
_
,
message
,
_
,
language
)
if
not
mattata
.
is_global_admin
(
message
.
from
.
id
)
then
return
false
end
local
input
=
mattata
.
input
(
message
.
text
)
if
not
input
or
not
input
:
match
(
'^[/!#]?[%w_]+ %- .-$'
)
then
return
mattata
.
send_reply
(
message
,
language
[
'addcommand'
][
'1'
],
'html'
)
end
local
commands
=
mattata
.
get_my_commands
()
if
not
commands
then
return
mattata
.
send_reply
(
message
,
language
[
'addcommand'
][
'2'
])
end
commands
=
type
(
commands
.
result
)
==
'table'
and
commands
.
result
or
{}
local
command
,
description
=
input
:
match
(
'^/?([%w_]+) %- (.-)$'
)
if
description
:
len
()
>
256
then
return
mattata
.
send_reply
(
message
,
language
[
'addcommand'
][
'3'
])
end
commands
=
table.insert
(
commands
,
{
[
'command'
]
=
command
,
[
'description'
]
=
description
})
local
success
=
mattata
.
set_my_commands
(
commands
)
if
not
success
then
return
mattata
.
send_reply
(
message
,
language
[
'addcommand'
][
'4'
])
end
return
mattata
.
send_reply
(
message
,
language
[
'addcommand'
][
'5'
])
end
return
addcommand
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 15, 2:11 AM (1 d, 23 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
119797
Default Alt Text
addcommand.lua (1 KB)
Attached To
Mode
R69 mattata
Attached
Detach File
Event Timeline