Zu viele Änderungen, die ich nicht alle einzeln aufzählen möchte ._.

This commit is contained in:
Akamaru 2016-01-30 21:03:21 +01:00
parent e3c4d404bd
commit f04437a829
21 changed files with 387 additions and 181 deletions

View File

@ -225,6 +225,7 @@ function create_cred()
owm_apikey = "",
page2images_restkey = "",
soundcloud_client_id = "",
tumblr_api_key = "",
tw_consumer_key = "",
tw_consumer_secret = "",
tw_access_token = "",

View File

@ -663,8 +663,80 @@ function cache_data(plugin, query, data, timeout, typ)
redis:expire(hash, timeout)
end
--[[
Ordered table iterator, allow to iterate on the natural order of the keys of a
table.
-- http://lua-users.org/wiki/SortedIteration
]]
function __genOrderedIndex( t )
local orderedIndex = {}
for key in pairs(t) do
table.insert( orderedIndex, key )
end
table.sort( orderedIndex )
return orderedIndex
end
function orderedNext(t, state)
-- Equivalent of the next function, but returns the keys in the alphabetic
-- order. We use a temporary ordered key table that is stored in the
-- table being iterated.
key = nil
--print("orderedNext: state = "..tostring(state) )
if state == nil then
-- the first time, generate the index
t.__orderedIndex = __genOrderedIndex( t )
key = t.__orderedIndex[1]
else
-- fetch the next value
for i = 1,table.getn(t.__orderedIndex) do
if t.__orderedIndex[i] == state then
key = t.__orderedIndex[i+1]
end
end
end
if key then
return key, t[key]
end
-- no more value to return, cleanup
t.__orderedIndex = nil
return
end
function orderedPairs(t)
-- Equivalent of the pairs() function on tables. Allows to iterate
-- in order
return orderedNext, t, nil
end
-- converts total amount of seconds (e.g. 65 seconds) to human redable time (e.g. 1:05 minutes)
function makeHumanTime(totalseconds)
local seconds = totalseconds % 60
local minutes = math.floor(totalseconds / 60)
local minutes = minutes % 60
local hours = math.floor(totalseconds / 3600)
if minutes == 00 and hours == 00 then
return seconds..' Sekunden'
elseif hours == 00 and minutes ~= 00 then
return string.format("%02d:%02d", minutes, seconds)..' Minuten'
elseif hours ~= 00 then
return string.format("%02d:%02d:%02d", hours, minutes, seconds)..' Stunden'
end
end
function is_blacklisted(msg)
_blacklist = redis:smembers("telegram:img_blacklist")
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

37
plugins/adfly.lua Normal file
View File

@ -0,0 +1,37 @@
-- 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://andibi.tk/dl/adfly.php'
local function expand_adfly_link (adfly_code)
local url = BASE_URL..'/?url=http://adf.ly/'..adfly_code
local res,code = https.request(url)
if code ~= 200 then return "HTTP-FEHLER" end
if res == 'Fehler: Keine Adf.ly-URL gefunden!' then return res end
cache_data('adfly', adfly_code, res, 31536000, 'key')
return res
end
local function run(msg, matches)
local adfly_code = matches[1]
local hash = 'telegram:cache:adfly:'..adfly_code
if redis:exists(hash) == false then
return expand_adfly_link(adfly_code)
else
local data = redis:get(hash)
return data
end
end
return {
description = "Verlängert Adfly-Links",
usage = "Adf.ly-Link",
patterns = {
"adf.ly/([A-Za-z0-9-_-]+)"
},
run = run
}
end

View File

@ -13,6 +13,8 @@ local function get_condition_symbol(weather, n)
return ' ☔☔☔☔'
elseif weather.list[n].weather[1].main == 'Snow' then
return ' ❄️'
elseif weather.weather[1].main == 'Fog' then
return ' 🌫'
else
return ''
end

View File

