Lösche ungenutzte/unnötige/defekte Plugins

This commit is contained in:
Akamaru 2016-07-07 21:26:36 +02:00
parent f53481f8de
commit d612fade97
62 changed files with 0 additions and 3076 deletions

View File

@ -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]

View File

@ -1,57 +0,0 @@
-- This is a proprietary plugin, property of Andreas Bielawski, (c) 2015 <andi (dot) b (at) outlook (dot) de>
-- 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..'&timestamp='..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..'&timestamp='..timestamp..api_secret)
local destroy_url = BASE_URL..'/destroy?api_key='..apikey..'&public_id='..image_id..'&timestamp='..timestamp..'&signature='..signature
local res,code = https.request(destroy_url)
if code ~= 200 then print("Löschen fehlgeschlagen") end
local data = json:decode(res)
if data.result == "ok" then
print("Datei von Cloudinary-Server gelöscht")
else
print("Löschen 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

View File

@ -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]

View File

@ -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]

View File

@ -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]

View File

@ -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
}

View File

@ -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

View File

@ -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

View File

@ -1,40 +0,0 @@
-- This is a proprietary plugin, property of Andreas Bielawski, (c) 2015 <andi (dot) b (at) outlook (dot) de>
-- 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

View File

@ -1,46 +0,0 @@
-- This is a proprietary plugin, property of Andreas Bielawski, (c) 2015 <andi (dot) b (at) outlook (dot) de>
-- 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

View File

@ -1,39 +0,0 @@
-- This is a proprietary plugin, property of Andreas Bielawski, (c) 2015 <andi (dot) b (at) outlook (dot) de>
-- 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

View File

@ -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

View File

@ -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

View File

@ -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]

View File

@ -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]

View File

@ -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
}

View File

@ -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

View File

@ -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&center=" .. 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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 ..
"&center=" .. 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

View File

@ -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

View File

