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 60570e90f3 added cron jobs for plugins
added example plugin with documentation
added liberbot-compliant flood control
	see Liberbot Support for details on getting compliant
added Kickass Torrent plugin
various bugfixes
all files seem to have been marked changed due to a shift in platform
	I will do a clean clone and testing to ensure there is no issue.
2015-08-28 23:15:01 -07:00

48 lines
1.1 KiB
Lua
Executable File

local PLUGIN = {}
PLUGIN.doc = [[
/whoami
Get the user ID for yourself and the group. Use it in a reply to get info for the sender of the original message.
]]
PLUGIN.triggers = {
'^/whoami',
'^/ping',
'^/who$'
}
function PLUGIN.action(msg)
if msg.from.id == msg.chat.id then
to_name = '@' .. bot.username .. ' (' .. bot.id .. ')'
else
to_name = string.gsub(msg.chat.title, '_', ' ') .. ' (' .. string.gsub(msg.chat.id, '-', '') .. ')'
end
if msg.reply_to_message then
msg = msg.reply_to_message
end
local nicknames = load_data('nicknames.json')
local message = ''
if nicknames[tostring(msg.from.id)] then
message = 'Hi, ' .. nicknames[tostring(msg.from.id)] .. '!\n'
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 message = message .. 'You are ' .. from_name .. ' and you are messaging ' .. to_name .. '.'
send_msg(msg, message)
end
return PLUGIN