@ -1,17 +1,17 @@
do
local function send_gfycat_gif(name, receiver)
local function send_gfycat_video(name, receiver)
local BASE_URL = "https://gfycat.com"
local url = BASE_URL..'/cajax/get/'..name
local res,code = https.request(url)
if code ~= 200 then return "HTTP-FEHLER" end
local data = json:decode(res).gfyItem
local file = download_to_file(data.gifUrl)
local file = download_to_file(data.webmUrl)
local cb_extra = {file_path=file}
if file == nil then
send_msg(receiver, 'Fehler beim Herunterladen von '..name, ok_cb, false)
send_msg(receiver, 'Fehler beim Herunterladen von '..name, ok_cb, false)
else
send_document(receiver, file, rmtmp_cb, cb_extra)
send_video(receiver, file, rmtmp_cb, cb_extra)
end
end
@ -21,24 +21,27 @@ local function send_gfycat_thumb(name, receiver)
local file = download_to_file(url)
local cb_extra = {file_path=file}
if file == nil then
print('Fehler beim Herunterladen des Thumbnails von '..name)
print('Fehler beim Herunterladen des Thumbnails von '..name)
else
send_photo(receiver, file, rmtmp_cb, cb_extra)
end
end
local function run(msg, matches)
local name = matches[1]
local receiver = get_receiver(msg)
send_gfycat_gif(name, receiver)
send_gfycat_thumb(name, receiver)
local name = matches[1]
local receiver = get_receiver(msg)
send_gfycat_video(name, receiver)
if matches[2] ~= 'NSFW' then
send_gfycat_thumb(name, receiver)
end
end
return {
description = "Postet Gfycat-Video",
usage = "gfycat-Link: Postet Gfycat-Video",
usage = "URL zu gfycat-Video (hänge 'NSFW' an, wenn es NSFW ist)",
patterns = {
"gfycat.com/([A-Za-z0-9-_-]+)",
"gfycat.com/([A-Za-z0-9-_-]+) (NSFW)",
"gfycat.com/([A-Za-z0-9-_-]+)"
},
run = run
}

View File

@ -67,8 +67,8 @@ return {
"Link zu GitHub-Commit"
},
patterns = {
"github.com/([A-Za-z0-9-_-.-.]+)/([A-Za-z0-9-_-.-.]+)/commit/([a-z0-9-]+)",
"github.com/([A-Za-z0-9-_-.-.]+)/([A-Za-z0-9-_-.-.]+)/?$"
"github.com/([A-Za-z0-9-_-.-._.]+)/([A-Za-z0-9-_-.-._.]+)/commit/([a-z0-9-]+)",
"github.com/([A-Za-z0-9-_-.-._.]+)/([A-Za-z0-9-_-.-._.]+)/?$"
},
run = run
}

View File

@ -38,40 +38,6 @@ local function is_blacklisted(msg)
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 cache_bing_image(results, text)
local cache = {}
for v in pairs(results) do
@ -83,38 +49,8 @@ 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 remove" and word == nil then
return "Benutzung: /imgblacklist remove [Wort]"
elseif text == "/imgblacklist remove" 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 ._."
@ -147,10 +83,8 @@ local function run(msg, matches)
if string.ends(url, ".gif") then
failed = not send_document_from_url(receiver, url, nil, nil, true)
return 'Source: '..url
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)
return 'Source: '..url
end
nofTries = nofTries + 1
@ -163,21 +97,17 @@ local function run(msg, matches)
if failed then
return "Fehler beim Herunterladen eines Bildes."
end
return 'Source: '..url
end
return {
description = "Sucht Bild mit Bing-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 remove [Wort]: Entfernt Wort aus der Blacklist (nur Superuser)"
"/imgbing [Suchbegriff]"
},
patterns = {
"^/img (.*)$",
"^(/imgblacklist show)$",
"^(/imgblacklist add) (.*)$",
"^(/imgblacklist remove) (.*)$"
"^/imgbing (.*)$"
},
run = run
}

77
plugins/img_blacklist.lua Normal file
View File

