Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F627033
triggers.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
triggers.lua
View Options
--[[
mattata v2.0 - Triggers Plugin
]]
local
plugin
=
{}
plugin
.
name
=
'triggers'
plugin
.
category
=
'admin'
plugin
.
description
=
'List all triggers in the group'
plugin
.
commands
=
{
'triggers'
}
plugin
.
help
=
'/triggers - Lists all triggers set for this group.'
plugin
.
group_only
=
true
plugin
.
admin_only
=
true
function
plugin
.
on_message
(
api
,
message
,
ctx
)
local
tools
=
require
(
'telegram-bot-lua.tools'
)
local
triggers
=
ctx
.
db
.
execute
(
'SELECT id, pattern, response, created_by, created_at FROM triggers WHERE chat_id = $1 ORDER BY created_at'
,
{
message
.
chat
.
id
}
)
if
not
triggers
or
#
triggers
==
0
then
return
api
.
send_message
(
message
.
chat
.
id
,
'No triggers are set. Use /addtrigger <pattern> <response> to add one.'
)
end
local
output
=
'<b>Triggers for this group:</b>
\n\n
'
for
i
,
t
in
ipairs
(
triggers
)
do
output
=
output
..
string.format
(
'%d. <code>%s</code> -> %s
\n
'
,
i
,
tools
.
escape_html
(
t
.
pattern
),
tools
.
escape_html
(
t
.
response
:
sub
(
1
,
50
))
..
(
#
t
.
response
>
50
and
'...'
or
''
)
)
end
output
=
output
..
string.format
(
'
\n
<i>Total: %d trigger(s)</i>'
,
#
triggers
)
api
.
send_message
(
message
.
chat
.
id
,
output
,
'html'
)
end
return
plugin
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 15, 1:30 AM (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
127382
Default Alt Text
triggers.lua (1 KB)
Attached To
Mode
R69 mattata
Attached
Detach File
Event Timeline