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
topkecleon 26c1299374 Rewrote help.lua and added markup support to several plugins.
help.lua has been rewritten to support "/help command".
New variable "command" has been added to plugins for the syntax (w/out slash) to be displayed in main
help message. "doc" will be displayed upon "/help command".

Output of >12 plugins has been reformated to utilize markup.
There is a fairly standard style throughout plugins.

get_word() in utilities.lua now has defaults for nil arguments.
2016-01-08 08:44:37 -05:00

50 lines
1.1 KiB
Lua
Executable File

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..']*$'
}
local action = function(msg)
if msg.reply_to_message then
msg = msg.reply_to_message
end
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 .. ')'
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
local nicks = load_data('nicknames.json')
if nicks[msg.from.id_str] then
message = message .. '\nYour nickname is ' .. nicks[msg.from.id_str] .. '.'
end
sendReply(msg, message)
end
return {
action = action,
triggers = triggers,
doc = doc,
command = command
}