From 05faa356cca6623c7e50f52a56c94a086b21b9ce Mon Sep 17 00:00:00 2001 From: Andreas Bielawski Date: Thu, 25 Aug 2016 01:18:26 +0200 Subject: [PATCH] - Passe "Stille" an Portiere: - Saved_text - Spam - Special --- miku/plugins/saved_text.lua | 58 +++++++++++++++++ miku/plugins/spam.lua | 12 ++++ miku/plugins/special.lua | 123 ++++++++++++++++++++++++++++++++++++ miku/plugins/stille.lua | 18 +++--- 4 files changed, 201 insertions(+), 10 deletions(-) create mode 100644 miku/plugins/saved_text.lua create mode 100644 miku/plugins/spam.lua create mode 100644 miku/plugins/special.lua diff --git a/miku/plugins/saved_text.lua b/miku/plugins/saved_text.lua new file mode 100644 index 0000000..cb37913 --- /dev/null +++ b/miku/plugins/saved_text.lua @@ -0,0 +1,58 @@ +local saved_text = {} + +saved_text.triggers = { + "^/(deltext) (.+)$", + "^/(addtext) (.+)$", + "^/(listtext)$" +} + +local text_hash = 'telegram:savedtext' + +function saved_text:save_text(text) + print('Saving stille to redis set '..text_hash) + redis:sadd(text_hash, text) + return 'Gespeichert: '..text..'' +end + +function saved_text:delete_text(text) + print('Deleting text from redis set '..text_hash) + if redis:sismember(text_hash, text) == true then + redis:srem(text_hash, text) + return 'Text erfolgreich gelöscht!' + else + return 'Dieser Text existiert nicht.' + end +end + +function saved_text:list_text() + print('Getting text from redis set '..text_hash) + local text_table = redis:smembers(text_hash) + local text = "" + for num,stille in pairs(text_table) do + text = text..num..") "..stille..'\n' + end + if not text or text == "" then + return 'Es wurden noch keine Texte gespeichert.\nSpeichere doch welche mit /addtext [Text]' + else + return text + end +end + +function saved_text:action(msg, config, matches) + if not is_sudo(msg, config) then + return -- Silent Ignore + end + + if matches[1] == "addtext" then + utilities.send_reply(msg, saved_text:save_text(matches[2]), 'HTML') + return + elseif matches[1] == "deltext" then + utilities.send_reply(msg, saved_text:delete_text(matches[2]), 'HTML') + return + elseif matches[1] == "listtext" then + utilities.send_reply(msg, saved_text:list_text()) + return + end +end + +return saved_text \ No newline at end of file diff --git a/miku/plugins/spam.lua b/miku/plugins/spam.lua new file mode 100644 index 0000000..39bb0ad --- /dev/null +++ b/miku/plugins/spam.lua @@ -0,0 +1,12 @@ +local spam = {} + +function spam:init(config) + spam.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('spam', true).table +end + +function spam:action(msg, config) + local text = string.rep('SPAM ', 819) + utilities.send_reply(msg, text) +end + +return spam \ No newline at end of file diff --git a/miku/plugins/special.lua b/miku/plugins/special.lua new file mode 100644 index 0000000..e5ba4f9 --- /dev/null +++ b/miku/plugins/special.lua @@ -0,0 +1,123 @@ +local special = {} + +special.triggers = { + "[Rr][Ii][Cc][Hh] [Bb][Ii][Tt][Cc][Hh]", + "^/[Oo][Ll][Dd]$", + "^[Nn][Yy][Uu]$", + "^[Nn][Oo][Pp][Ee].[Aa][Vv][Ii]$", + "^[Nn][Ii][Ii][Ss][Aa][Nn]$", + "^[Nn][Ii][Ii](-)[Ss][Aa][Nn]$", + "^[Nn][Ii][Ss][Ss][Aa][Nn]$", + "^/[Nn][Ee][Oo][Rr][Aa][Mm][Ee]$", + "^/[Nn][Aa][Uu]$", + "^/[Ff][Tt][Tt]$", + "^/[Ff][Tt][Ff]$", + "^[Mm]ö[Pp]?$", + "^[Mm][Ee][Ee][Pp]$", + "^/[Bb][Aa][Rr][Uu][Ss][Aa][Mm][Ii][Kk][Oo][Ss][Uu]$", + "^/[Bb][Aa][Ll][Ss][Aa][Mm][Ii][Kk][Oo] [Ee][Ss][Ss][Ii][Gg]$", + "^[Bb][Aa][Kk][Aa] [Bb][Oo][Tt]$", + "^[Aa][Hh][Aa].[Pp][Nn][Gg]$", + "^~?[Pp][Oo][Ii]$", + "^/[Tt][Hh][Yy][Mm][Ee]$", + "^[Yy][Oo][Ll][Oo]$", + "^/[Kk][Aa][Pp][Pp][Aa]$", + "[Ii] [Ww][Ii][Ss][Hh] [Ss][Qq][Uu][Ii][Dd][Ss] [Ww][Ee][Rr][Ee] [Rr][Ee][Aa][Ll]", + "^/[Kk][Ii][Ll][Ll] (.*)", + "^[Ii][Nn][Ll][Oo][Vv][Ee]$", + "^[Pp][Ee]$", + "^[Vv][Aa]$", + "^[Mm][Uu]$", + "^/[Ii][Yy][Kk][Ww][Ii][Mm]$" +} + +function special:action(msg, config, matches) + local msg_text = msg.text + local output + + if msg_text:match("[Rr][Ii][Cc][Hh] [Bb][Ii][Tt][Cc][Hh]") then + output = 'Akamaru ist nicht reich!' + elseif msg_text:match("/[Oo][Ll][Dd]") then + output = 'Deine Mudda is old!' + elseif msg_text:match("[Nn][Yy][Uu]") then + utilities.send_photo(msg.chat.id, download_to_file('http://img.ponywave.de/di/JSXH/nyu.jpg'), nil, msg.message_id) + return + elseif msg_text:match("[Nn][Oo][Pp][Ee].[Aa][Vv][Ii]") then + utilities.send_typing(msg.chat.id, 'upload_video') + utilities.send_video(msg.chat.id, download_to_file('https://dl.dropboxusercontent.com/u/32829149/nope.avi'), nil, msg.message_id) + return + elseif msg_text:match("[Nn][Ii][Ii][Ss][Aa][Nn]") or msg_text:match("[Nn][Ii][Ii](-)[Ss][Aa][Nn]") or msg_text:match("[Nn][Ii][Ss][Ss][Aa][Nn]") then + utilities.send_photo(msg.chat.id, download_to_file('http://img.ponywave.de/di/XB2T/Nii-san.jpg'), nil, msg.message_id) + return + elseif msg_text:match("/[Nn][Ee][Oo][Rr][Aa][Mm][Ee]") then + utilities.send_photo(msg.chat.id, download_to_file('http://img.ponywave.de/di/GM93/neorame.jpg'), nil, msg.message_id) + return + elseif msg_text:match("[Nn][Aa][Uu]") then + utilities.send_photo(msg.chat.id, download_to_file('http://img.ponywave.de/di/V1QH/nau.jpg'), nil, msg.message_id) + return + elseif msg_text:match("[Ff][Tt][Tt]") then + output = [[(╯°□°)╯︵ ┻━┻ FLIP THAT TABLE. +┻━┻ ︵ ヽ(°□°ヽ) FLIP THIS TABLE. +┻━┻ ︵ \(`0`)/ ︵ ┻━┻ FLIP ALL THE TABLES +ಠ_ಠ Child. . . +ಠ_ಠ Put. +ಠ__ಠ The tables. +ಠ___ಠ Back. +(╮°-°)╮┳━┳ +(╯°□°)╯︵ ┻━┻ NEVER]] + elseif msg_text:match("[Ff][Tt][Ff]") then + output = [[(╯┳┳)╯︵ ಠ‾ಠ FLIP THAT FATHER. +ಠ‾ಠ ︵ ヽ(┳┳ヽ) FLIP THIS FATHER. +ಠ‾ಠ ︵ \(┳┳)/ ︵ ಠ‾ಠ FLIP ALL THE FATHERS +┳━┳ Child. . . +┳━┳ Put. +┳━━┳ The Fathers. +┳━━━┳ Back. +(╮┳┳)╮ಠ_ಠ +(╯┳┳)╯︵ ಠ‾ಠ NEVER]] + elseif msg_text:match("[Mm]ö[Pp]?") or msg_text:match("[Mm][Ee][Ee][Pp]") then + output = 'se' + elseif msg_text:match("[Bb][Aa][Rr][Uu][Ss][Aa][Mm][Ii][Kk][Oo][Ss][Uu]") or msg_text:match("[Bb][Aa][Ll][Ss][Aa][Mm][Ii][Kk][Oo] [Ee][Ss][Ss][Ii][Gg]") then + utilities.send_photo(msg.chat.id, download_to_file('http://img.ponywave.de/di/0SEY/barusamikosu.jpg'), nil, msg.message_id) + return + elseif msg_text:match("[Bb][Aa][Kk][Aa] [Bb][Oo][Tt]") then + output = 'Gomen\'nasai '..msg.from.first_name..'-sempai 😣' + elseif msg_text:match("[Aa][Hh][Aa].[Pp][Nn][Gg]") then + utilities.send_photo(msg.chat.id, download_to_file('http://img.ponywave.de/di/W97R/aha.png'), nil, msg.message_id) + return + elseif msg_text:match("[Pp][Oo][Ii]") then + utilities.send_document(msg.chat.id, download_to_file('https://dl.dropboxusercontent.com/u/32829149/poi.webp'), nil, msg.message_id) + return + elseif msg_text:match("/[Tt][Hh][Yy][Mm][Ee]") then + utilities.send_photo(msg.chat.id, download_to_file('http://img.ponywave.de/di/N6NO/thyme.jpg'), nil, msg.message_id) + return + elseif msg_text:match("[Yy][Oo][Ll][Oo]") then + output = 'Hä YOLO?' + elseif msg_text:match("/[Kk][Aa][Pp][Pp][Aa]") then + output = [[⠀⠀⠀⠀⣀⣀⣬⣥⣽⣿⣧⣤⢀⠀⠀⠀ +⠀⠀⠀⠂⢯⣧⣿⣿⣿⣿⣿⣿⣿⣿⣷⠀ +⠀⢨⣽⣾⣿⣿⣿⣿⡿⠛⠃⠉⠛⣿⣿⠀ +⠀⠘⣿⣿⣿⡟⠁⠁⠀⠀⠀⠀⠨⣟⢿⠀ +⠀⠀⠩⢿⠀⠀⠶⠾⢿⡿⠉⠿⣿⡿⢟⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⣩⣦⣾⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠠⡦⣺⣿⡿⣹⡏⠀ +⠀⠀⠀⠀⠀⠀⠻⠅⢄⡀⢈⣻⠟⠀⠀⠀]] + elseif msg_text:match("[Ii] [Ww][Ii][Ss][Hh] [Ss][Qq][Uu][Ii][Dd][Ss] [Ww][Ee][Rr][Ee] [Rr][Ee][Aa][Ll]") then + utilities.send_photo(msg.chat.id, download_to_file('http://img.ponywave.de/di/N03B/squid.jpg'), 'They are', msg.message_id) + return + elseif msg_text:match("[Kk][Ii][Ll][Ll]") then + output = msg.first.first_name..' tötet '..matches[1] + elseif msg_text:match("[Pp][Ee]") then + output = 'nis' + elseif msg_text:match("[Vv][Aa]") then + output = 'gina' + elseif msg_text:match("[Mm][Uu]") then + output = 'schi' + elseif msg_text:match("/[Ii][Yy][Kk][Ww][Ii][Mm]") then + output = '(¬‿¬)' + end + + utilities.send_reply(msg, output) +end + +return special \ No newline at end of file diff --git a/miku/plugins/stille.lua b/miku/plugins/stille.lua index a7222a5..bf6aa6f 100644 --- a/miku/plugins/stille.lua +++ b/miku/plugins/stille.lua @@ -10,17 +10,15 @@ stille.triggers = { local stille_hash = 'telegram:stille' function stille:save_stille(text) - local stille = text:sub(11) print('Saving stille to redis set '..stille_hash) - redis:sadd(stille_hash, stille) - return 'Gespeichert: '..stille..'' + redis:sadd(stille_hash, text) + return 'Gespeichert: '..text..'' end function stille:delete_stille(text) - local stille = text:sub(11) print('Deleting stille from redis set '..stille_hash) - if redis:sismember(stille_hash, stille) == true then - redis:srem(stille_hash, stille) + if redis:sismember(stille_hash, text) == true then + redis:srem(stille_hash, text) return 'Zitat erfolgreich gelöscht!' else return 'Dieses Zitat existiert nicht.' @@ -61,11 +59,11 @@ function stille:action(msg, config, matches) return -- Silent Ignore end - if matches[1] == "addstille" and matches[2] then - utilities.send_reply(msg, stille:save_stille(msg.text), 'HTML') + if matches[1] == "addstille" then + utilities.send_reply(msg, stille:save_stille(matches[2]), 'HTML') return - elseif matches[1] == "delstille" and matches[2] then - utilities.send_reply(msg, stille:delete_stille(msg.text), 'HTML') + elseif matches[1] == "delstille" then + utilities.send_reply(msg, stille:delete_stille(matches[2]), 'HTML') return elseif matches[1] == "liststille" then utilities.send_reply(msg, stille:list_stilles())