This repository has been archived on 2021-04-24. You can view files and clone it, but cannot push or open issues or pull requests.
Mikubot-2/plugins/whoami.lua

45 lines
956 B
Lua
Raw Normal View History

local command = 'whoami'
local doc = [[```
Returns user and chat info for you or the replied-to message.
Alias: /who
```]]
local triggers = {
'^/who[ami]*[@'..bot.username..']*$'
2015-07-03 00:15:52 +02:00
}
local action = function(msg)
if msg.reply_to_message then
msg = msg.reply_to_message
end
2015-07-03 00:15:52 +02:00
local from_name = msg.from.first_name
if msg.from.last_name then
from_name = from_name .. ' ' .. msg.from.last_name
end
if msg.from.username then
from_name = '@' .. msg.from.username .. ', AKA ' .. from_name
end
from_name = from_name .. ' (' .. msg.from.id .. ')'
2015-07-08 09:38:04 +02:00
local to_name
if msg.chat.title then
to_name = msg.chat.title .. ' (' .. math.abs(msg.chat.id) .. ').'
else
to_name = '@' .. bot.username .. ', AKA ' .. bot.first_name .. ' (' .. bot.id .. ').'
end
local message = 'You are ' .. from_name .. ' and you are messaging ' .. to_name
2015-07-08 09:38:04 +02:00
sendReply(msg, message)
2015-07-03 00:15:52 +02:00
end
return {
action = action,
triggers = triggers,
doc = doc,
command = command
}