9ebdbd9d3c
"things occurred" Added some utilities (id_from_username, id_from_message), removed some utilities (latcyr, others?). Removed cycle-wasting "shortcuts" -- no more automatic id_str or name; text_lower remains. Moved userdata (nicknames, lastfm, etc) to a different tree in the database (automatic migration will occur). /me now returns userdata. Speaking of migration, database now stores the latest version run to make future automigration easy. Database now saves hourly rather than minutely. Changed readme and some plugins to reflect above changes. Removed broken rockspec (Brayden, feel free to re-add once it's working). Added option to automatically block people (via drua) when blacklisted. Fixed about.lua trigger problems. administration 1.11 - Removed /kickme and /broadcast. Users should leave manually, and announcements should be made via channel rather than spam. /setqotd now handles forwarded messages correctly. /kick, /ban, /hammer, /mod, /admin now support multiple arguments. Added get_targets function. No migration is necessary.
53 lines
1.4 KiB
Lua
Executable File
53 lines
1.4 KiB
Lua
Executable File
local whoami = {}
|
|
|
|
local utilities = require('otouto.utilities')
|
|
|
|
whoami.command = 'whoami'
|
|
|
|
function whoami:init(config)
|
|
whoami.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('who', true):t('whoami').table
|
|
whoami.doc = [[```
|
|
Returns user and chat info for you or the replied-to message.
|
|
Alias: ]]..config.cmd_pat..[[who
|
|
```]]
|
|
end
|
|
|
|
function whoami:action(msg)
|
|
|
|
if msg.reply_to_message then
|
|
msg = msg.reply_to_message
|
|
end
|
|
|
|
local from_name = utilities.build_name(msg.from.first_name, msg.from.last_name)
|
|
|
|
local chat_id = math.abs(msg.chat.id)
|
|
if chat_id > 1000000000000 then
|
|
chat_id = chat_id - 1000000000000
|
|
end
|
|
|
|
local user = 'You are @%s, also known as *%s* `[%s]`'
|
|
if msg.from.username then
|
|
user = user:format(utilities.markdown_escape(msg.from.username), from_name, msg.from.id)
|
|
else
|
|
user = 'You are *%s* `[%s]`,'
|
|
user = user:format(from_name, msg.from.id)
|
|
end
|
|
|
|
local group = '@%s, also known as *%s* `[%s]`.'
|
|
if msg.chat.type == 'private' then
|
|
group = group:format(utilities.markdown_escape(self.info.username), self.info.first_name, self.info.id)
|
|
elseif msg.chat.username then
|
|
group = group:format(utilities.markdown_escape(msg.chat.username), msg.chat.title, chat_id)
|
|
else
|
|
group = '*%s* `[%s]`.'
|
|
group = group:format(msg.chat.title, chat_id)
|
|
end
|
|
|
|
local output = user .. ', and you are messaging ' .. group
|
|
|
|
utilities.send_message(self, msg.chat.id, output, true, msg.message_id, true)
|
|
|
|
end
|
|
|
|
return whoami
|