@ -0,0 +1,77 @@
-- 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 _blacklist
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
function run(msg, matches)
local action = matches[1]
if matches[2] then word = string.lower(matches[2]) end
_blacklist = redis:smembers("telegram:img_blacklist")
if action == "add" and word == nil then
return "Benutzung: !imgblacklist add [Wort]"
elseif action == "add" and word then
return add_blacklist()
end
if action == "remove" and word == nil then
return "Benutzung: !imgblacklist remove [Wort]"
elseif action == "remove" and word then
return remove_blacklist()
end
return show_blacklist()
end
return {
description = "Blacklist-Manager für Bilder-Plugins (nur Superuser)",
usage = {
"/imgblacklist show: Zeigt Blacklist",
"/imgblacklist add [Wort]: Fügt Wort der Blacklist hinzu",
"/imgblacklist remove [Wort]: Entfernt Wort aus der Blacklist"
},
patterns = {
"^/imgblacklist show$",
"^/imgblacklist (add) (.*)$",
"^/imgblacklist (remove) (.*)$"
},
run = run,
privileged = true
}
end

View File

@ -16,18 +16,6 @@ local function getGoogleImage(text)
return google
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 cache_google_image(results, text)
local cache = {}
for v in pairs(results) do
@ -38,10 +26,7 @@ end
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")
local text = matches[1]
print ('Checking if search contains blacklisted words: '..text)
if is_blacklisted(text) then
@ -53,6 +38,9 @@ function run(msg, matches)
if not results[1] then
print('doing web request')
results = getGoogleImage(text)
if results == 'QUOTAEXCEEDED' then
return 'Kontingent für heute erreicht - nur noch gecachte Suchanfragen möglich (oder /imgbing <Suchbegriff>).'
end
if not results then
return "Kein Bild gefunden!"
end
@ -74,10 +62,8 @@ function run(msg, matches)
if string.ends(url, ".gif") then
failed = not send_document_from_url(receiver, url, nil, nil, true)
return 'Source: '..url
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)
return 'Source: '..url
end
nofTries = nofTries + 1
@ -90,15 +76,17 @@ function run(msg, matches)
if failed then
return "Fehler beim Herunterladen eines Bildes."
end
return 'Source: '..url
end
return {
description = "Sucht Bild mit Google-API und versendet es (SafeSearch aktiv)",
usage = {
"/oldimg [Suchbegriff]"
"/img [Suchbegriff]"
},
patterns = {
"^/oldimg (.*)$"
"^/img (.*)$"
},
run = run
}

View File

