diff --git a/plugins/change_pic.lua b/plugins/change_pic.lua deleted file mode 100644 index 2a5a5aa..0000000 --- a/plugins/change_pic.lua +++ /dev/null @@ -1,16 +0,0 @@ -function run(msg, matches) -local receiver = get_receiver(msg) -local url = matches[1] -local file = download_to_file(url) -local cb_extra = {file_path=file} - chat_set_photo(receiver, file, ok_cb, false) -end - -return { - description = "", - usage = {"#pic BILDURL"}, - patterns = {"^#pic (.*)$"}, - run = run, - notyping = true -} ---by Akamaru [https://ponywave.de] \ No newline at end of file diff --git a/plugins/create_sticker.lua b/plugins/create_sticker.lua deleted file mode 100644 index 57b6143..0000000 --- a/plugins/create_sticker.lua +++ /dev/null @@ -1,57 +0,0 @@ --- This is a proprietary plugin, property of Andreas Bielawski, (c) 2015 --- DO NOT USE WITHOUT PERMISSION - -do - -local apikey = cred_data.cloudinary_apikey -local api_secret = cred_data.cloudinary_api_secret -local public_id = cred_data.cloudinary_public_id -local BASE_URL = 'https://api.cloudinary.com/v1_1/'..public_id..'/image' - -local function upload_image(file_url) - local timestamp = os.time() - local signature = sha1('timestamp='..timestamp..api_secret) - local upload_url = BASE_URL..'/upload?api_key='..apikey..'&file='..file_url..'×tamp='..timestamp..'&signature='..signature - local res,code = https.request(upload_url) - if code ~= 200 then return "HTTP-FEHLER" end - local data = json:decode(res) - return data.public_id -end - -local function destroy_image(image_id) - local timestamp = os.time() - local signature = sha1('public_id='..image_id..'×tamp='..timestamp..api_secret) - local destroy_url = BASE_URL..'/destroy?api_key='..apikey..'&public_id='..image_id..'×tamp='..timestamp..'&signature='..signature - local res,code = https.request(destroy_url) - if code ~= 200 then print("Lschen fehlgeschlagen") end - local data = json:decode(res) - if data.result == "ok" then - print("Datei von Cloudinary-Server gelscht") - else - print("Lschen fehlgeschlagen") - end -end - -local function run(msg, matches) - if not sha1 then - print('sha1 Library wird zum ersten Mal geladen...') - sha1 = (loadfile "./libs/sha1.lua")() - end - local file_url = matches[1] - local image_id = upload_image(file_url) - local file_url = 'https://res.cloudinary.com/'..public_id..'/image/upload/w_512/'..image_id..'.webp' - local receiver = get_receiver(msg) - send_document_from_url(receiver, file_url, cb_extra) - destroy_image(image_id) -end - -return { - description = "Erstellt einen Sticker on-the-fly.", - usage = "#sticker [Bilder-URL]: Erstelt einen Sticker aus einem Bild", - patterns = { - "^#sticker (https?://[%w-_%.%?%.:/%+=&]+)" - }, - run = run -} - -end \ No newline at end of file diff --git a/plugins/pluginsold/aha.png.lua b/plugins/pluginsold/aha.png.lua deleted file mode 100644 index da9816d..0000000 --- a/plugins/pluginsold/aha.png.lua +++ /dev/null @@ -1,11 +0,0 @@ -function run(msg, matches) - send_photo(get_receiver(msg), "pictures/aha.png", ok_cb, false) -end - -return { - description = "Aha", - usage = {"aha.png"}, - patterns = {"^aha.png$"}, - run = run -} ---by Akamaru [https://ponywave.de] \ No newline at end of file diff --git a/plugins/pluginsold/baka_bot.lua b/plugins/pluginsold/baka_bot.lua deleted file mode 100644 index beeb9fa..0000000 --- a/plugins/pluginsold/baka_bot.lua +++ /dev/null @@ -1,13 +0,0 @@ - -function run(msg, matches) - local user_name = get_name(msg) - return "Gomen'nasai "..user_name.."-sempai 😣" -end - -return { - description = "So ein dummer Bot", - usage = {"Baka Bot","baka bot","Baka bot","baka Bot","BAKA BOT"}, - patterns = {"baka bot","Baka bot","baka Bot","Baka Bot","BAKA BOT"}, - run = run -} ---by Akamaru [https://ponywave.de] \ No newline at end of file diff --git a/plugins/pluginsold/barusamikosu.lua b/plugins/pluginsold/barusamikosu.lua deleted file mode 100644 index 406cb11..0000000 --- a/plugins/pluginsold/barusamikosu.lua +++ /dev/null @@ -1,11 +0,0 @@ -function run(msg, matches) - send_photo(get_receiver(msg), "pictures/luckystar/barusamikosu.jpg", ok_cb, false) -end - -return { - description = "Balsamiko Essig!", - usage = {"/barusamiko","/barusamikosu","/Balsamiko Essig"}, - patterns = {"^/barusamiko","^/barusamikosu","^/Balsamiko Essig"}, - run = run -} ---by Akamaru [https://ponywave.de] \ No newline at end of file diff --git a/plugins/pluginsold/boersedown.lua b/plugins/pluginsold/boersedown.lua deleted file mode 100644 index 0d1e9de..0000000 --- a/plugins/pluginsold/boersedown.lua +++ /dev/null @@ -1,24 +0,0 @@ -socket = require("socket") - -function cron() - -- Use yours desired web and id - local addr = "www.boerse.to" - local dest = "chat#id12345678" - -- Checks a TCP connexion - local connexion = socket.connect(addr, 80) - if not connexion then - local text = "boerse.to ist schon wieder Offline..." - print (text) - send_msg(dest, text, ok_cb, false) - else - connexion:close() - end -end - -return { - description = "Checkt ob Boerse.to online ist", - usage = {"Hierfür gibt es kein Befehl"}, - patterns = {}, - run = nil, - cron = cron -} \ No newline at end of file diff --git a/plugins/pluginsold/bugzilla.lua b/plugins/pluginsold/bugzilla.lua deleted file mode 100644 index ffeeadb..0000000 --- a/plugins/pluginsold/bugzilla.lua +++ /dev/null @@ -1,105 +0,0 @@ -do - -local BASE_URL = "https://bugzilla.mozilla.org/rest/" - -local function bugzilla_login() - local url = BASE_URL.."login?login=" .. _config.bugzilla.username .. "&password=" .. _config.bugzilla.password - print("accessing " .. url) - local res,code = https.request( url ) - local data = json:decode(res) - return data -end - -local function bugzilla_check(id) - -- data = bugzilla_login() - local url = BASE_URL.."bug/" .. id .. "?api_key=" .. _config.bugzilla.apikey - -- print(url) - local res,code = https.request( url ) - local data = json:decode(res) - return data -end - -local function bugzilla_listopened(email) - local url = BASE_URL.."bug?include_fields=id,summary,status,whiteboard,resolution&email1=" .. email .. "&email2=" .. email .. "&emailassigned_to2=1&emailreporter1=1&emailtype1=substring&emailtype2=substring&f1=bug_status&f2=bug_status&n1=1&n2=1&o1=equals&o2=equals&resolution=---&v1=closed&v2=resolved&api_key=" .. _config.bugzilla.apikey - local res,code = https.request( url ) - print(res) - local data = json:decode(res) - return data -end - -local function run(msg, matches) - - local response = "" - - if matches[1] == "status" then - local data = bugzilla_check(matches[2]) - vardump(data) - if data.error == true then - return "Sorry, API failed with message: " .. data.message - else - response = "Bug #"..matches[1]..":\nReporter: "..data.bugs[1].creator - response = response .. "\n Last update: "..data.bugs[1].last_change_time - response = response .. "\n Status: "..data.bugs[1].status.." "..data.bugs[1].resolution - response = response .. "\n Whiteboard: "..data.bugs[1].whiteboard - response = response .. "\n Access: https://bugzilla.mozilla.org/show_bug.cgi?id=" .. matches[1] - print(response) - end - elseif matches[1] == "list" then - local data = bugzilla_listopened(matches[2]) - - vardump(data) - if data.error == true then - return "Sorry, API failed with message: " .. data.message - else - - -- response = "Bug #"..matches[1]..":\nReporter: "..data.bugs[1].creator - -- response = response .. "\n Last update: "..data.bugs[1].last_change_time - -- response = response .. "\n Status: "..data.bugs[1].status.." "..data.bugs[1].resolution - -- response = response .. "\n Whiteboard: "..data.bugs[1].whiteboard - -- response = response .. "\n Access: https://bugzilla.mozilla.org/show_bug.cgi?id=" .. matches[1] - local total = table.map_length(data.bugs) - - print("total bugs: " .. total) - local response = "There are " .. total .. " number of bug(s) assigned/reported by " .. matches[2] - - if total > 0 then - response = response .. ": " - - for tableKey, bug in pairs(data.bugs) do - response = response .. "\n #" .. bug.id - response = response .. "\n Status: " .. bug.status .. " " .. bug.resolution - response = response .. "\n Whiteboard: " .. bug.whiteboard - response = response .. "\n Summary: " .. bug.summary - end - end - end - - end - return response -end - --- (table) --- [bugs] = (table) --- [1] = (table) --- [status] = (string) ASSIGNED --- [id] = (number) 927704 --- [whiteboard] = (string) [approved][full processed] --- [summary] = (string) Budget Request - Arief Bayu Purwanto - https://reps.mozilla.org/e/mozilla-summit-2013/ --- [2] = (table) --- [status] = (string) ASSIGNED --- [id] = (number) 1049337 --- [whiteboard] = (string) [approved][full processed][waiting receipts][waiting report and photos] --- [summary] = (string) Budget Request - Arief Bayu Purwanto - https://reps.mozilla.org/e/workshop-firefox-os-pada-workshop-media-sosial-untuk-perubahan-1/ --- total bugs: 2 - -return { - description = "Lookup bugzilla status update", - usage = "/bot bugzilla [bug number]", - patterns = { - "^/bugzilla (status) (.*)$", - "^/bugzilla (list) (.*)$" - }, - run = run -} - -end \ No newline at end of file diff --git a/plugins/pluginsold/eur.lua b/plugins/pluginsold/eur.lua deleted file mode 100644 index fac860a..0000000 --- a/plugins/pluginsold/eur.lua +++ /dev/null @@ -1,38 +0,0 @@ -do --- TODO: More currencies - --- See http://webrates.truefx.com/rates/connect.html -local function getEURUSD(usd) - local url = 'http://webrates.truefx.com/rates/connect.html?c=EUR/USD&f=csv&s=n' - local res,code = http.request(url) - local rates = res:split(", ") - local symbol = rates[1] - local timestamp = rates[2] - local sell = rates[3]..rates[4] - local buy = rates[5]..rates[6] - local text = symbol..'\n'..'Buy: '..buy..'\n'..'Sell: '..sell - if usd then - local eur = tonumber(usd) / tonumber(buy) - text = text.."\n "..usd.."USD = "..eur.."EUR" - end - return text -end - -local function run(msg, matches) - if matches[1] == "!eur" then - return getEURUSD(nil) - end - return getEURUSD(matches[1]) -end - -return { - description = "Real-time EURUSD market price", - usage = "!eur [USD]", - patterns = { - "^!eur$", - "^!eur (%d+[%d%.]*)$", - }, - run = run -} - -end \ No newline at end of file diff --git a/plugins/pluginsold/facebook.lua b/plugins/pluginsold/facebook.lua deleted file mode 100644 index 5f4e08a..0000000 --- a/plugins/pluginsold/facebook.lua +++ /dev/null @@ -1,40 +0,0 @@ --- This is a proprietary plugin, property of Andreas Bielawski, (c) 2015 --- DO NOT USE WITHOUT PERMISSION - -do - -local BASE_URL = 'https://graph.facebook.com' - -function get_fb_data (fb_code) - local access_token = cred_data.fb_access_token - local url = BASE_URL..'/'..fb_code..'?access_token='..access_token..'&locale=de_DE' - local res,code = https.request(url) - if code ~= 200 then return "HTTP-FEHLER" end - local data = json:decode(res) - return data -end - -function send_fb_data(data, receiver) - local from = data.from.name - local message = data.message - local name = data.name - local link = data.link - local text = from..' hat gepostet:\n'..message..'\n'..name..' '..link - send_msg(receiver, text, ok_cb, false) -end - -function run(msg, matches) - local fb_code = matches[2] - local data = get_fb_data(fb_code) - local receiver = get_receiver(msg) - send_fb_data(data, receiver) -end - -return { - description = "Sendet Facebook-Post.", - usage = {"Link zu einem Facebook-Post"}, - patterns = {"facebook.com/([A-Za-z0-9-_-]+)/posts/([0-9-]+)","facebook.com/permalink.([a-z-]+)%?story_fbid=([0-9-]+)"}, - run = run -} - -end diff --git a/plugins/pluginsold/facebook_photo.lua b/plugins/pluginsold/facebook_photo.lua deleted file mode 100644 index a007728..0000000 --- a/plugins/pluginsold/facebook_photo.lua +++ /dev/null @@ -1,46 +0,0 @@ --- This is a proprietary plugin, property of Andreas Bielawski, (c) 2015 --- DO NOT USE WITHOUT PERMISSION - -do - -local BASE_URL = 'https://graph.facebook.com' - -function get_fbphoto_data (fbphoto_code) - local access_token = cred_data.fb_access_token - local url = BASE_URL..'/'..fbphoto_code..'?access_token='..access_token..'&locale=de_DE' - local res,code = https.request(url) - if code ~= 200 then return "HTTP-FEHLER" end - local data = json:decode(res) - return data -end - -function send_fbphoto_data(data, receiver) - local from = data.from.name - local name = data.name - if name then - text = from..' hat ein Bild gepostet:\n'..name - else - text = from..' hat ein Bild gepostet' - end - local image_url = data.source - local cb_extra = { - receiver=receiver, - url=image_url - } - send_msg(receiver, text, send_photo_from_url_callback, cb_extra) -end - -function run(msg, matches) - local fbphoto_code = matches[3] - local data = get_fbphoto_data(fbphoto_code) - local receiver = get_receiver(msg) - send_fbphoto_data(data, receiver) -end - -return { - description = "Sendet Facebook-Bilder-Post", - usage = "URL zu öffentlichem Facebook-Bild", - patterns = {"facebook.com/([A-Za-z0-9-._-]+)/photos/([A-Za-z0-9-._-]+)/([A-Za-z0-9-._-]+)"}, - run = run -} -end \ No newline at end of file diff --git a/plugins/pluginsold/facebook_video.lua b/plugins/pluginsold/facebook_video.lua deleted file mode 100644 index 166d6e1..0000000 --- a/plugins/pluginsold/facebook_video.lua +++ /dev/null @@ -1,39 +0,0 @@ --- This is a proprietary plugin, property of Andreas Bielawski, (c) 2015 --- DO NOT USE WITHOUT PERMISSION - -do - -local BASE_URL = 'https://graph.facebook.com' - -function get_fbvid_data (fbvid_code) - local access_token = cred_data.fb_access_token - local url = BASE_URL..'/'..fbvid_code..'?access_token='..access_token..'&locale=de_DE' - local res,code = https.request(url) - if code ~= 200 then return "HTTP-FEHLER" end - local data = json:decode(res) - return data -end - -function send_fbvid_data(data, receiver) - local from = data.from.name - local description = data.description - local source = data.source - local text = from..' hat ein Video gepostet:\n'..description..'\n'..source - send_msg(receiver, text, ok_cb, false) -end - -function run(msg, matches) - local fbvid_code = matches[1] - local data = get_fbvid_data(fbvid_code) - local receiver = get_receiver(msg) - send_fbvid_data(data, receiver) -end - -return { - description = "Sendet Facebook-Video.", - usage = {"Link zu einem Video auf Facebook"}, - patterns = {"facebook.com/video.php%?v=([0-9-]+)"}, - run = run -} - -end diff --git a/plugins/pluginsold/forecast.lua b/plugins/pluginsold/forecast.lua deleted file mode 100644 index 3675d04..0000000 --- a/plugins/pluginsold/forecast.lua +++ /dev/null @@ -1,119 +0,0 @@ -do - -local BASE_URL = "http://api.openweathermap.org/data/2.5/forecast/daily" - -local function get_condition_symbol(weather, n) - if weather.list[n].weather[1].main == 'Clear' then - return ' ☀' - elseif weather.list[n].weather[1].main == 'Clouds' then - return ' ☁☁' - elseif weather.list[n].weather[1].main == 'Rain' then - return ' ☔' - elseif weather.list[n].weather[1].main == 'Thunderstorm' then - return ' ☔☔☔☔' - elseif weather.list[n].weather[1].main == 'Snow' then - return ' ❄️' - elseif weather.weather[1].main == 'Fog' then - return ' 🌫' - else - return '' - end -end - -local function get_temp(weather, n) - local day = (round(weather.list[n].temp.day, 1)) - local night = (round(weather.list[n].temp.night, 1)) - local condition = weather.list[n].weather[1].description - return '☀️ '..day..'°C | 🌙 '..night..'°C | '..condition -end - -local function get_forecast(location, days) - print("Bekomme Wettervorhersage für ", location) - local location = string.gsub(location," ","+") - local url = BASE_URL - local apikey = cred_data.owm_apikey - local url = url..'?q='..location - local url = url..'&lang=de&units=metric&cnt='..days..'&APPID='..apikey - - local b, c, h = http.request(url) - if c ~= 200 then return nil end - - local weather = json:decode(b) - local city = weather.city.name - if weather.city.country == "" then - country = '' - else - country = ' ('..weather.city.country..')' - end - local header = 'Vorhersage für '..city..country..':\n' - - local text = 'Heute: '..get_temp(weather, 1)..get_condition_symbol(weather, 1) - - if days > 1 then - text = text..'\nMorgen: '..get_temp(weather, 2)..get_condition_symbol(weather, 2) - end - if days > 2 then - text = text..'\nÜbermorgen: '..get_temp(weather, 3)..get_condition_symbol(weather, 3) - end - - if days > 3 then - for day in pairs(weather.list) do - if day > 3 then - local actual_day = day-1 - text = text..'\n'..actual_day..' Tage: '..get_temp(weather, day)..get_condition_symbol(weather, day) - end - end - end - - return header..text -end - -local function run(msg, matches) - local user_id = msg.from.id - local city = get_location(user_id) - if not city then city = 'Berlin' end - - if tonumber(matches[1]) then - days = matches[1]+1 - else - days = 4 - end - - if matches[2] then - days = matches[1]+1 - city = matches[2] - end - - if not tonumber(matches[1]) and matches[1] ~= '/forecast' then - city = matches[1] - end - - if days > 17 then - return 'Wettervorhersagen gehen nur von 1-16 Tagen!' - end - - local text = get_forecast(city, days) - if not text then - text = 'Konnte die Wettervorhersage für diese Stadt nicht bekommen.' - end - return text -end - -return { - description = "Wettervorhersage für deinen oder einen gewählten Ort", - usage = { - "/forecast: Wettervorhersage für deine Stadt (!location set [Ort])", - "/forecast [0-16]: Wettervorhersage für X Tage für deine Stadt (!location set [Ort])", - "/forecast (Stadt): Wettervorhersage für diese Stadt", - "/forecast [0-16] (Stadt): Wettervorhersage für X Tage für diese Stadt" - }, - patterns = { - "^/forecast$", - "^/forecast (%d+) (.*)$", - "^/forecast (%d+)", - "^/forecast (.*)$" - }, - run = run -} - -end \ No newline at end of file diff --git a/plugins/pluginsold/fortunes_uc3m.lua b/plugins/pluginsold/fortunes_uc3m.lua deleted file mode 100644 index 8dcd46c..0000000 --- a/plugins/pluginsold/fortunes_uc3m.lua +++ /dev/null @@ -1,24 +0,0 @@ -do - -local function get_fortunes_uc3m() - local i = math.random(0,178) -- max 178 - local web = "http://www.gul.es/fortunes/f"..i - local b, c, h = http.request(web) - return b -end - - -local function run(msg, matches) - return get_fortunes_uc3m() -end - -return { - description = "Fortunes from Universidad Carlos III", - usage = "!uc3m", - patterns = { - "^!uc3m$" - }, - run = run -} - -end \ No newline at end of file diff --git a/plugins/pluginsold/frosch.lua b/plugins/pluginsold/frosch.lua deleted file mode 100644 index fc84bb1..0000000 --- a/plugins/pluginsold/frosch.lua +++ /dev/null @@ -1,11 +0,0 @@ -function run(msg, matches) - return '🐸🐸🐸' -end - -return { - description = "🐸🐸🐸", - usage = {"/frosch","/Frosch"}, - patterns = {"^/frosch","^/Frosch"}, - run = run -} ---by Akamaru [https://ponywave.de] \ No newline at end of file diff --git a/plugins/pluginsold/gay.lua b/plugins/pluginsold/gay.lua deleted file mode 100644 index 9954a30..0000000 --- a/plugins/pluginsold/gay.lua +++ /dev/null @@ -1,74 +0,0 @@ -do - -function getGay(text) - local text = URL.escape(text) - local api = "https://ajax.googleapis.com/ajax/services/search/images?v=1.0&rsz=8&q=gay+porn" - local res, code = http.request(api..text) - if code ~= 200 then return nil end - local google = json:decode(res) - - if google.responseStatus ~= 200 then - return nil - end - - local data = google.responseData - - if not data or not data.results then - return nil - end - - if #data.results == 0 then - return nil - end - - -- Random image from table - -- local i = math.random(#data.results) - -- return data.results[i].url - return data.results -end - -function run(msg, matches) - local receiver = get_receiver(msg) - local text = matches[1] - - local results = getGay(text) - if not results then - return "Kein Bild gefunden." - end - local i = math.random(#results) - local url = nil; - - local failed = true - local nofTries = 0 - while failed and nofTries < #results do - url = results[i].url; - print("Bilder-URL: ", url) - - if string.ends(url, ".gif") then - failed = not send_document_from_url(receiver, url, nil, nil, true) - elseif string.ends(url, ".jpg") or string.ends(url, ".jpeg") or string.ends(url, ".png") then - failed = not send_photo_from_url(receiver, url, nil, nil, true) - end - - nofTries = nofTries + 1 - i = i+1 - if i > #results then - i = 1 - end - end - - if failed then - return "Fehler beim Laden des Bildes." - else - return "Source: "..url - end -end - -return { - description = "Sucht Bild mit Google-API und versendet es [NSFW]", - usage = {"/gay"}, - patterns = {"^/gay$"}, - run = run -} -end ---Modified by Akamaru [https://ponywave.de] \ No newline at end of file diff --git a/plugins/pluginsold/get.lua b/plugins/pluginsold/get.lua deleted file mode 100644 index cba79a2..0000000 --- a/plugins/pluginsold/get.lua +++ /dev/null @@ -1,49 +0,0 @@ -local function get_variables_hash(msg) - if msg.to.type == 'chat' then - return 'chat:'..msg.to.id..':variables' - end - if msg.to.type == 'user' then - return 'user:'..msg.from.id..':variables' - end -end - -local function list_variables(msg) - local hash = get_variables_hash(msg) - - if hash then - local names = redis:hkeys(hash) - local text = '' - for i=1, #names do - text = text..names[i]..'\n' - end - return text - end -end - -local function get_value(msg, var_name) - local hash = get_variables_hash(msg) - if hash then - local value = redis:hget(hash, var_name) - if not value then - return'Not found, use "/get" to list variables' - else - return var_name..' => '..value - end - end -end - -local function run(msg, matches) - if matches[2] then - return get_value(msg, matches[2]) - else - return list_variables(msg) - end -end - -return { - description = "Bekommt Variable, die mit /set gesetzt wurde", - usage = {"/get (Variable)"}, - patterns = {"^/get (%a+)$","^/get$"}, - run = run, - pre_process = lex -} diff --git a/plugins/pluginsold/googlethat.lua b/plugins/pluginsold/googlethat.lua deleted file mode 100644 index 713be2d..0000000 --- a/plugins/pluginsold/googlethat.lua +++ /dev/null @@ -1,28 +0,0 @@ --- Need this for wiki.lua -function googlethat(query) - local number = 5 -- Set number of results - local api = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&safe=active&hl=de&rsz="..number.."&" - local parameters = "q=".. (URL.escape(query) or "") - - -- Do the request - local res, code = https.request(api..parameters) - if code ~=200 then return nil end - local data = json:decode(res) - - local results={} - for key,result in ipairs(data.responseData.results) do - table.insert(results, { - result.titleNoFormatting, - result.unescapedUrl or result.url - }) - end - return results -end - -function stringlinks(results) - local stringresults="" - for key,val in ipairs(results) do - stringresults=stringresults..val[1].." - "..val[2].."\n" - end - return stringresults -end \ No newline at end of file diff --git a/plugins/pluginsold/gps.lua b/plugins/pluginsold/gps.lua deleted file mode 100644 index 1cc4347..0000000 --- a/plugins/pluginsold/gps.lua +++ /dev/null @@ -1,28 +0,0 @@ -do - -function run(msg, matches) - local lat = matches[1] - local lon = matches[2] - local receiver = get_receiver(msg) - - local zooms = {16, 18} - local urls = {} - for i = 1, #zooms do - local zoom = zooms[i] - local url = "http://maps.googleapis.com/maps/api/staticmap?zoom=" .. zoom .. "&size=600x300&maptype=roadmap¢er=" .. lat .. "," .. lon .. "&markers=color:blue%7Clabel:X%7C" .. lat .. "," .. lon - table.insert(urls, url) - end - - send_photos_from_url(receiver, urls) - - return "www.google.es/maps/place/@" .. lat .. "," .. lon -end - -return { - description = "generates a map showing the given GPS coordinates", - usage = "!gps latitude,longitude: generates a map showing the given GPS coordinates", - patterns = {"^!gps ([^,]*)[,%s]([^,]*)$"}, - run = run -} - -end \ No newline at end of file diff --git a/plugins/pluginsold/hackernews.lua b/plugins/pluginsold/hackernews.lua deleted file mode 100644 index 284a03f..0000000 --- a/plugins/pluginsold/hackernews.lua +++ /dev/null @@ -1,24 +0,0 @@ -do - -function run(msg, matches) - local result = 'Hacker News Top5:\n' - local top_stories_json, code = https.request('https://hacker-news.firebaseio.com/v0/topstories.json') - if code ~=200 then return nil end - local top_stories = json:decode(top_stories_json) - for i = 1, 5 do - local story_json, code = https.request('https://hacker-news.firebaseio.com/v0/item/'..top_stories[i]..'.json') - if code ~=200 then return nil end - local story = json:decode(story_json) - result = result .. i .. '. ' .. story.title .. ' - ' .. story.url .. '\n' - end - return result -end - -return { - description = "Show top 5 hacker news (ycombinator.com)", - usage = "!hackernews", - patterns = {"^!hackernews$"}, - run = run -} - -end diff --git a/plugins/pluginsold/hello.lua b/plugins/pluginsold/hello.lua deleted file mode 100644 index 706b3d1..0000000 --- a/plugins/pluginsold/hello.lua +++ /dev/null @@ -1,17 +0,0 @@ -do - -function run(msg, matches) - return "Hello, " .. matches[1] -end - -return { - description = "Says hello to someone", - usage = "say hello to [name]", - patterns = { - "^say hello to (.*)$", - "^Say hello to (.*)$" - }, - run = run -} - -end \ No newline at end of file diff --git a/plugins/pluginsold/helpold.lua b/plugins/pluginsold/helpold.lua deleted file mode 100644 index ff18984..0000000 --- a/plugins/pluginsold/helpold.lua +++ /dev/null @@ -1,70 +0,0 @@ -do - --- Returns true if is not empty -local function has_usage_data(dict) - if (dict.usage == nil or dict.usage == '') then - return false - end - return true -end - --- Get commands for that plugin -local function plugin_help(name) - local plugin = plugins[name] - if not plugin then return nil end - - local text = "" - if (type(plugin.usage) == "table") then - for ku,usage in pairs(plugin.usage) do - text = text..usage..'\n' - end - text = text..'\n' - elseif has_usage_data(plugin) then -- Is not empty - text = text..plugin.usage..'\n\n' - end - return text -end - --- !help command -local function telegram_help() - local text = "Plugin Liste: \n\n" - -- Plugins names - for name in pairs(plugins) do - text = text..name..'\n' - end - text = text..'\n'..'Benutze "/hilfe [Plugin Name]" für mehr Informationen' - text = text..'\n'..'Oder "/hilfe all" um alles zu sehen.' - return text -end - --- !help all command -local function help_all() - local ret = "" - for name in pairs(plugins) do - ret = ret .. plugin_help(name) - end - return ret -end - -local function run(msg, matches) - if matches[1] == "/hilfe" then - return telegram_help() - elseif matches[1] == "/hilfe all" then - return help_all() - else - local text = plugin_help(matches[1]) - if not text then - text = telegram_help() - end - return text - end -end - -return { - description = "Zeigt die Plugins und Befehle", - usage = {"/hilfe","/hilfe all","/hilfe [Plugin]"}, - patterns = {"^/hilfe$","^/hilfe all","^/hilfe (.+)"}, - run = run -} - -end \ No newline at end of file diff --git a/plugins/pluginsold/img_google.lua b/plugins/pluginsold/img_google.lua deleted file mode 100644 index dcc654a..0000000 --- a/plugins/pluginsold/img_google.lua +++ /dev/null @@ -1,166 +0,0 @@ -do - -local _blacklist - -local function getGoogleImage(text) - local text = URL.escape(text) - local api = "https://ajax.googleapis.com/ajax/services/search/images?v=1.0&rsz=8&safe=active&q=" - local res, code = http.request(api..text) - if code ~= 200 then return nil end - local google = json:decode(res) - - if google.responseStatus ~= 200 then - return nil - end - - local data = google.responseData - - if not data or not data.results then - return nil - end - - if #data.results == 0 then - return nil - end - - return data.results -end - -local function is_blacklisted(msg) - local var = false - for v,word in pairs(_blacklist) do - if string.find(string.lower(msg), string.lower(word)) then - print("Wort steht auf der Blacklist!") - var = true - break - end - end - return var -end - -local function show_blacklist() - if not _blacklist[1] then - return "Keine Wörter geblacklisted!\nBlackliste welche mit /imgblacklist add [Wort]" - else - local sort_alph = function( a,b ) return a < b end - table.sort( _blacklist, sort_alph ) - local blacklist = "Folgende Wörter stehen auf der Blacklist:\n" - for v,word in pairs(_blacklist) do - blacklist = blacklist..'- '..word..'\n' - end - return blacklist - end -end - -local function add_blacklist() - print('Blacklisting '..word..' - saving to redis set telegram:img_blacklist') - if redis:sismember("telegram:img_blacklist", word) == true then - return '"'..word..'" steht schon auf der Blacklist.' - else - redis:sadd("telegram:img_blacklist", word) - return '"'..word..'" blacklisted!' - end -end - -local function remove_blacklist() - print('De-blacklisting '..word..' - removing from redis set telegram:img_blacklist') - if redis:sismember("telegram:img_blacklist", word) == true then - redis:srem("telegram:img_blacklist", word) - return '"'..word..'" erfolgreich von der Blacklist gelöscht!' - else - return '"'..word..'" steht nicht auf der Blacklist.' - end -end - -local function run(msg, matches) - local receiver = get_receiver(msg) - local text = matches[1] - if matches[2] then word = string.lower(matches[2]) end - - _blacklist = redis:smembers("telegram:img_blacklist") - - if text == "/imgblacklist show" then - if is_sudo(msg) then - return show_blacklist() - else - return "Du bist kein Superuser. Dieser Vorfall wird gemeldet!" - end - end - - if text == "/imgblacklist add" and word == nil then - return "Benutzung: /imgblacklist add [Wort]" - elseif text == "/imgblacklist add" and word then - if is_sudo(msg) then - return add_blacklist() - else - return "Du bist kein Superuser. Dieser Vorfall wird gemeldet!" - end - end - - if text == "/imgblacklist del" and word == nil then - return "Benutzung: /imgblacklist del [Wort]" - elseif text == "/imgblacklist del" and word then - if is_sudo(msg) then - return remove_blacklist() - else - return "Du bist kein Superuser. Dieser Vorfall wird gemeldet!" - end - end - - print ('Checking if search contains blacklisted words: '..text) - if is_blacklisted(text) then - return "Vergiss es ._." - end - - local results = getGoogleImage(text) - if not results then - return "Kein Bild gefunden!" - end - - -- Random image from table - local i = math.random(#results) - local url = nil; - - local failed = true - local nofTries = 0 - while failed and nofTries < #results do - url = results[i].url; - print("Bilder-URL: ", url) - - if string.ends(url, ".gif") then - failed = not send_document_from_url(receiver, url, nil, nil, true) - elseif string.ends(url, ".jpg") or string.ends(url, ".jpeg") or string.ends(url, ".png") then - failed = not send_photo_from_url(receiver, url, nil, nil, true) - end - - nofTries = nofTries + 1 - i = i+1 - if i > #results then - i = 1 - end - end - - if failed then - return "Fehler beim Herunterladen eines Bildes." - else - return "Source: "..url - end -end - -return { - description = "Sucht Bild mit Google-API und versendet es (SafeSearch aktiv)", - usage = { - "/img [Suchbegriff]", - "/imgblacklist show: Zeigt Blacklist (nur Superuser)", - "/imgblacklist add [Wort]: Fügt Wort der Blacklist hinzu (nur Superuser)", - "/imgblacklist del [Wort]: Entfernt Wort aus der Blacklist (nur Superuser)" - }, - patterns = { - "^/img (.*)$", - "^(/imgblacklist show)$", - "^(/imgblacklist add) (.*)$", - "^(/imgblacklist del) (.*)$" - }, - run = run -} -end \ No newline at end of file diff --git a/plugins/pluginsold/img_google_nsfw.lua b/plugins/pluginsold/img_google_nsfw.lua deleted file mode 100644 index 7732690..0000000 --- a/plugins/pluginsold/img_google_nsfw.lua +++ /dev/null @@ -1,161 +0,0 @@ -do - -local _blacklist - -local function getNSFWImage(text) - local text = URL.escape(text) - local api = "https://ajax.googleapis.com/ajax/services/search/images?v=1.0&rsz=8&q=" - local res, code = http.request(api..text) - if code ~= 200 then return nil end - local google = json:decode(res) - - if google.responseStatus ~= 200 then - return nil - end - - local data = google.responseData - - if not data or not data.results then - return nil - end - - if #data.results == 0 then - return nil - end - - return data.results -end - -local function is_blacklisted(msg) - local var = false - for v,word in pairs(_blacklist) do - if string.find(string.lower(msg), string.lower(word)) then - print("Wort steht auf der Blacklist!") - var = true - break - end - end - return var -end - -local function show_blacklist() - if not _blacklist[1] then - return "Keine Wörter geblacklisted!\nBlackliste welche mit /imgblacklist add [Wort]" - else - local sort_alph = function( a,b ) return a < b end - table.sort( _blacklist, sort_alph ) - local blacklist = "Folgende Wörter stehen auf der Blacklist:\n" - for v,word in pairs(_blacklist) do - blacklist = blacklist..'- '..word..'\n' - end - return blacklist - end -end - -local function add_blacklist() - print('Blacklisting '..word..' - saving to redis set telegram:img_blacklist') - if redis:sismember("telegram:img_blacklist", word) == true then - return '"'..word..'" steht schon auf der Blacklist.' - else - redis:sadd("telegram:img_blacklist", word) - return '"'..word..'" blacklisted!' - end -end - -local function remove_blacklist() - print('De-blacklisting '..word..' - removing from redis set telegram:img_blacklist') - if redis:sismember("telegram:img_blacklist", word) == true then - redis:srem("telegram:img_blacklist", word) - return '"'..word..'" erfolgreich von der Blacklist gelöscht!' - else - return '"'..word..'" steht nicht auf der Blacklist.' - end -end - -local function run(msg, matches) - local receiver = get_receiver(msg) - local text = matches[1] - if matches[2] then word = string.lower(matches[2]) end - - _blacklist = redis:smembers("telegram:img_blacklist") - - if text == "/imgblacklist show" then - if is_sudo(msg) then - return show_blacklist() - else - return "Du bist kein Superuser. Dieser Vorfall wird gemeldet!" - end - end - - if text == "/imgblacklist add" and word == nil then - return "Benutzung: /imgblacklist add [Wort]" - elseif text == "/imgblacklist add" and word then - if is_sudo(msg) then - return add_blacklist() - else - return "Du bist kein Superuser. Dieser Vorfall wird gemeldet!" - end - end - - if text == "/imgblacklist del" and word == nil then - return "Benutzung: /imgblacklist del [Wort]" - elseif text == "/imgblacklist del" and word then - if is_sudo(msg) then - return remove_blacklist() - else - return "Du bist kein Superuser. Dieser Vorfall wird gemeldet!" - end - end - - print ('Checking if search contains blacklisted words: '..text) - if is_blacklisted(text) then - return "Vergiss es ._." - end - - local results = getNSFWImage(text) - if not results then - return "Kein Bild gefunden!" - end - - -- Random image from table - local i = math.random(#results) - local url = nil; - - local failed = true - local nofTries = 0 - while failed and nofTries < #results do - url = results[i].url; - print("Bilder-URL: ", url) - - if string.ends(url, ".gif") then - failed = not send_document_from_url(receiver, url, nil, nil, true) - elseif string.ends(url, ".jpg") or string.ends(url, ".jpeg") or string.ends(url, ".png") then - failed = not send_photo_from_url(receiver, url, nil, nil, true) - end - - nofTries = nofTries + 1 - i = i+1 - if i > #results then - i = 1 - end - end - - if failed then - return "Fehler beim Herunterladen eines Bildes." - else - return "Source: "..url - end -end - -return { - description = "Sucht Bild mit Google-API und versendet es [NSFW]", - usage = {"/img2 [Suchbegriff]","/nsfwimg [Suchbegriff]"}, - patterns = {"^/img2 (.*)$", - "^/nsfwimg (.*)$"--[[, - "^(/imgblacklist show)$", - "^(/imgblacklist add) (.*)$", - "^(/imgblacklist del) (.*)$"]] - }, - run = run -} -end \ No newline at end of file diff --git a/plugins/pluginsold/invite.lua b/plugins/pluginsold/invite.lua deleted file mode 100644 index f1398c8..0000000 --- a/plugins/pluginsold/invite.lua +++ /dev/null @@ -1,48 +0,0 @@ --- Invite other user to the chat group. --- Use !invite name User_name or !invite id id_number --- The User_name is the print_name (there are no spaces but _) - -do - -local function callback(extra, success, result) - vardump(success) - vardump(result) -end - -local function run(msg, matches) - local user = matches[2] - - -- User submitted a user name - if matches[1] == "name" then - user = string.gsub(user," ","_") - end - - -- User submitted an id - if matches[1] == "id" then - user = 'user#id'..user - end - - -- The message must come from a chat group - if msg.to.type == 'chat' then - local chat = 'chat#id'..msg.to.id - chat_add_user(chat, user, callback, false) - return "Add: "..user.." to "..chat - else - return 'This isnt a chat group!' - end - -end - -return { - description = "Invite other user to the chat group", - usage = { - "!invite name [user_name]", - "!invite id [user_id]" }, - patterns = { - "^!invite (name) (.*)$", - "^!invite (id) (%d+)$" - }, - run = run -} - -end \ No newline at end of file diff --git a/plugins/pluginsold/location.lua b/plugins/pluginsold/location.lua deleted file mode 100644 index 23663db..0000000 --- a/plugins/pluginsold/location.lua +++ /dev/null @@ -1,61 +0,0 @@ --- Implement a command !loc [area] which uses --- the static map API to get a location image - --- Not sure if this is the proper way --- Intent: get_latlong is in time.lua, we need it here --- loadfile "time.lua" - --- Globals --- If you have a google api key for the geocoding/timezone api -do - -local api_key = nil - -local base_api = "https://maps.googleapis.com/maps/api" - -function get_staticmap(area) - local api = base_api .. "/staticmap?" - - -- Get a sense of scale - local lat,lng,acc,types = get_latlong(area) - - local scale = types[1] - if scale=="locality" then zoom=8 - elseif scale=="country" then zoom=4 - else zoom = 13 end - - local parameters = - "size=600x300" .. - "&zoom=" .. zoom .. - "¢er=" .. URL.escape(area) .. - "&markers=color:red"..URL.escape("|"..area) - - if api_key ~=nil and api_key ~= "" then - parameters = parameters .. "&key="..api_key - end - return lat, lng, api..parameters -end - - -function run(msg, matches) - local receiver = get_receiver(msg) - local lat,lng,url = get_staticmap(matches[1]) - - -- Send the actual location, is a google maps link - send_location(receiver, lat, lng, ok_cb, false) - - -- Send a picture of the map, which takes scale into account - send_photo_from_url(receiver, url) - - -- Return a link to the google maps stuff is now not needed anymore - return nil -end - -return { - description = "Gets information about a location, maplink and overview", - usage = "!loc (location): Gets information about a location, maplink and overview", - patterns = {"^!loc (.*)$"}, - run = run -} - -end \ No newline at end of file diff --git a/plugins/pluginsold/magic8ball.lua b/plugins/pluginsold/magic8ball.lua deleted file mode 100644 index 7d62c71..0000000 --- a/plugins/pluginsold/magic8ball.lua +++ /dev/null @@ -1,22 +0,0 @@ -do - -function run(msg, matches) - local answers = {'It is certain','It is decidedly so','Without a doubt', - 'Yes definitely','You may rely on it','As I see it, yes', - 'Most likely','Outlook good','Yes','Signs point to yes', - 'Reply hazy try again','Ask again later', - 'Better not tell you now','Cannot predict now', - 'Concentrate and ask again','Don\'t count on it', - 'My reply is no','My sources say no','Outlook not so good', - 'Very doubtful'} - return answers[math.random(#answers)] -end - -return { - description = "Magic 8Ball", - usage = "!magic8ball", - patterns = {"^!magic8ball"}, - run = run -} - -end diff --git a/plugins/pluginsold/miiverse.lua b/plugins/pluginsold/miiverse.lua deleted file mode 100644 index 4b52fa8..0000000 --- a/plugins/pluginsold/miiverse.lua +++ /dev/null @@ -1,89 +0,0 @@ --- This is a proprietary plugin, property of Andreas Bielawski, (c) 2015 --- DO NOT USE WITHOUT PERMISSION - -do - --- TODO: Language selector (for e.g. this post: https://miiverse.nintendo.net/posts/AYMHAAACAAADVHkSrNJ-9Q) --- - -local function get_miiverse_data(res, post) - username = string.match(res, "

(.-)") - userid = string.match(res, "(.-)") - timestamp = string.match(res, "(.-)") - if string.starts(timestamp, 'Vor') then - timestamp = string.gsub(timestamp, "Vor","") - timestamp = "vor"..timestamp - else - timestamp = "am "..timestamp - end - community = string.match(res, "

(.-)
") - --community = string.gsub(community, "™","") - yeahs = string.match(res, "(.-)") - if yeahs == "1" then yeahs = "1 Yeah" else yeahs = yeahs.." Yeahs" end - replys = string.match(res, "(.-)") - if replys == "1" then replys = "1 Kommentar" else replys = replys.." Kommentaren" end - youtube_link = string.match(res, "