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/otouto/plugins/whoami.lua
Andreas Bielawski a4d7c40ad9 Committe aktuellen Status.
NEU:
- Twitter-Plugin (ohne Markdown bisher)
- Get- Set-Plugins
- 9GAG
- Adfly
- Redis-Integration
- Google Search
- Google Images (modifiziert, mit Blacklist, bisher ohne Caching)
- Einige Plugins lokalisiert

Das ist momentan noch alles WIP, das meiste ist einfach bloß copy&paste vom proprietären
Brawlbot v1.
2016-06-11 14:46:41 +02:00

52 lines
1.4 KiB
Lua

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
msg.from.name = utilities.build_name(msg.from.first_name, msg.from.last_name)
end
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), msg.from.name, msg.from.id)
else
user = 'You are *%s* `[%s]`,'
user = user:format(msg.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