@ -38,10 +38,7 @@ end
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")
local text = matches[1]
print ('Checking if search contains blacklisted words: '..text)
if is_blacklisted(text) then
@ -52,11 +49,14 @@ function run(msg, matches)
local results = redis:smembers(hash)
if not results[1] then
print('doing web request')
results = getNSFWImage(text)
results = getGoogleImage(text)
if results == 'QUOTAEXCEEDED' then
return 'Kontingent für heute erreicht - nur noch gecachte Suchanfragen möglich!'
end
if not results then
return "Kein Bild gefunden!"
end
cache_nsfw_image(results, text)
cache_google_image(results, text)
end
-- Random image from table
local i = math.random(#results)
@ -74,10 +74,8 @@ function run(msg, matches)
if string.ends(url, ".gif") then
failed = not send_document_from_url(receiver, url, nil, nil, true)
return 'Source: '..url
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)
return 'Source: '..url
end
nofTries = nofTries + 1
@ -90,6 +88,8 @@ function run(msg, matches)
if failed then
return "Fehler beim Herunterladen eines Bildes."
end
return 'Source: '..url
end
return {

View File

@ -13,8 +13,8 @@ local makeOurDate = function(dateString)
end
local function get_vid_info(id)
local url = 'https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3D%22http%3A%2F%2Fext.nicovideo.jp%2Fapi%2Fgetthumbinfo%2Fsm'..id..'%22&format=json&diagnostics=true&callback='
local res,code = http.request(url)
local url = 'https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3D%22http%3A%2F%2Fext.nicovideo.jp%2Fapi%2Fgetthumbinfo%2Fsm'..id..'%22&format=json'
local res,code = https.request(url)
local data = json:decode(res).query.results.nicovideo_thumb_response.thumb
if code ~= 200 then return "HTTP-Fehler" end
if not data then return "HTTP-Fehler" end
@ -46,7 +46,8 @@ return {
description = "Sendet Infos zu einem nicovideo-Video",
usage = "Link zu nicovideo.jp Video",
patterns = {
"nicovideo.jp/watch/sm(.*)$"
"nicovideo.jp/watch/sm(%d+)$",
"nico.ms/sm(%d+)$"
},
run = run
}

View File

@ -45,18 +45,18 @@ local function reload_plugins(plugin_name, status)
plugins = {}
load_plugins()
if plugin_name then
return 'Das Plugin "'..plugin_name..'" wurde '..status
return 'Plugin '..plugin_name..' wurde '..status
else
return 'Plugins wurden neu geladen'
return 'Plugins neu geladen'
end
end
local function enable_plugin( plugin_name )
print('überprüfe ob "'..plugin_name..'" existiert')
print('checking if '..plugin_name..' exists')
-- Check if plugin is enabled
if plugin_enabled(plugin_name) then
return 'Das Plugin "'..plugin_name..'" ist bereits aktiviert'
return 'Plugin '..plugin_name..' ist schon aktiviert'
end
-- Checks if plugin exists
if plugin_exists(plugin_name) then
@ -73,7 +73,7 @@ end
local function disable_plugin( name, chat )
-- Check if plugins exists
if not plugin_exists(name) then
return 'Das Plugin "'..name..'" existiert nicht'
return 'Plugin '..name..' existiert nicht'
end
local k = plugin_enabled(name)
-- Check if plugin is enabled
@ -88,27 +88,35 @@ end
local function disable_plugin_on_chat(msg, plugin)
if not plugin_exists(plugin) then
return "Dieses Plugin existiert nicht!"
return "Plugin existiert nicht!"
end
local hash = get_redis_hash(msg, 'disabled_plugins')
if not msg.to then
hash = 'chat:'..msg..':disabled_plugins'
else
hash = get_redis_hash(msg, 'disabled_plugins')
end
local disabled = redis:hget(hash, plugin)
if disabled ~= 'true' then
print('Setting '..plugin..' in redis hash '..hash..' to true')
redis:hset(hash, plugin, true)
return 'Das Plugin "'..plugin..'" wurde für diesen Chat deaktiviert.'
return 'Plugin '..plugin..' für diesen Chat deaktiviert.'
else
return 'Das Plugin "'..plugin..'" wurde für diesen Chat bereits deaktiviert.'
return 'Plugin '..plugin..' wurde für diesen Chat bereits deaktiviert.'
end
end
local function reenable_plugin_on_chat(msg, plugin)
if not plugin_exists(plugin) then
return "Dieses Plugin existiert nicht!"
return "Plugin existiert nicht!"
end
local hash = get_redis_hash(msg, 'disabled_plugins')
if not msg.to then
hash = 'chat:'..msg..':disabled_plugins'
else
hash = get_redis_hash(msg, 'disabled_plugins')
end
local disabled = redis:hget(hash, plugin)
if disabled == nil then return 'Es gibt keine deaktivierten Plugins für disen Chat.' end
@ -116,9 +124,9 @@ local function reenable_plugin_on_chat(msg, plugin)
if disabled == 'true' then
print('Setting '..plugin..' in redis hash '..hash..' to false')
redis:hset(hash, plugin, false)
return 'Das Plugin "'..plugin..'" wurde für diesen Chat reaktiviert.'
return 'Plugin '..plugin..' wurde für diesen Chat reaktiviert.'
else
return 'Das Plugin "'..plugin..'" ist nicht deaktiviert.'
return 'Plugin '..plugin..' ist nicht deaktiviert.'
end
end
@ -131,32 +139,46 @@ local function run(msg, matches)
-- Reenable a plugin for this chat
if matches[1] == 'enable' and matches[3] == 'chat' then
local plugin = matches[2]
print('Aktiviere "'..plugin..'" in diesem Chat')
return reenable_plugin_on_chat(msg, plugin)
if matches[4] then
local id = matches[4]
print("enable "..plugin..' on chat#id'..id)
return reenable_plugin_on_chat(id, plugin)
else
print("enable "..plugin..' on this chat')
return reenable_plugin_on_chat(msg, plugin)
end
end
-- Enable a plugin
if matches[1] == 'enable' then
local plugin_name = matches[2]
print('Aktiviere: "'..matches[2]..'"')
print("enable: "..matches[2])
return enable_plugin(plugin_name)
end
-- Disable a plugin on a chat
if matches[1] == 'disable' and matches[3] == 'chat' then
local plugin = matches[2]
print('Deaktiviere "'..plugin..'" in diesem Chat')
return disable_plugin_on_chat(msg, plugin)
if matches[4] then
local id = matches[4]
print("disable "..plugin..' on chat#id'..id)
return disable_plugin_on_chat(id, plugin)
else
print("disable "..plugin..' on this chat')
return disable_plugin_on_chat(msg, plugin)
end
end
-- Disable a plugin
if matches[1] == 'disable' then
print('Deaktiviere: "'..matches[2]..'"')
print("disable: "..matches[2])
return disable_plugin(matches[2])
end
-- Reload all the plugins!
if matches[1] == 'reload' or '/reload' then
if matches[1] == 'reload' then
return reload_plugins()
end
end
@ -168,21 +190,25 @@ return {
"/plugins enable [plugin]: Aktiviert Plugin.",
"/plugins disable [plugin]: Deaktiviert Plugin.",
"/plugins enable [plugin] chat: Aktiviert Plugin in diesem Chat.",
"/plugins enable [plugin] chat <ID>: Aktiviert Plugin in Chat <ID>.",
"/plugins disable [plugin] chat: Deaktiviert Plugin in diesem Chat.",
"/plugins reload: Lädt alle Plugins neu (Alias: /reload)."
"/plugins disable [plugin] chat <ID>: Deaktiviert Plugin in Chat <ID>.",
"/plugins reload: Lädt alle Plugins neu.",
"/reload: Lädt alle Plugins neu."
},
patterns = {
"^/plugins$",
"^/plugins? (enable) ([%w_%.%-]+)$",
"^/plugins? (disable) ([%w_%.%-]+)$",
"^/plugins? (enable) ([%w_%.%-]+) (chat) (%d+)",
"^/plugins? (enable) ([%w_%.%-]+) (chat)",
"^/plugins? (disable) ([%w_%.%-]+) (chat) (%d+)",
"^/plugins? (disable) ([%w_%.%-]+) (chat)",
"^/plugins? (reload)$",
"^/reload$"
"^/(reload)$"
},
run = run,
privileged = true,
notyping = true
privileged = true
}
end