@ -1,89 +0,0 @@
-- This is a proprietary plugin, property of Andreas Bielawski, (c) 2015 <andi (dot) b (at) outlook (dot) de>
-- DO NOT USE WITHOUT PERMISSION
do
-- TODO: Language selector (for e.g. this post: https://miiverse.nintendo.net/posts/AYMHAAACAAADVHkSrNJ-9Q)
-- <iframe class="youtube-player" type="text/html" width="490" height="276" src="https://www.youtube.com/embed/2kB7tUD-MJk?rel=0&amp;modestbranding=1&amp;iv_load_policy=3" frameborder="0"></iframe></div>
local function get_miiverse_data(res, post)
username = string.match(res, "<p class%=\"user%-name\"><a href=\".-\">(.-)</a>")
userid = string.match(res, "<span class%=\"user%-id\">(.-)</span>")
timestamp = string.match(res, "<span class%=\"timestamp\">(.-)</span>")
if string.starts(timestamp, 'Vor') then
timestamp = string.gsub(timestamp, "Vor","")
timestamp = "vor"..timestamp
else
timestamp = "am "..timestamp
end
community = string.match(res, "<div id%=\"page%-title\">(.-)</div>")
--community = string.gsub(community, "™","")
yeahs = string.match(res, "<span class%=\"empathy%-count\">(.-)</span>")
if yeahs == "1" then yeahs = "1 Yeah" else yeahs = yeahs.." Yeahs" end
replys = string.match(res, "<span class%=\"reply%-count\">(.-)</span>")
if replys == "1" then replys = "1 Kommentar" else replys = replys.." Kommentaren" end
youtube_link = string.match(res, "<iframe class%=\"youtube%-player\" .- src=\"(.-)\" frameborder")
if youtube_link == nil then youtube_link = '' end
if post ~= '' and youtube_link ~= nil then youtube_link = ' '..youtube_link end
end
local function get_miiverse_post(miiverse_postid, receiver)
local url = 'https://miiverse.nintendo.net/posts/'..miiverse_postid
local respbody = {}
local options = {
url = url,
sink = ltn12.sink.table(respbody),
headers = {["Accept-Language"] = "de-de",},
}
local response = {https.request(options)}
local code = response[2]
local res = table.concat(respbody)
if code ~= 200 then return "Fehler beim Abrufen vom Miiverse" end
local post = string.match(res, "<p class%=\"post%-content%-text.-\">(.-)<div class%=\"post%-meta\">")
if post == nil then
local memo = string.match(res, "<p class%=\"post%-content%-memo\"><img src%=\"(.-)\" class=\"post%-memo\"")
if memo ~= nil then
post = ''
local file = download_to_file(memo)
local cb_extra = {file_path=file}
send_photo(receiver, file, rmtmp_cb, cb_extra)
else
post = 'Fehler! Miiverse-Post konnte nicht abgerufen werden.'
end
else
post = string.gsub(post, "</p>","")
post = string.gsub(post, "<p class.->","")
post = unescape(post)
end
get_miiverse_data(res, post)
local text = username..' ('..userid..') '..timestamp..' in "'..community..'" mit ' ..yeahs..' und '..replys..'\n\n'..post..youtube_link
local photo = string.match(res, "<div class%=\"screenshot%-container still%-image\"><img src%=\"(.-)\"></div>")
if photo ~= nil then
local image_url = photo
local cb_extra = {
receiver=receiver,
url=image_url
}
send_msg(receiver, text, send_photo_from_url_callback, cb_extra)
else
send_msg(receiver, text, ok_cb, false)
end
end
local function run(msg, matches)
local miiverse_postid = matches[1]
local receiver = get_receiver(msg)
get_miiverse_post(miiverse_postid, receiver)
end
return {
description = "Postet Miiverse-Post",
usage = "Miiverse-Link: Postet Miiverse-Post",
patterns = {"miiverse.nintendo.net/posts/([A-Za-z0-9-_-]+)"},
run = run
}
end

View File

@ -1,11 +0,0 @@
function run(msg, matches)
return 'se'
end
return {
description = "Möpse? Meepse?",
usage = {"möp","Möp","meep","Meep"},
patterns = {"^möp$","Möp$","meep$","Meep$"},
run = run
}
--by Akamaru [https://ponywave.de]

View File

@ -1,40 +0,0 @@
function getAnime(query)
local number = 1 -- Set number of results
local api = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&safe=active&hl=de&rsz="..number.."&q=site%3Amyanimelist.net"
local parameters = "+".. (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
function run(msg, matches)
local results = getAnime(matches[1])
return stringlinks(results)
end
return {
description = "",
usage = {"/myanimelist [Anime]","/mal [Anime]"},
patterns = {"^/myanimelist (.*)$","^/mal (.*)$"},
run = run
}
--Modified by Akamaru [https://ponywave.de]

View File

@ -1,11 +0,0 @@
function run(msg, matches)
send_photo(get_receiver(msg), "pictures/nau.jpg", ok_cb, false)
end
return {
description = "RTL Nau",
usage = {"/nau","/now"},
patterns = {"^/nau$","^/now$"},
run = run
}
--by Akamaru [https://ponywave.de]

View File

@ -1,11 +0,0 @@
function run(msg, matches)
send_photo(get_receiver(msg), "pictures/neorame.jpg", ok_cb, false)
end
return {
description = "NeoRame is best pony!",
usage = {"/neorame"},
patterns = {"^/neorame"},
run = run
}
--by Akamaru [https://ponywave.de]

View File

@ -1,11 +0,0 @@
function run(msg, matches)
send_photo(get_receiver(msg), "pictures/Nii-san.jpg", ok_cb, false)
end
return {
description = "Nii-san <3",
usage = {"nii-san","Nii-san","nissan","Nissan"},
patterns = {"^nii-san$","^Nii-san$","^nissan$","^Nissan$"},
run = run
}
--by Akamaru [https://ponywave.de]

View File

@ -1,12 +0,0 @@
function run(msg, matches)
send_video(get_receiver(msg), "videos/nope.avi", ok_cb, false)
return 'Video wird gesendet...'
end
return {
description = 'Sendet ein Video namens "nope.avi"',
usage = {"nope.avi"},
patterns = {"^nope.avi"},
run = run
}
--by Akamaru [https://ponywave.de]

View File

@ -1,11 +0,0 @@
function run(msg, matches)
send_photo(get_receiver(msg), "pictures/nyu.jpg", ok_cb, false)
end
return {
description = "Nyu?",
usage = {"nyu"},
patterns = {"^[N|n][Y|y][U|u]$"},
run = run
}
--by Akamaru [https://ponywave.de]

View File

@ -1,11 +0,0 @@
function run(msg, matches)
return 'Deine Mudda is old!'
end
return {
description = "",
usage = {"#old"},
patterns = {"^#old$","^.#old$"},
run = run
}
--by Akamaru [https://ponywave.de]

View File

@ -1,32 +0,0 @@
local helpers = require "OAuth.helpers"
local url = "http://pili.la/api.php"
local function run(msg, matches)
local url_req = matches[1]
local request = {
url = url_req
}
local url = url .. "?" .. helpers.url_encode_arguments(request)
local res, code = http.request(url)
if code ~= 200 then
return "Sorry, can't connect"
end
return res
end
return {
description = "Shorten an URL with the awesome http://pili.la",
usage = {
"!pili [url]: Shorten the URL"
},
patterns = {
"^!pili (https?://[%w-_%.%?%.:/%+=&]+)$"
},
run = run
}

View File

@ -1,92 +0,0 @@
-- This is a proprietary plugin, property of Andreas Bielawski, (c) 2015 <andi (dot) b (at) outlook (dot) de>
-- DO NOT USE WITHOUT PERMISSION
do
local xml = require("xml")
local BASE_URL = 'http://yagyuu.local:32400'
local function delete_tags(str)
str = string.gsub( str, '<br />', '')
str = string.gsub( str, '%[i%]', '')
str = string.gsub( str, '%[/i%]', '')
str = string.gsub( str, '&mdash;', '')
return str
end
local makeOurDate = function(dateString)
local pattern = "(%d+)%-(%d+)%-(%d+)"
local year, month, day = dateString:match(pattern)
return day..'.'..month..'.'..year
end
local function get_info(tags)
local url = BASE_URL..'/search?query='..tags
local res,code = http.request(url)
if code ~= 200 then return "HTTP-Fehler" end
local result = xml.load(res)
return result
end
local function send_data(result, receiver)
--[[ local title = xml.find(result, 'Video', 'title')[1]
if xml.find(result, 'Video', 'parentIndex')[1] then
season = 'S'..xml.find(result, 'Video', 'parentIndex')[1]
else
season = ''
end
if xml.find(result, 'Video', 'index')[1] then
episode = 'E'..xml.find(result, 'Video', 'index')[1]
else
episode = ''
end
if xml.find(result, 'Video', 'originallyAvailableAt')[1] ~= "0000-00-00" then
date = 'Ausstrahlung: '..makeOurDate(xml.find(result, 'Video', 'originallyAvailableAt')[1])
else
date = ''
end
if xml.find(result, 'Video', 'summary')[1] then
desc = '\n'..unescape(delete_tags(string.sub(xml.find(result, 'Video', 'summary')[1], 1, 200)))..'...'
else
desc = ''
end
local text = title..' ('..season..episode..')\n'..date..'\n\n'..desc]]
if xml.find(result, 'thumb') then
local image_url = BASE_URL..xml.find(result, 'thumb')[1]
local cb_extra = {
receiver=receiver,
url=image_url
}
send_msg(receiver, text, send_photo_from_url_callback, cb_extra)
else
send_msg(receiver, text, ok_cb, false)
end
end
local function run(msg, matches)
local tags = URL.escape(matches[1])
local receiver = get_receiver(msg)
local info = get_info(tags)
if info == "HTTP-Fehler" then
return "Nichts gefunden!"
else
send_data(info, receiver)
end
end
return {
description = "",
usage = "",
patterns = {"^/plex (.*)$"
},
run = run
}
end

View File

@ -1,39 +0,0 @@
local function googlethat(query)
query = "site:pornhub.com" .. query
local api = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&"
local parameters = "q=".. (URL.escape(query))
-- 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
local function stringlinks(results)
local stringresults=""
for key,val in ipairs(results) do
stringresults=stringresults..val[1].." - "..val[2].."\n"
end
return stringresults
end
local function run(msg, matches)
local results = googlethat(matches[1])
return stringlinks(results)
end
return {
description = "Sendet ein PornHub Video",
usage = {"/pornhub [Begriff]","/ph [Begriff]"},
patterns = {"^/pornhub(.*)$","^/ph(.*)$"},
run = run
}

View File

@ -1,65 +0,0 @@
local quotes_file = './data/quotes.lua'
local quotes_table
function read_quotes_file()
local f = io.open(quotes_file, "r+")
if f == nil then
print ('Erstelle neue Zitat Datei '..quotes_file)
serialize_to_file({}, quotes_file)
else
print ('Zitate geladen: '..quotes_file)
f:close()
end
return loadfile (quotes_file)()
end
function save_quote(msg)
local to_id = tostring(msg.to.id)
if msg.text:sub(11):isempty() then
return "Verwendung: /addquote [Text]"
end
if quotes_table == nil then
quotes_table = {}
end
if quotes_table[to_id] == nil then
print ('Neuer quote key to_id: '..to_id)
quotes_table[to_id] = {}
end
local quotes = quotes_table[to_id]
quotes[#quotes+1] = msg.text:sub(11)
serialize_to_file(quotes_table, quotes_file)
return "Neues Zitat hinzugefügt!"
end
function get_quote(msg)
local to_id = tostring(msg.to.id)
local quotes_phrases
quotes_table = read_quotes_file()
quotes_phrases = quotes_table[to_id]
return quotes_phrases[math.random(1,#quotes_phrases)]
end
function run(msg, matches)
if string.match(msg.text, "/quote$") then
return get_quote(msg)
elseif string.match(msg.text, "/addquote (.+)$") then
quotes_table = read_quotes_file()
return save_quote(msg)
end
end
return {
description = "Speichert Zitate",
usage = {"/addquote [Text]","/quote",},
patterns = {"^/addquote (.+)$","^/quote$",},
run = run
}

View File

@ -1,65 +0,0 @@
do
function getDulcinea( text )
-- Powered by https://github.com/javierhonduco/dulcinea
local api = "http://dulcinea.herokuapp.com/api/?query="
local query_url = api..text
local b, code = http.request(query_url)
if code ~= 200 then
return "Error: HTTP Connection"
end
dulcinea = json:decode(b)
if dulcinea.status == "error" then
return "Error: " .. dulcinea.message
end
while dulcinea.type == "multiple" do
text = dulcinea.response[1].id
b = http.request(api..text)
dulcinea = json:decode(b)
end
local text = ""
local responses = #dulcinea.response
if responses == 0 then
return "Error: 404 word not found"
end
if (responses > 5) then
responses = 5
end
for i = 1, responses, 1 do
text = text .. dulcinea.response[i].word .. "\n"
local meanings = #dulcinea.response[i].meanings
if (meanings > 5) then
meanings = 5
end
for j = 1, meanings, 1 do
local meaning = dulcinea.response[i].meanings[j].meaning
text = text .. meaning .. "\n\n"
end
end
return text
end
function run(msg, matches)
return getDulcinea(matches[1])
end
return {
description = "Spanish dictionary",
usage = "!rae [word]: Search that word in Spanish dictionary.",
patterns = {"^!rae (.*)$"},
run = run
}
end

View File

@ -1,14 +0,0 @@
function run(msg, matches)
plugins = {}
load_plugins()
return 'Plugins erfolgreich geladen!'
end
return {
description = "Läd die Plugins neu",
usage = {"/reload (kann nur Akamaru)"},
patterns = {"^/reload$"},
run = run,
privileged = true,
notyping = true
}

View File

@ -1,11 +0,0 @@
function run(msg, matches)
return 'Akamaru ist nicht reich!'
end
return {
description = "Sagt euch dass Akamaru nicht reich ist",
usage = {"Rich Bitch","rich bitch","rich Bitch","Rich bitch","RICH BITCH"},
patterns = {"^Rich Bitch$","^rich bitch$","^rich Bitch$","^Rich bitch$","^RICH BITCH$"},
run = run
}
--by Akamaru [https://ponywave.de]

View File

@ -1,44 +0,0 @@
do
local ROLL_USAGE = "!roll d<sides>|<count> d<sides>"
local DEFAULT_SIDES = 100
local DEFAULT_NUMBER_OF_DICE = 1
local MAX_NUMBER_OF_DICE = 100
function run(msg, matches)
local str = matches[1]
local sides = DEFAULT_SIDES
local number_of_dice = DEFAULT_NUMBER_OF_DICE
if str:find("!roll%s+d%d+%s*$") then
sides = tonumber(str:match("[^d]%d+%s*$"))
elseif str:find("!roll%s+%d+d%d+%s*$") then
number_of_dice = tonumber(str:match("%s+%d+"))
sides = tonumber(str:match("%d+%s*$"))
end
if number_of_dice > MAX_NUMBER_OF_DICE then
number_of_dice = MAX_NUMBER_OF_DICE
end
local padding = #string.format("%d", sides)
local results = ""
local fmt = "%s %0"..padding.."d"
for i=1,number_of_dice do
results = string.format(fmt, results, math.random(sides))
end
return string.format("Rolling %dd%d:\n%s", number_of_dice, sides, results)
end
return {
description = "Roll some dice!",
usage = ROLL_USAGE,
patterns = {
"^!roll%s*.*"
},
run = run
}
end

View File

@ -1,84 +0,0 @@
-- This is a proprietary plugin, property of Andreas Bielawski, (c) 2015 <andi (dot) b (at) outlook (dot) de>
-- DO NOT USE WITHOUT PERMISSION
-- DIES IST EINE PREVIEW!
-- Ok Leute, ich zeig euch mal, wie der Hase läuft:
-- 1. Erstelle die Datei data/feeds.lua
-- 2. Paste das rein: https://wiidatabase.de/paste/?0772d759b7b49773#7ubf6C8IP78JoafaPK/XrnhhL03cvDgIUCQULTQNYIs=
-- 3. Du kannst mehr Feeds hinzufügen - mehr Feeds gehen mehr auf die Perfomance und können schnell nerven, also vorsicht! Ich empfehle 2-3
-- (die Feeds und Feednamen kannst du natürlich beliebig verändern, vergiss nicht, dass das Komma hinter dem letzten Feed weg muss!)
-- 4. Erstelle die Datei data/feeddata.lua
-- 5. Paste das rein: https://wiidatabase.de/paste/?87e36c6a5e2ae337#SGE2KLMJL1+oJ8gmLhHav4WxMqU1gYvIyWZxXJQHg7k=
-- 6. Ersetze die Variablen ("wiidatabase", "heise") durch deine Variablen aus der feeds.lua. Zwischen den '' sollte nichts stehen
-- 7. Ändere hier deine IP und die chat#id
-- 8. Starte den Bot, er holt sich die Feeds und schreibt deine feeddata.lua neu
do
local socket = require('socket')
local _file_feeddata = './data/feeddata.lua'
function get_feed_data(feed_url)
-- You don't need any IP, but Google won't block you, if you provide one!
local userip = '84.144.215.197' -- plz change to your IP or leave blank
local url = 'https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q='..feed_url..'&hl=de&num=1&userip='..userip
local res,code = https.request(url)
if code ~= 200 then return "HTTP-FEHLER" end
local data = json:decode(res).responseData.feed
return data
end
function unescape(str)
str = string.gsub( str, '&lt;', '<' )
str = string.gsub( str, '&gt;', '>' )
str = string.gsub( str, '&quot;', '"' )
str = string.gsub( str, '&apos;', "'" )
str = string.gsub( str, '&#(%d+);', function(n) return string.char(n) end )
str = string.gsub( str, '&#x(%d+);', function(n) return string.char(tonumber(n,16)) end )
str = string.gsub( str, '&amp;', '&' ) -- Be sure to do this after all others
return str
end
function check_feed(msg, matches)
local dest = "chat#id9587278" -- Plz change this, you can find your group id with "chat_info GROUP_NAME"
local _file_rss = loadfile ("./data/feeddata.lua")()
local _file_feeds = loadfile ("./data/feeds.lua")()
feeddata = io.open(_file_feeddata, "w")
feeddata:write("do local _ = {\n")
-- loop through feeds.lua
for int_feedname, feed_url in pairs(_file_feeds) do
local data = get_feed_data(feed_url)
print(data.title)
print('Erhalten: '..data.entries[1].link)
print('Gespeichert: '.._file_rss[int_feedname]..'\n')
if data.entries[1].link ~= _file_rss[int_feedname] then
local link = data.entries[1].link
local feed_title = data.title
local title = data.entries[1].title
local content = string.sub(unescape(data.entries[1].content:gsub("%b<>", "")), 1, 250) .. '...'
local text = title..'\n'..content..'\n\n -- '..link..' ('..feed_title..')'
send_msg(dest, text, ok_cb, false)
feeddata:write(" "..int_feedname.." = '"..link.."',\n")
else
-- //TODO: find a better way to rewrite lua when the feed is not updated
feeddata:write(" "..int_feedname.." = '"..data.entries[1].link.."',\n") -- ew, I hate this workaround
end
end
feeddata:write(" Ende = Ende\n") -- Dirty hack, remember me to not show this to anybody
feeddata:write("}\nreturn _\nend")
feeddata:close()
end
return {
description = "Sendet RSS-Feeds (public preview)",
usage = "",
patterns = {},
run = run,
cron = check_feed
}
end

View File

@ -1,68 +0,0 @@
local add_user_cfg = load_from_file('data/add_user_cfg.lua')
local function template_add_user(base, to_username, from_username, chat_name, chat_id)
base = base or ''
to_username = '@' .. (to_username or '')
from_username = '@' .. (from_username or '')
chat_name = chat_name or ''
chat_id = "chat#id" .. (chat_id or '')
if to_username == "@" then
to_username = ''
end
if from_username == "@" then
from_username = ''
end
base = string.gsub(base, "{to_username}", to_username)
base = string.gsub(base, "{from_username}", from_username)
base = string.gsub(base, "{chat_name}", chat_name)
base = string.gsub(base, "{chat_id}", chat_id)
return base
end
function chat_new_user_link(msg)
local pattern = add_user_cfg.initial_chat_msg
local to_username = msg.from.username
local from_username = '[link](@' .. (msg.action.link_issuer.username or '') .. ')'
local chat_name = msg.to.print_name
local chat_id = msg.to.id
pattern = template_add_user(pattern, to_username, from_username, chat_name, chat_id)
if pattern ~= '' then
local receiver = get_receiver(msg)
send_msg(receiver, pattern, ok_cb, false)
end
end
function chat_new_user(msg)
local pattern = add_user_cfg.initial_chat_msg
local to_username = msg.action.user.username
local from_username = msg.from.username
local chat_name = msg.to.print_name
local chat_id = msg.to.id
pattern = template_add_user(pattern, to_username, from_username, chat_name, chat_id)
if pattern ~= '' then
local receiver = get_receiver(msg)
send_msg(receiver, pattern, ok_cb, false)
end
end
local function run(msg, matches)
if not msg.service then
return "Are you trying to troll me?"
end
if matches[1] == "chat_add_user" then
chat_new_user(msg)
elseif matches[1] == "chat_add_user_link" then
chat_new_user_link(msg)
end
end
return {
description = "Service plugin that sends a custom message when an user enters a chat.",
usage = "",
patterns = {
"^!!tgservice (chat_add_user)$",
"^!!tgservice (chat_add_user_link)$"
},
run = run
}

View File

@ -1,18 +0,0 @@
local function run(msg, matches)
-- avoid this plugins to process user messages
if not msg.service then
-- return "Are you trying to troll me?"
return nil
end
print("Service message received: " .. matches[1])
end
return {
description = "Template for service plugins",
usage = "",
patterns = {
"^!!tgservice (.*)$" -- Do not use the (.*) match in your service plugin
},
run = run
}

View File

@ -1,30 +0,0 @@
local _file_values = './data/values.lua'
local function save_value(chat, text )
var_name, var_value = string.match(text, "/set (%a+) (.+)")
if (var_name == nil or var_value == nil) then
return "Benutzung: /set var_name value"
end
if _values[chat] == nil then
_values[chat] = {}
end
_values[chat][var_name] = var_value
-- Save values to file
serialize_to_file(_values, _file_values)
return "Gespeichert: "..var_name.." = "..var_value
end
local function run(msg, matches)
local chat_id = tostring(msg.to.id)
local text = save_value(chat_id, msg.text)
return text
end
return {
description = "Setze Variable",
usage = {"/set [Variablenname] [Daten]"},
patterns = {"^/set (%a+) (.+)$"},
run = run
}

View File

@ -1,42 +0,0 @@
local function get_value(msg, var_name)
local hash = 'telegram:savedtext'
if hash then
local value = redis:hget(hash, var_name)
if not value then
return ""
else
return var_name..' '..value
end
end
end
local function list_variables(msg)
local hash = 'telegram:savedtext'
if hash then
print('Getting variable from redis hash '..hash)
local names = redis:hkeys(hash)
local text = ''
for i=1, #names do
variables = get_value(msg, names[i])
text = text..variables.."\n"
end
if text == '' or text == nil then
return ""
else
return text
end
end
end
local function run(msg, matches)
return list_variables(msg)
end
return {
description = "",
usage = {},
patterns = {"^/save$"},
run = run,
privileged = true
}

View File

@ -1,45 +0,0 @@
local function save_value(msg, name, value)
if (not name or not value) then
return ""
end
local hash = 'telegram:savedtext'
if hash then
print('Saving variable to redis hash '..hash)
redis:hset(hash, name, value)
return value.." gespeichert!"
end
end
local function delete_value(msg, name)
local hash = 'telegram:savedtext'
if redis:hexists(hash, name) == true then
print('Deleting from redis hash '..hash)
redis:hdel(hash, name)
return value..' erfolgreich gelöscht!'
else
return ""
end
end
local function run(msg, matches)
local name = string.sub(matches[1], 1, 50)
local value = string.sub(matches[2], 1, 1000)
if value == "nil" then
text = delete_value(msg, name, value)
else
text = save_value(msg, name, value)
end
return text
end
return {
description = ".",
usage = {},
patterns = {
"^/save ([^%s]+) (.+)$"
},
run = run ,
privileged = true
}

View File

@ -1,100 +0,0 @@
-- Implement a command !time [area] which uses
-- 2 Google APIs to get the desired result:
-- 1. Geocoding to get from area to a lat/long pair
-- 2. Timezone to get the local time in that lat/long location
-- Globals
-- If you have a google api key for the geocoding/timezone api
api_key = nil
base_api = "https://maps.googleapis.com/maps/api"
dateFormat = "%A %d %B - %H:%M:%S"
-- Need the utc time for the google api
function utctime()
return os.time(os.date("!*t"))
end
-- Use the geocoding api to get the lattitude and longitude with accuracy specifier
-- CHECKME: this seems to work without a key??
function get_latlong(area)
local api = base_api .. "/geocode/json?"
local parameters = "address=".. (URL.escape(area) or "")
if api_key ~= nil then
parameters = parameters .. "&key="..api_key
end
-- Do the request
local res, code = https.request(api..parameters)
if code ~=200 then return nil end
local data = json:decode(res)
if (data.status == "ZERO_RESULTS") then
return nil
end
if (data.status == "OK") then
-- Get the data
lat = data.results[1].geometry.location.lat
lng = data.results[1].geometry.location.lng
acc = data.results[1].geometry.location_type
types= data.results[1].types
return lat,lng,acc,types
end
end
-- Use timezone api to get the time in the lat,
-- Note: this needs an API key
function get_time(lat,lng)
local api = base_api .. "/timezone/json?"
-- Get a timestamp (server time is relevant here)
local timestamp = utctime()
local parameters = "location=" ..
URL.escape(lat) .. "," ..
URL.escape(lng) ..
"&timestamp="..URL.escape(timestamp)
if api_key ~=nil then
parameters = parameters .. "&key="..api_key
end
local res,code = https.request(api..parameters)
if code ~= 200 then return nil end
local data = json:decode(res)
if (data.status == "ZERO_RESULTS") then
return nil
end
if (data.status == "OK") then
-- Construct what we want
-- The local time in the location is:
-- timestamp + rawOffset + dstOffset
local localTime = timestamp + data.rawOffset + data.dstOffset
return localTime, data.timeZoneId
end
return localTime
end
function getformattedLocalTime(area)
if area == nil then
return "The time in nowhere is never"
end
lat,lng,acc = get_latlong(area)
if lat == nil and lng == nil then
return 'It seems that in "'..area..'" they do not have a concept of time.'
end
local localTime, timeZoneId = get_time(lat,lng)
return "The local time in "..timeZoneId.." is: ".. os.date(dateFormat,localTime)
end
function run(msg, matches)
return getformattedLocalTime(matches[1])
end
return {
description = "Displays the local time in an area",
usage = "!time [area]: Displays the local time in that area",
patterns = {"^!time (.*)$"},
run = run
}

View File

@ -1,67 +0,0 @@
--[[
-- Translate text using Google Translate.
-- http://translate.google.com/translate_a/single?client=t&ie=UTF-8&oe=UTF-8&hl=en&dt=t&tl=en&sl=auto&text=hello
--]]
do
function translate(source_lang, target_lang, text)
local path = "http://translate.google.com/translate_a/single"
-- URL query parameters
local params = {
client = "t",
ie = "UTF-8",
oe = "UTF-8",
hl = "de",
dt = "t",
tl = target_lang or "de",
sl = source_lang or "auto",
text = URL.escape(text)
}
local query = format_http_params(params, true)
local url = path..query
local res, code = https.request(url)
-- Return nil if error
if code > 200 then return nil end
local trans = res:gmatch("%[%[%[\"(.*)\"")():gsub("\"(.*)", "")
return trans
end
function run(msg, matches)
-- Third pattern
if #matches == 1 then
print("First")
local text = matches[1]
return translate(nil, nil, text)
end
-- Second pattern
if #matches == 2 then
print("Second")
local target = matches[1]
local text = matches[2]
return translate(nil, target, text)
end
-- First pattern
if #matches == 3 then
print("Third")
local source = matches[1]
local target = matches[2]
local text = matches[3]
return translate(source, target, text)
end
end
return {
description = "Übersetze Text",
usage = {"/translate [Text]"},
patterns = {"^/translate ([%w]+),([%a]+) (.+)","^/translate ([%w]+) (.+)","^/translate (.+)",},
run = run
}
end

View File

@ -1,238 +0,0 @@
do
-- Trivia plugin developed by Guy Spronck
-- Returns the chat hash for storing information
local function get_hash(msg)
local hash = nil
if msg.to.type == 'chat' then
hash = 'chat:'..msg.to.id..':trivia'
end
if msg.to.type == 'user' then
hash = 'user:'..msg.from.id..':trivia'
end
return hash
end
-- Sets the question variables
local function set_question(msg, question, answer)
local hash =get_hash(msg)
if hash then
redis:hset(hash, "question", question)
redis:hset(hash, "answer", answer)
redis:hset(hash, "time", os.time())
end
end
-- Returns the current question
local function get_question( msg )
local hash = get_hash(msg)
if hash then
local question = redis:hget(hash, 'question')
if question ~= "NA" then
return question
end
end
return nil
end
-- Returns the answer of the last question
local function get_answer(msg)
local hash = get_hash(msg)
if hash then
return redis:hget(hash, 'answer')
else
return nil
end
end
-- Returns the time of the last question
local function get_time(msg)
local hash = get_hash(msg)
if hash then
return redis:hget(hash, 'time')
else
return nil
end
end
-- This function generates a new question if available
local function get_newquestion(msg)
local timediff = 601
if(get_time(msg)) then
timediff = os.time() - get_time(msg)
end
if(timediff > 600 or get_question(msg) == nil)then
-- Let's show the answer if no-body guessed it right.
if(get_question(msg)) then
send_large_msg(get_receiver(msg), "The question '" .. get_question(msg) .."' has not been answered. \nThe answer was '" .. get_answer(msg) .."'")
end
local url = "http://jservice.io/api/random/"
local b,c = http.request(url)
local query = json:decode(b)
if query then
local stringQuestion = ""
if(query[1].category)then
stringQuestion = "Category: " .. query[1].category.title .. "\n"
end
if query[1].question then
stringQuestion = stringQuestion .. "Question: " .. query[1].question
set_question(msg, query[1].question, query[1].answer:lower())
return stringQuestion
end
end
return 'Something went wrong, please try again.'
else
return 'Please wait ' .. 600 - timediff .. ' seconds before requesting a new question. \nUse !triviaquestion to see the current question.'
end
end
-- This function generates a new question when forced
local function force_newquestion(msg)
-- Let's show the answer if no-body guessed it right.
if(get_question(msg)) then
send_large_msg(get_receiver(msg), "The question '" .. get_question(msg) .."' has not been answered. \nThe answer was '" .. get_answer(msg) .."'")
end
local url = "http://jservice.io/api/random/"
local b,c = http.request(url)
local query = json:decode(b)
if query then
local stringQuestion = ""
if(query[1].category)then
stringQuestion = "Category: " .. query[1].category.title .. "\n"
end
if query[1].question then
stringQuestion = stringQuestion .. "Question: " .. query[1].question
set_question(msg, query[1].question, query[1].answer:lower())
return stringQuestion
end
end
return 'Something went wrong, please try again.'
end
-- This function adds a point to the player
local function give_point(msg)
local hash = get_hash(msg)
if hash then
local score = tonumber(redis:hget(hash, msg.from.id) or 0)
redis:hset(hash, msg.from.id, score+1)
end
end
-- This function checks for a correct answer
local function check_answer(msg, answer)
if(get_answer(msg)) then -- Safety for first time use
if(get_answer(msg) == "NA")then
-- Question has not been set, give a new one
--get_newquestion(msg)
return "No question set, please use !trivia first."
elseif (get_answer(msg) == answer:lower()) then -- Question is set, lets check the answer
set_question(msg, "NA", "NA") -- Correct, clear the answer
give_point(msg) -- gives out point to player for correct answer
return msg.from.print_name .. " has answered correctly! \nUse !trivia to get a new question."
else
return "Sorry " .. msg.from.print_name .. ", but '" .. answer .. "' is not the correct answer!"
end
else
return "No question set, please use !trivia first."
end
end
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 get_user_score(msg, user_id, chat_id)
local user_info = {}
local uhash = 'user:'..user_id
local user = redis:hgetall(uhash)
local hash = 'chat:'..msg.to.id..':trivia'
user_info.score = tonumber(redis:hget(hash, user_id) or 0)
user_info.name = user_print_name(user)..' ('..user_id..')'
return user_info
end
-- Function to print score
local function trivia_scores(msg)
if msg.to.type == 'chat' then
-- Users on chat
local hash = 'chat:'..msg.to.id..':users'
local users = redis:smembers(hash)
local users_info = {}
-- Get user info
for i = 1, #users do
local user_id = users[i]
local user_info = get_user_score(msg, user_id, msg.to.id)
table.insert(users_info, user_info)
end
table.sort(users_info, function(a, b)
if a.score and b.score then
return a.score > b.score
end
end)
local text = ''
for k,user in pairs(users_info) do
text = text..user.name..' => '..user.score..'\n'
end
return text
else
return "This function is only available in group chats."
end
end
local function run(msg, matches)
if(matches[1] == "!triviascore" or matches[1] == "!triviascores") then
-- Output all scores
return trivia_scores(msg)
elseif(matches[1] == "!triviaquestion")then
return "Question: " .. get_question(msg)
elseif(matches[1] == "!triviaskip") then
if is_sudo(msg) then
return force_newquestion(msg)
end
elseif(matches[1] ~= "!trivia") then
return check_answer(msg, matches[1])
end
return get_newquestion(msg)
end
return {
description = "Trivia plugin for Telegram",
usage = {
"!trivia to obtain a new question.",
"!trivia [answer] to answer the question.",
"!triviaquestion to show the current question.",
"!triviascore to get a scoretable of all players.",
"!triviaskip to skip a question (requires sudo)"
},
patterns = {"^!trivia (.*)$",
"^!trivia$",
"^!triviaquestion$",
"^!triviascore$",
"^!triviascores$",
"^!triviaskip$"},
run = run
}
end

View File

@ -1,46 +0,0 @@
do
local api_key = cred_data.tumblr_api_key
local function get_blog_info(id)
local url = 'https://api.tumblr.com/v2/blog/'..id..'.tumblr.com/info?api_key='..api_key
local res,code = https.request(url)
local data = json:decode(res).response.blog
if code ~= 200 then return "HTTP-Fehler" end
if not data then return "HTTP-Fehler" end
local title = data.title
local desc = data.description
if data.posts == 1 then
posts = data.posts..' Post'
else
posts = data.posts..' Posts'
end
if data.likes then
likes = ', '..data.likes..' Likes'
else
likes = ''
end
local text = title..'\n'..desc..'\n'..posts..likes..'\n'
return text
end
local function run(msg, matches)
local id = matches[1]
local text = get_blog_info(id)
local receiver = get_receiver(msg)
return text
end
return {
description = "Sendet Infos zu einem tumblr-Blog",
usage = "Link zu tumblr Blog",
patterns = {
"^https?://(.*).tumblr.com/?$"
},
run = run
}
end

View File

@ -1,65 +0,0 @@
do
local api_key = cred_data.tumblr_api_key
local makeOurDate = function(dateString)
local pattern = "(%d+)%-(%d+)%-(%d+)"
local year, month, day = dateString:match(pattern)
if month == "00" then
return year
elseif day == "00" then
return month..'.'..year
else
return day..'.'..month..'.'..year
end
end
local function get_tumblr_post(blog, id)
local url = 'https://api.tumblr.com/v2/blog/'..blog..'.tumblr.com/posts?id='..id..'&api_key='..api_key
print(url)
local res,code = https.request(url)
local data = json:decode(res).response
if code ~= 200 then return "HTTP-Fehler" end
if not data then return "HTTP-Fehler" end
local blog_name = data.blog.title
local date = makeOurDate(data.posts[1].date)
local sum = data.posts[1].summary
local short_url = data.posts[1].short_url
if data.posts[1].photos then
pic = data.posts[1].photos[1].original_size.url
end
local text = blog_name..' am '..date..':\n'..sum..'\n'..short_url
if data.posts[1].photos then
return text, pic
else
return text
end
end
local function run(msg, matches)
local blog = matches[1]
local id = matches[2]
local text, pic = get_tumblr_post(blog, id)
local receiver = get_receiver(msg)
local file = download_to_file(pic)
if string.ends(pic, '.gif') then
send_document(receiver, file, ok_cb, false)
else
send_photo(receiver, file, ok_cb, false)
end
return text
end
return {
description = "Sendet Infos zu einem tumblr-Post",
usage = "Link zu tumblr Post",
patterns = {
"^https?://(.*).tumblr.com/post/(%d+)"
},
run = run
}
end

View File

@ -1,88 +0,0 @@
do
local _file_votes = './data/votes.lua'
function read_file_votes ()
local f = io.open(_file_votes, "r+")
if f == nil then
print ('Created voting file '.._file_votes)
serialize_to_file({}, _file_votes)
else
print ('Values loaded: '.._file_votes)
f:close()
end
return loadfile (_file_votes)()
end
function clear_votes (chat)
local _votes = read_file_votes ()
_votes [chat] = {}
serialize_to_file(_votes, _file_votes)
end
function votes_result (chat)
local _votes = read_file_votes ()
local results = {}
local result_string = ""
if _votes [chat] == nil then
_votes[chat] = {}
end
for user,vote in pairs (_votes[chat]) do
if (results [vote] == nil) then
results [vote] = user
else
results [vote] = results [vote] .. ", " .. user
end
end
for vote,users in pairs (results) do
result_string = result_string .. vote .. " : " .. users .. "\n"
end
return result_string
end
function save_vote(chat, user, vote)
local _votes = read_file_votes ()
if _votes[chat] == nil then
_votes[chat] = {}
end
_votes[chat][user] = vote
serialize_to_file(_votes, _file_votes)
end
function run(msg, matches)
if (matches[1] == "ing") then
if (matches [2] == "reset") then
clear_votes (tostring(msg.to.id))
return "Voting statistics reset.."
elseif (matches [2] == "stats") then
local votes_result = votes_result (tostring(msg.to.id))
if (votes_result == "") then
votes_result = "[No votes registered]\n"
end
return "Voting statistics :\n" .. votes_result
end
else
save_vote(tostring(msg.to.id), msg.from.print_name, tostring(tonumber(matches[2])))
return "Vote registered : " .. msg.from.print_name .. " " .. tostring(tonumber(matches [2]))
end
end
return {
description = "Plugin for voting in groups.",
usage = {
"!voting reset: Reset all the votes.",
"!vote [number]: Cast the vote.",
"!voting stats: Shows the statistics of voting."
},
patterns = {
"^!vot(ing) (reset)",
"^!vot(ing) (stats)",
"^!vot(e) ([0-9]+)$"
},
run = run
}
end

View File

@ -1,50 +0,0 @@
do
function getWallpaper(text)
local text = URL.escape(text)
local api = "https://ajax.googleapis.com/ajax/services/search/images?v=1.0&rsz=8&safe=active&tbs=isz:l&tbm=isch&q=wallpaper+"
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
end
function run(msg, matches)
local receiver = get_receiver(msg)
local text = matches[1]
local url = getWallpaper(text)
if not url then
return "Kein Wallpaper gefunden."
end
print("Bilder-URL: ", url)
send_photo_from_url(receiver, url)
return "Source: "..url
end
return {
description = "Sucht Wallpaper mit Google und versendet es (SafeSearch aktiv)",
usage = {"/wallpaper [Suchbegriff]","/wp [Suchbegriff]"},
patterns = {"^/wallpaper (.*)$","^/wp (.*)$"},
run = run
}
end
-- Original by yagop ; Modified by Akamaru [https://ponywave.de]

View File

@ -1,50 +0,0 @@
do
function getWallpaper2(text)
local text = URL.escape(text)
local api = "https://ajax.googleapis.com/ajax/services/search/images?v=1.0&rsz=8&tbs=isz:l&tbm=isch&q=wallpaper+"
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
end
function run(msg, matches)
local receiver = get_receiver(msg)
local text = matches[1]
local url = getWallpaper2(text)
if not url then
return "Kein Wallpaper gefunden."
end
print("Bilder-URL: ", url)
send_photo_from_url(receiver, url)
return "Source: "..url
end
return {
description = "Sucht Wallpaper mit Google und versendet es [NSFW]",
usage = {"/wallpaper2 [Suchbegriff]","/wp2 [Suchbegriff]"},
patterns = {"^/wallpaper2 (.*)$","^/wp2 (.*)$"},
run = run
}
end
-- Original by yagop ; Modified by Akamaru [https://ponywave.de]

View File

@ -1,77 +0,0 @@
do
local BASE_URL = "http://api.openweathermap.org/data/2.5/weather"
local function get_weather(location)
print("Finde Wetter in ", 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&APPID='..apikey
local b, c, h = http.request(url)
if c ~= 200 then return nil end
local weather = json:decode(b)
local city = weather.name
if weather.sys.country == 'none' then
country = ''
else
country = ' ('..weather.sys.country..')'
end
local temperature = round(weather.main.temp, 1)
local temp = 'Wetter in '..city..country..':\n'..temperature..'°C'
local conditions = ' | '..weather.weather[1].description
if weather.weather[1].main == 'Clear' then
conditions = conditions..''
elseif weather.weather[1].main == 'Clouds' then
conditions = conditions..' ☁☁'
elseif weather.weather[1].main == 'Rain' then
conditions = conditions..''
elseif weather.weather[1].main == 'Thunderstorm' then
conditions = conditions..' ☔☔☔☔'
elseif weather.weather[1].main == 'Snow' then
conditions = conditions..' ❄️'
elseif weather.weather[1].main == 'Fog' then
conditions = conditions..' 🌫'
else
conditions = conditions..''
end
return temp..conditions
end
local function run(msg, matches)
local user_id = msg.from.id
if matches[1] ~= '/wetter' then
city = matches[1]
else
local set_location = get_location(user_id)
if not set_location then
city = 'Berlin'
else
city = set_location
end
end
local text = get_weather(city)
if not text then
text = 'Konnte das Wetter von dieser Stadt nicht bekommen.'
end
return text
end
return {
description = "Wetter für deinen oder einen gewählten Ort",
usage = {
"/wetter: Wetter für deinen Wohnort (!location set [Ort])",
"/wetter (Stadt): Wetter für diese Stadt"
},
patterns = {
"^/wetter$",
"^/wetter (.*)$"
},
run = run
}
end

View File

@ -1,66 +0,0 @@
require("./plugins/googlethat")
function firstresult(results)
return results[1][2]
end
function wikiapilink(wikiurl)
local wikipattern="^http://de.wikipedia.org/wiki/(.*)$"
local matches = { string.match(wikiurl, wikipattern) }
local queryterm=matches[1]
local apilink = "http://de.wikipedia.org/w/index.php?action=raw&title="..queryterm
return apilink
end
function getwikifromapi(apilink)
-- Do the request
local res, code = https.request(apilink)
if code ~=200 then return "Ein Fehler ist aufgetreten" end
local data = res
local wikitext=data
return wikitext
end
function plaintext(wikitext)
local plaintext=string.gsub(wikitext,"{{Infobox.-\n}}\n","")
plaintext=string.gsub(wikitext,"{{Medienbox.-\n}}\n","")
plaintext=string.gsub(wikitext,"<!--.--->","")
plaintext=string.gsub(plaintext,"Datei:.-]]","")
plaintext=string.gsub(plaintext,"{{.-}}","")
plaintext=string.gsub(plaintext,"[%[%|%]%]]","")
plaintext=string.gsub(plaintext,"<ref.->.-</ref>","")
local firstsectionindex=string.find(plaintext,"==")
if firstsectionindex~=nil then
plaintext=string.sub(plaintext,1,firstsectionindex-1)
end
return plaintext
end
function formatwikiforsending(wikitext,url)
-- local stringtosend=title.."\n==="
local stringtosend=plaintext(wikitext).."\n"
stringtosend=stringtosend.."- "..url
return stringtosend
end
function scrapewiki(results)
local url=firstresult(results)
local tosend=formatwikiforsending(getwikifromapi(wikiapilink(url)),url)
return tosend
end
function run(msg, matches)
vardump(matches)
local results = googlethat(matches[1].." site:de.wikipedia.org")
return scrapewiki(results)
end
return {
description = "Sendet einen Wikipedia-Artikel",
usage = {"/wiki [Suchwort]","de.wikipedia.org Link"},
patterns = {"^/wiki (.*)$","^%.[w|W]iki (.*)$","de.wikipedia.org/wiki/([A-Za-z0-9-_-]+)"},
run = run
}

View File

@ -1,11 +0,0 @@
function run(msg, matches)
return 'Hä YOLO?'
end
return {
description = "Sendet euch ein Hä YOLO?",
usage = {'yolo','Yolo','YOLO'},
patterns = {'^yolo$','^Yolo$','^YOLO$'},
run = run
}
--by Akamaru [https://ponywave.de]

View File

@ -1,39 +0,0 @@
local function googlethat(query)
query = "site:youporn.com" .. query
local api = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&"
local parameters = "q=".. (URL.escape(query))
-- 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
local function stringlinks(results)
local stringresults=""
for key,val in ipairs(results) do
stringresults=stringresults..val[1].." - "..val[2].."\n"
end
return stringresults
end
local function run(msg, matches)
local results = googlethat(matches[1])
return stringlinks(results)
end
return {
description = "Sendet ein YouPorn Video",
usage = {"/youporn [Begriff]","/yp [Begriff]"},
patterns = {"^/youporn(.*)$","^/yp(.*)$"},
run = run
}

View File

@ -1,21 +0,0 @@
-- Requires: (sudo) apt-get install youtube-dl
-- See https://github.com/rg3/youtube-dl/blob/master/README.md#options
function run(msg, matches)
URL = matches[1]
local receiver = get_receiver(msg)
if string.match(msg.text, '"') then
return 'Vergiss es'
else
text = run_bash("youtube-dl -o tmp/sound.mp3 --audio-format mp3 --no-continue " .. URL)
send_audio(get_receiver(msg), "tmp/sound.mp3", ok_cb, false)
return URL .. ' wurde gedownloadet und wird jetzt gesendet! \nDas kann je nach Video sehr lang dauern! \nAlso habt Geduld!'
end
end
return {
description = "Downloadet und sendet die MP3 von einem YouTube-Video",
usage = {"/mp3 [Link]"},
patterns = {"^/mp3 (https?://[%w-_%.%?%.:/%+=&]+)$"},
run = run
}
--by Akamaru [https://ponywave.de]