Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F627483
slap.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
slap.lua
View Options
--[[
mattata v2.0 - Slap Plugin
Slap users with random messages using templates.
]]
local
plugin
=
{}
plugin
.
name
=
'slap'
plugin
.
category
=
'fun'
plugin
.
description
=
'Slap a user with a random object'
plugin
.
commands
=
{
'slap'
}
plugin
.
help
=
'/slap [user] - Slap a user with a random message. Use in reply to target the replied user.'
function
plugin
.
on_message
(
api
,
message
,
ctx
)
local
tools
=
require
(
'telegram-bot-lua.tools'
)
local
slaps
=
require
(
'src.data.slaps'
)
local
sender_name
=
message
.
from
.
first_name
or
'Unknown'
local
target_name
if
message
.
reply
and
message
.
reply
.
from
then
target_name
=
message
.
reply
.
from
.
first_name
or
'Unknown'
elseif
message
.
args
and
message
.
args
~=
''
then
target_name
=
message
.
args
else
-- Slap yourself if no target
target_name
=
sender_name
sender_name
=
api
.
info
.
first_name
end
math.randomseed
(
os.time
()
+
os.clock
()
*
1000
)
local
template
=
slaps
[
math.random
(
#
slaps
)]
local
output
=
template
:
gsub
(
'{ME}'
,
tools
.
escape_html
(
sender_name
)):
gsub
(
'{THEM}'
,
tools
.
escape_html
(
target_name
))
return
api
.
send_message
(
message
.
chat
.
id
,
output
,
{
parse_mode
=
'html'
})
end
return
plugin
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 15, 2:09 AM (1 d, 22 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
140480
Default Alt Text
slap.lua (1 KB)
Attached To
Mode
R69 mattata
Attached
Detach File
Event Timeline