44
plugins/reminder.lua Normal file
View File

@ -0,0 +1,44 @@
function remindme(data)
print('Cron: remindme')
local receiver = data[1]
local text = data[2]
send_msg(receiver, text, ok_cb, false)
end
function run(msg, matches)
if matches[2] == 's' then
minutes = 1
seconds = tonumber(matches[1])
if seconds > 3600 then return 'Bitte nicht länger als eine Stunde!' end
remindtime = seconds
elseif matches[2] == 'm' then
minutes = tonumber(matches[1])
seconds = 60.0
if minutes > 60 then return 'Bitte nicht länger als eine Stunde!' end
remindtime = math.floor(minutes * 60)
end
local text = matches[3]
local receiver = get_receiver(msg)
local current_timestamp = msg.date
local dest_timestamp = current_timestamp+remindtime
local dest_time = run_bash('date -d @'..dest_timestamp..' +"%H:%M:%S"')
local dest_time = string.gsub(dest_time, "%\n", "")
postpone(remindme, {receiver, text}, minutes*seconds)
return 'OK, ich werde dich um '..dest_time..' erinnern (BETA)!'
end
return {
description = "Erinnert dich an etwas in XX Sekunden/Minuten (BETA)",
usage = {
"/remindme (Zahl)s [Text]: Erinnert dich in XX Sekunden",
"/remindme (Zahl)m [Text]: Erinnert dich in XX Minuten"
},
patterns = {
"^/remindme (%d+)(s) (.+)$",
"^/remindme (%d+)(m) (.+)$",
},
run = run
}

View File

@ -22,13 +22,9 @@ function send_track_data(data, receiver)
-- convert s to mm:ss
local totalseconds = math.floor(milliseconds / 1000)
local milliseconds = milliseconds % 1000
local seconds = totalseconds % 60
local minutes = math.floor(totalseconds / 60)
local minutes = minutes % 60
local duration = string.format("%02d:%02d", minutes, seconds)
local duration = makeHumanTime(totalseconds)
local text = '"'..name..' von '..artist..'" aus dem Album "'..album..'" ('..duration..' Minuten)'
local text = '"'..name..' von '..artist..'" aus dem Album "'..album..'" ('..duration..')'
if preview then
local file = download_to_file(preview, 'VORSCHAU: '..name..'.mp3')
send_msg(receiver, text, ok_cb, false)

