2015-05-18 21:43:42 +02:00
|
|
|
local function user_print_name(user)
|
|
|
|
if user.print_name then
|
|
|
|
return user.print_name
|
|
|
|
end
|
|
|
|
local text = ''
|
|
|
|
if user.first_name then
|
|
|
|
text = user.last_name..' '
|
|
|
|
end
|
|
|
|
if user.lastname then
|
|
|
|
text = text..user.last_name
|
|
|
|
end
|
|
|
|
return text
|
|
|
|
end
|
|
|
|
|
|
|
|
local function returnids(cb_extra, success, result)
|
|
|
|
local receiver = "chat#id" .. result.id
|
|
|
|
local chatname = result.print_name
|
|
|
|
local text = 'IDs fuer den Chat "' .. chatname .. '" (' .. receiver .. ')\n'
|
|
|
|
text = text .. "Hier sind " .. result.members_num .. ' Mitglieder:\n---------\n'
|
|
|
|
for k,v in pairs(result.members) do
|
2015-05-19 18:41:36 +02:00
|
|
|
text = text .. v.print_name .. " (user#id" .. v.id ..")\n"
|
2015-06-08 21:14:29 +02:00
|
|
|
text = string.gsub(text, "%_", " ")
|
2015-05-18 21:43:42 +02:00
|
|
|
end
|
2015-06-08 21:14:29 +02:00
|
|
|
send_large_msg(receiver, text)
|
2015-05-18 21:43:42 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
local function run(msg, matches)
|
2016-06-22 13:59:06 +02:00
|
|
|
if matches[1] == "#id" or matches[1] == "#myid"then
|
2015-05-19 18:41:36 +02:00
|
|
|
local text = 'Dein Name lautet "' .. user_print_name(msg.from) .. '" und deine ID ist ' .. msg.from.id .. ' ' .. tostring(is_sudo(msg))
|
2015-05-18 21:43:42 +02:00
|
|
|
if is_chat_msg(msg) then
|
2015-05-19 18:41:36 +02:00
|
|
|
text = text .. '\nDu bist in der Gruppe "' .. user_print_name(msg.to) .. '" und die Chat ID ist ' .. msg.to.id
|
2015-06-08 21:14:29 +02:00
|
|
|
text = string.gsub(text, "%_", " ")
|
2015-05-18 21:43:42 +02:00
|
|
|
end
|
|
|
|
return text
|
|
|
|
elseif matches[1] == "chat" then
|
|
|
|
if not is_chat_msg(msg) then
|
|
|
|
return "Du bist nicht in einer Gruppe."
|
|
|
|
end
|
|
|
|
local chat_name = msg.to.print_name
|
|
|
|
chat_info(chat_name, returnids, {})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return {
|
2015-05-19 18:41:36 +02:00
|
|
|
description = "Zeige dir deine ID und die IDs aller Gruppenmitglieder an.",
|
2016-06-22 13:59:06 +02:00
|
|
|
usage = {"#id", "#myid"," #id chat"},
|
|
|
|
patterns = {"^#id$","^#myid$","^#ids? (chat)"},
|
2015-05-18 21:43:42 +02:00
|
|
|
run = run
|
|
|
|
}
|