From 14cef425297f82e7eb8d1763c3df5b0b11790348 Mon Sep 17 00:00:00 2001 From: Akamaru Date: Mon, 18 May 2015 21:43:42 +0200 Subject: [PATCH] new plugins id.lua old.lua --- plugins/id.lua | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ plugins/old.lua | 12 ++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 plugins/id.lua create mode 100644 plugins/old.lua diff --git a/plugins/id.lua b/plugins/id.lua new file mode 100644 index 0000000..1e65137 --- /dev/null +++ b/plugins/id.lua @@ -0,0 +1,50 @@ +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 + text = text .. v.print_name .. " (user#id" .. v.id .. ")\n" + end + send_msg(receiver, text, ok_cb, false) +end + +local function run(msg, matches) + if matches[1] == "/id" then + local text = user_print_name(msg.from) .. ' (user#id' .. msg.from.id .. ' ' .. tostring(is_sudo(msg)) .. ')' + if is_chat_msg(msg) then + text = text .. '\nDu bist in der Gruppe "' .. user_print_name(msg.to) .. '" (chat#id ' .. msg.to.id .. ')' + 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 { + description = "Zeige dir IDs und IDs aller Gruppenmitglieder an.", + usage = "/id, /id chat", + patterns = { + "^/id$", + "^/ids? (chat)" + }, + run = run +} \ No newline at end of file diff --git a/plugins/old.lua b/plugins/old.lua new file mode 100644 index 0000000..7207b5b --- /dev/null +++ b/plugins/old.lua @@ -0,0 +1,12 @@ + +function run(msg, matches) + return 'Deine Mudda is old!' +end + +return { + description = "", + usage = {"#old"}, + patterns = {"^#old$"}, + run = run +} +--by Akamaru \ No newline at end of file