View File

@ -122,11 +122,11 @@ local function get_bot_stats()
-- Users
local hash = 'msgs:*:'..our_id
local r = redis:eval(redis_scan, 1, hash)
local text = 'Users: '..r
local text = 'User: '..r
hash = 'chat:*:users'
r = redis:eval(redis_scan, 1, hash)
text = text..'\nChats: '..r
text = text..'\nGruppen: '..r
return text

View File

@ -24,7 +24,7 @@ function send_twitch_data(data, receiver)
local status = data.status
local views = comma_value(data.views)
local followers = comma_value(data.followers)
local text = display_name..' ('..name..') streamt '..game..'\n'..status..'\n'..views..' Zuschauer und '..followers..' Follower'
local text = display_name..' ('..name..') streamt '..game..'\n'..status..'\n'..views..' Zuschauer insgesamt und '..followers..' Follower'
send_msg(receiver, text, ok_cb, false)
end

View File

@ -89,6 +89,6 @@ end
return {
description = "Sendet Informationen über Twitter-User",
usage = "URL zu Twitter-User",
patterns = {"twitter.com/([A-Za-z0-9-_-.-_-]+)$"},
patterns = {"twitter.com/@?([A-Za-z0-9-_-.-_-]+)$"},
run = run
}

View File

@ -12,13 +12,14 @@ function getTitle(page)
s = string.gsub(s, "&acute;", "´")
s = string.gsub(s, "&bull;", "")
s = string.gsub(s, "&gt;", ">")
s = string.gsub(s, "&quot;", '"')
s = string.gsub(s, "&hellip;", "")
s = string.gsub(s, "&lt;", "<")
s = string.gsub(s, "&mdash;", "")
s = string.gsub(s, "&nabla;", "")
s = string.gsub(s, "&ndash;", "")
s = string.gsub(s, "&Psi;", "ψ")
s = string.gsub(s, "&psi;", "ψ")
s = string.gsub(s, "&quot;", '"')
s = string.gsub(s, "&raquo;", "»")
s = string.gsub(s, "&reg;", "®")
s = string.gsub(s, "&szlig;", "ß")
@ -83,6 +84,7 @@ function run(msg, matches)
title == "Not Found" or
title == "Document Moved" or
title == "521: Web server is down" or
title == "403 Forbidden" or
string.match(title, "on Steam") or
string.match(title, "eBay</title>") or
string.match(msg.text, "twitch.tv") or
@ -100,6 +102,8 @@ function run(msg, matches)
string.match(msg.text, "myfigurecollection.net") or
string.match(msg.text, "dropbox.com/s/") or
string.match(msg.text, "nicovideo.jp/watch/sm") or
string.match(msg.text, "nico.ms/sm") or
string.match(msg.text, "tumblr.com") or
string.ends(url, ".jpg") or
string.ends(url, ".jpeg") or
string.ends(url, ".gif") or

View File

@ -1,32 +1,52 @@
-- This is a proprietary plugin, property of Andreas Bielawski, (c) 2015 <andi (dot) b (at) outlook (dot) de>
-- 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://vine.co/oembed.json'
local BASE_URL = 'https://vine.co'
function get_vine_data (vine_code)
local url = BASE_URL..'?url=https://vine.co/v/'..vine_code
print(url)
local res,code = https.request(url)
local function get_vine_data (vine_code)
local res, code = https.request(BASE_URL..'/v/'..vine_code..'/embed/simple')
if code ~= 200 then return "HTTP-FEHLER" end
local data = json:decode(res)
local json_data = string.match(res, '<script type%="application/json" id%="configuration">(.-)</script>')
local data = json:decode(json_data).post
return data
end
function send_vine_data(data, receiver)
local title = data.title
local author_name = data.author_name
local text = '"'..title..'", hochgeladen von '..author_name
local image_url = data.thumbnail_url
local cb_extra = {
receiver=receiver,
url=image_url
}
send_msg(receiver, text, send_photo_from_url_callback, cb_extra)
local function send_vine_data(data, receiver)
local title = data.description
local author_name = data.user.username
local creation_date = data.createdPretty
local loops = data.loops.count
local video_url = data.videoUrls[1].videoUrl
local profile_name = string.gsub(data.user.profileUrl, '/', '')
local text = '"'..title..'", hochgeladen von '..author_name..' ('..profile_name..') im '..creation_date..', '..loops..'x angesehen'
if data.explicitContent == 1 then
text = text..' (🔞 NSFW 🔞)'
end
--[[ Send image if not NSFW (remove comment to enable)
if data.explicitContent == 1 then
send_msg(receiver, text, ok_cb, false)
else
local cb_extra = {
receiver=receiver,
url=data.thumbnailUrl
}
send_msg(receiver, text, send_photo_from_url_callback, cb_extra)
end --]]
-- Send text, put comment to disable and remove comment above to enable
-- posting of thumbnail image
send_msg(receiver, text, ok_cb, false)
-- Send video
local file = download_to_file(video_url, data.shortId..'.mp4')
local cb_extra = {file_path=file}
send_video(receiver, file, rmtmp_cb, cb_extra)
end
function run(msg, matches)
local function run(msg, matches)
local vine_code = matches[1]
local data = get_vine_data(vine_code)
local receiver = get_receiver(msg)
@ -35,9 +55,9 @@ end
return {
description = "Sendet Vine-Info.",
usage = {"vine.co/v Link"},
usage = "URL zu Vine.co-Video",
patterns = {"vine.co/v/([A-Za-z0-9-_-]+)"},
run = run
}
end
end

View File

@ -31,6 +31,10 @@ local function get_weather(location)
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

View File

@ -11,6 +11,12 @@ function table.contains(table, element)
return false
end
local makeOurDate = function(dateString)
local pattern = "(%d+)%-(%d+)%-(%d+)T"
local year, month, day = dateString:match(pattern)
return day..'.'..month..'.'..year
end
function get_yt_data (yt_code)
local apikey = cred_data.google_apikey
local url = BASE_URL..'/videos?part=snippet,statistics,contentDetails&key='..apikey..'&id='..yt_code..'&fields=items(snippet(channelTitle,localized(title,description),thumbnails),statistics(viewCount,likeCount,dislikeCount,commentCount),contentDetails(duration,regionRestriction(blocked)))'
@ -62,8 +68,10 @@ end
function send_youtube_data(data, receiver, link, sendpic)
local title = data.snippet.localized.title
--local description = data.snippet.localized.description
local upload_date = makeOurDate(data.snippet.publishedAt)
local uploader = data.snippet.channelTitle
local viewCount = comma_value(data.statistics.viewCount)
local duration = makeHumanTime(totalseconds)
if data.statistics.likeCount then
likeCount = comma_value(data.statistics.likeCount)
dislikeCount = comma_value(data.statistics.dislikeCount)
@ -79,16 +87,9 @@ function send_youtube_data(data, receiver, link, sendpic)
else
blocked = false
end
-- convert s to mm:ss
local seconds = totalseconds % 60
local minutes = math.floor(totalseconds / 60)
local minutes = minutes % 60
local hours = math.floor(totalseconds / 3600)
local duration = string.format("%02d:%02d:%02d", hours, minutes, seconds)
--text = 'Titel: '..title..'\nUploader: '..uploader..'\nAufrufe: '..viewCount..'\nLänge: '..duration..' Stunden\nLikes: '..likeCount..'\nDislikes: '..dislikeCount..'\nKommentare: '..commentCount..'\n'
text = '"'..title..'" hochgeladen von "'..uploader..'"\n'..viewCount..' Aufrufe, Länge: '..duration..' Stunden, '..likeCount..' Likes und '..dislikeCount..' Dislikes, '..commentCount..' Kommentare\n\n'
text = '"'..title..'" hochgeladen am '..upload_date..' von "'..uploader..'"\n'..viewCount..' Aufrufe, Länge: '..duration..' Stunden, '..likeCount..' Likes und '..dislikeCount..' Dislikes, '..commentCount..' Kommentare\n\n'
if link then
text = link..'\n'..text
end