Erster privater commit

This commit is contained in:
Akamaru 2015-11-12 17:42:03 +01:00
parent 71ddfb8502
commit ea622733f6
118 changed files with 5289 additions and 820 deletions

47
.gitignore vendored
View File

@ -1,53 +1,8 @@
res/
.luarocks
*.db
plugins/bitly.lua
plugins/danbooru2.lua
plugins/deviantart.lua
plugins/facebook.lua
plugins/facebook_photo.lua
plugins/facebook_video.lua
plugins/gender.lua
plugins/github.lua
plugins/googl.lua
plugins/ip_info.lua
plugins/konachan.lua
plugins/konachan_nsfw.lua
plugins/page2image.lua
plugins/pagespeed_insights.lua
plugins/ping_adress.lua
plugins/test.lua
plugins/twitch.lua
plugins/derpibooru_nsfw.lua
plugins/derpibooru.lua
plugins/app_store.lua
plugins/dailymotion.lua
plugins/dns.lua
plugins/gdrive.lua
plugins/instagram.lua
plugins/play_store.lua
plugins/reddit.lua
plugins/soundcloud.lua
plugins/spotify.lua
plugins/vimeo.lua
plugins/vine.lua
plugins/youtube_playlist.lua
plugins/yandere.lua
plugins/e621.lua
plugins/ponyfaces.lua
plugins/rss_old.lua
plugins/gfycat.lua
plugins/yourls.lua
plugins/youtube_channel.lua
plugins/pr0gramm.lua
plugins/licht.lua
plugins/dantest.lua
plugins/flickr.lua
plugins/flickr_search.lua
plugins/google_books.lua
plugins/safebrowsing.lua
plugins/stats2.lua
plugins/help2.lua
plugins/miiverse.lua
plugins/videotogif.lua
plugins/music163.lua
plugins/help2.lua

View File

@ -1,26 +1,25 @@
package.path = package.path .. ';.luarocks/share/lua/5.2/?.lua'
..';.luarocks/share/lua/5.2/?/init.lua'
package.cpath = package.cpath .. ';.luarocks/lib/lua/5.2/?.so'
package.path = './.luarocks/share/lua/5.2/?.lua;./.luarocks/share/lua/5.2/?/init.lua;./.luarocks/lib/lua/5.2/?.lua;./.luarocks/lib/lua/5.2/?/init.lua;' .. package.path
require("luarocks.loader")
require("./bot/utils")
VERSION = '2.5-reloaded'
VERSION = '20151003'
-- This function is called when tg receive a msg
function on_msg_receive (msg)
if not started then
return
end
local receiver = get_receiver(msg)
-- vardump(msg)
msg = pre_process_service_msg(msg)
if msg_valid(msg) then
msg = pre_process_msg(msg)
if msg then
match_plugins(msg)
--mark_read(receiver, ok_cb, false)
if msg then
match_plugins(msg)
-- mark_read(receiver, ok_cb, false)
end
end
end
@ -33,9 +32,10 @@ function on_binlog_replay_end()
postpone (cron_plugins, false, 60*5.0)
-- See plugins/isup.lua as an example for cron
_config = load_config()
-- load sudo_users and credentials
sudo_users = load_sudo_users()
cred_data = load_cred()
-- load plugins
plugins = {}
load_plugins()
@ -53,11 +53,6 @@ function msg_valid(msg)
print('\27[36mNicht gültig: alte Nachricht\27[39m')
return false
end
if msg.unread == 0 then
print('\27[36mNicht gültig: gelesen\27[39m')
return false
end
if not msg.to.id then
print('\27[36mNicht gültig: To id not provided\27[39m')
@ -68,6 +63,11 @@ function msg_valid(msg)
print('\27[36mNicht gültig: From id not provided\27[39m')
return false
end
if msg.unread == 0 then
print('\27[36mNicht gültig: gelesen\27[39m')
return false
end
if msg.from.id == our_id then
print('\27[36mNicht gültig: Nachricht von unserer ID\27[39m')
@ -83,11 +83,10 @@ function msg_valid(msg)
print('\27[36mNicht gültig: Telegram Nachricht\27[39m')
return false
end
return true
end
--
function pre_process_service_msg(msg)
if msg.service then
local action = msg.action or {type=""}
@ -111,7 +110,7 @@ function pre_process_msg(msg)
for name,plugin in pairs(plugins) do
if plugin.pre_process and msg then
-- print('Preprocess', name)
msg = plugin.pre_process(msg)
msg = plugin.pre_process(msg)
end
end
@ -125,22 +124,18 @@ function match_plugins(msg)
end
end
-- Check if plugin is on _config.disabled_plugin_on_chat table
local function is_plugin_disabled_on_chat(plugin_name, receiver)
local disabled_chats = _config.disabled_plugin_on_chat
-- Table exists and chat has disabled plugins
if disabled_chats and disabled_chats[receiver] then
-- Checks if plugin is disabled on this chat
for disabled_plugin,disabled in pairs(disabled_chats[receiver]) do
if disabled_plugin == plugin_name and disabled then
local warning = 'Plugin '..disabled_plugin..' ist in diesem Chat deaktiviert'
print(warning)
-- send_msg(receiver, warning, ok_cb, false)
return true
end
end
-- Check if plugin is deactivated in this chat
local function is_plugin_disabled_on_chat(plugin_name, msg)
local hash = get_redis_hash(msg, 'disabled_plugins')
local disabled = redis:hget(hash, plugin_name)
-- Plugin is disabled
if disabled == 'true' then
print('Plugin '..plugin_name..' ist in diesem Chat deaktiviert')
return true
else
return false
end
return false
end
function match_plugin(plugin, plugin_name, msg)
@ -151,20 +146,13 @@ function match_plugin(plugin, plugin_name, msg)
local matches = match_pattern(pattern, msg.text)
if matches then
print("Nachricht stimmt überein mit ", pattern)
-- Send typing
--if pattern ~= ".*" then send_typing(receiver, ok_cb, true) end
if is_plugin_disabled_on_chat(plugin_name, receiver) then
if is_plugin_disabled_on_chat(plugin_name, msg) then
return nil
end
-- Function exists
if plugin.run then
-- check if user has privileges
if can_use_bot(msg) then
print("Gesperrt")
-- local text = 'Du darfst den Bot nicht nutzen!'
-- send_msg(receiver, text, ok_cb, false)
else
if not plugin.notyping then send_typing(receiver, ok_cb, true) end
-- If plugin is for privileged users only
if not warns_user_not_allowed(plugin, msg) then
local result = plugin.run(msg, matches)
@ -173,7 +161,6 @@ function match_plugin(plugin, plugin_name, msg)
end
end
end
end
-- One patterns matches
return
end
@ -185,61 +172,37 @@ function _send_msg(destination, text)
send_large_msg(destination, text)
end
-- Save the content of _config to config.lua
function save_config( )
serialize_to_file(_config, './data/config.lua')
print ('Configuration in ./data/config.lua gespeichert')
-- Load superusers from redis
function load_sudo_users()
if redis:exists("telegram:sudo_users") == false then
-- If sudo_users set doesnt exists
print ("Created new sudo_users set: telegram:sudo_users")
create_sudo_users()
end
local sudo_users = redis:smembers("telegram:sudo_users")
for v,user in pairs(sudo_users) do
print("Superuser: " .. user)
end
return sudo_users
end
-- Returns the config from config.lua file.
-- If file doesn't exist, create it.
function load_config( )
local f = io.open('./data/config.lua', "r")
-- If config.lua doesn't exist
if not f then
print ("Neue Config-Datei erstellt: data/config.lua")
create_config()
else
f:close()
end
local config = loadfile ("./data/config.lua")()
for v,user in pairs(config.sudo_users) do
print("Erlaubter Benutzer: " .. user)
end
return config
end
function load_cred( )
local cf = io.open('./data/credentials.lua', "r")
-- If credentials.lua doesnt exists
if not cf then
print ("Neue Credentials-Datei erstellt: data/credentials.lua")
-- Load credentials from redis
function load_cred()
if redis:exists("telegram:credentials") == false then
-- If credentials hash doesnt exists
print ("Neuen Credentials-Hash erstellt: telegram:credentials")
create_cred()
else
cf:close()
end
local _file_cred = loadfile ("./data/credentials.lua")()
return _file_cred
return redis:hgetall("telegram:credentials")
end
-- Create a basic config.json file and saves it.
function create_config( )
-- A simple config with basic plugins and ourselves as privileged user
config = {
enabled_plugins = {
"help",
"plugins" },
sudo_users = {our_id},
disabled_channels = {}
}
serialize_to_file(config, './data/config.lua')
print ('Configuration in ./data/config.lua gespeichert')
end
function create_cred( )
-- create credentials hash with redis
function create_cred()
cred = {
bitly_access_token = "",
cloudconvert_apikey = "",
cloudinary_apikey = "",
cloudinary_api_secret = "",
cloudinary_public_id = "",
derpibooru_apikey = "",
fb_access_token = "",
flickr_apikey = "",
@ -247,15 +210,20 @@ function create_cred( )
ftp_username = "",
ftp_password = "",
gender_apikey = "",
golem_apikey = "",
google_apikey = "",
google_cse_id = "",
gitlab_private_token = "",
gitlab_project_id = "",
instagram_access_token = "",
lyricsnmusic_apikey = "",
mal_username = "",
mal_pw = "",
neutrino_userid = "",
neutrino_apikey = "",
owm_apikey = "",
page2images_restkey = "",
soundcloud_client_id = "",
superfeedr_authorization = "",
tw_consumer_key = "",
tw_consumer_secret = "",
tw_access_token = "",
@ -266,8 +234,28 @@ function create_cred( )
yourls_site_url = "",
yourls_signature_token = ""
}
serialize_to_file(cred, './data/credentials.lua')
print ('Credentials gespeichert in ./data/credentials.lua')
redis:hmset("telegram:credentials", cred)
print ('Credentials gespeichert in telegram:credentials')
end
function create_sudo_users()
redis:sadd("telegram:sudo_users", '0')
redis:sadd("telegram:sudo_users", '1')
redis:sadd("telegram:sudo_users", our_id)
print('Speichere Superuser in telegram:sudo_users')
print('Adde deine ID mit Redis: SADD telegram:sudo_users YOURID')
end
-- create plugin set if it doesn't exist
function create_plugin_set()
enabled_plugins = {
"plugins",
"manager"
}
print ('enabling a few plugins - saving to redis set telegram:enabled_plugins')
for _,plugin in pairs(enabled_plugins) do
redis:sadd("telegram:enabled_plugins", plugin)
end
end
function on_our_id (id)
@ -291,7 +279,11 @@ end
-- Enable plugins in config.json
function load_plugins()
for k, v in pairs(_config.enabled_plugins) do
enabled_plugins = redis:smembers('telegram:enabled_plugins')
if not enabled_plugins[1] then
create_plugin_set()
end
for k, v in pairs(enabled_plugins) do
print("Lade Plugin", v)
local ok, err = pcall(function()
@ -300,9 +292,10 @@ function load_plugins()
end)
if not ok then
print('\27[31mFehler beim laden des Plugins '..v..'\27[39m')
print('\27[31mFehler beim Laden vom Plugin '..v..'\27[39m')
print('\27[31m'..err..'\27[39m')
end
end
end
@ -324,4 +317,5 @@ end
our_id = 0
now = os.time()
math.randomseed(now)
started = false
started = false

View File

@ -1,14 +1,14 @@
URL = require "socket.url"
http = require "socket.http"
https = require "ssl.https"
http = require("socket.http")
https = require("ssl.https")
ltn12 = require "ltn12"
serpent = require "serpent"
feedparser = require "feedparser"
URL = require("socket.url")
feedparser = require ("feedparser")
json = (loadfile "./libs/JSON.lua")()
serpent = (loadfile "./libs/serpent.lua")()
mimetype = (loadfile "./libs/mimetype.lua")()
redis = (loadfile "./libs/redis.lua")()
http.TIMEOUT = 10
http.TIMEOUT = 5
function get_receiver(msg)
if msg.to.type == 'user' then
@ -19,7 +19,7 @@ function get_receiver(msg)
end
if msg.to.type == 'encr_chat' then
return msg.to.print_name
end
end
end
function is_chat_msg( msg )
@ -45,15 +45,9 @@ function string:split(sep)
return fields
end
-- DEPRECATED
function string.trim(s)
print("string.trim(s) is DEPRECATED use string:trim() instead")
return s:gsub("^%s*(.-)%s*$", "%1")
end
-- Removes spaces
function string:trim()
return self:gsub("^%s*(.-)%s*$", "%1")
function string.trim(s)
return s:gsub("^%s*(.-)%s*$", "%1")
end
function get_http_file_name(url, headers)
@ -63,17 +57,18 @@ function get_http_file_name(url, headers)
file_name = file_name or url:match("[^%w]+(%w+)[^%w]+$")
-- Random name, hope content-type works
file_name = file_name or str:random(5)
local content_type = headers["content-type"]
local content_type = headers["content-type"]
local extension = nil
if content_type then
extension = mimetype.get_mime_extension(content_type)
extension = mimetype.get_mime_extension(content_type)
end
if extension then
file_name = file_name.."."..extension
end
local disposition = headers["content-disposition"]
if disposition then
-- attachment; filename=CodeCogsEqn.png
@ -95,7 +90,7 @@ function download_to_file(url, file_name)
url = url,
sink = ltn12.sink.table(respbody),
redirect = true
}
}
-- nil, code, headers, status
local response = nil
@ -147,16 +142,15 @@ function run_command(str)
return result
end
-- User has privileges
function is_sudo(msg)
local var = false
-- Check users id in config
for v,user in pairs(_config.sudo_users) do
if user == msg.from.id then
var = true
end
end
return var
local var = false
-- Check if user id is in sudoers table
for v,user in pairs(sudo_users) do
if string.match(user, msg.from.id) then
var = true
end
end
return var
end
function can_use_bot(msg)
@ -172,11 +166,11 @@ end
-- Returns the name of the sender
function get_name(msg)
local name = msg.from.first_name
if name == nil then
name = msg.from.id
end
return name
local name = msg.from.first_name
if name == nil then
name = msg.from.id
end
return name
end
-- Returns at table of lua files inside plugins
@ -255,27 +249,33 @@ end
-- Download the image and send to receiver, it will be deleted.
-- cb_function and cb_extra are optionals callback
function send_photo_from_url(receiver, url, cb_function, cb_extra)
function send_photo_from_url(receiver, url, cb_function, cb_extra, sendNotErrMsg)
-- If callback not provided
cb_function = cb_function or ok_cb
cb_extra = cb_extra or false
local file_path = download_to_file(url, false)
if not file_path then -- Error
local text = 'Fehler beim laden des Bildes'
send_msg(receiver, text, cb_function, cb_extra)
if sendNotErrMsg then
return false
else
local text = 'Fehler beim Laden des Bildes'
send_msg(receiver, text, cb_function, cb_extra)
end
else
print("Datei Pfad: "..file_path)
_send_photo(receiver, file_path, cb_function, cb_extra)
return true
end
end
-- Same as send_photo_from_url but as callback function
function send_photo_from_url_callback(cb_extra, success, result)
function send_photo_from_url_callback(cb_extra, success, result, sendErrMsg)
local receiver = cb_extra.receiver
local url = cb_extra.url
local file_path = download_to_file(url, false)
if not file_path then -- Error
local text = 'Fehler beim laden des Bildes'
local text = 'Fehler beim Herunterladen des Bildes'
send_msg(receiver, text, ok_cb, false)
else
print("Datei Pfad: "..file_path)
@ -283,6 +283,21 @@ function send_photo_from_url_callback(cb_extra, success, result)
end
end
-- Same as above, but with send_as_document
function send_document_from_url_callback(cb_extra, success, result)
local receiver = cb_extra.receiver
local url = cb_extra.url
local file_path = download_to_file(url, false)
if not file_path then -- Error
local text = 'Fehler beim Herunterladen des Dokumentes'
send_msg(receiver, text, ok_cb, false)
else
print("File path: "..file_path)
_send_document(receiver, file_path, ok_cb, false)
end
end
-- Send multiple images asynchronous.
-- param urls must be a table.
function send_photos_from_url(receiver, urls)
@ -355,10 +370,24 @@ end
-- Download the image and send to receiver, it will be deleted.
-- cb_function and cb_extra are optionals callback
function send_document_from_url(receiver, url, cb_function, cb_extra)
function send_document_from_url(receiver, url, cb_function, cb_extra, sendNotErrMsg)
-- If callback not provided
cb_function = cb_function or ok_cb
cb_extra = cb_extra or false
local file_path = download_to_file(url, false)
print("Datei Pfad: "..file_path)
_send_document(receiver, file_path, cb_function, cb_extra)
if not file_path then -- Error
if sendNotErrMsg then
return false
else
local text = 'Fehler beim Herunterladen des Dokumentes'
send_msg(receiver, text, cb_function, cb_extra)
end
else
print("Datei Pfad: "..file_path)
_send_document(receiver, file_path, cb_function, cb_extra)
return true
end
end
-- Parameters in ?a=1&b=2 style
@ -409,48 +438,6 @@ function send_order_msg(destination, msgs)
send_order_msg_callback(cb_extra, true)
end
function send_order_msg_callback(cb_extra, success, result)
local destination = cb_extra.destination
local msgs = cb_extra.msgs
local file_path = cb_extra.file_path
if file_path ~= nil then
os.remove(file_path)
print("Deleted: " .. file_path)
end
if type(msgs) == 'string' then
send_large_msg(destination, msgs)
elseif type(msgs) ~= 'table' then
return
end
if #msgs < 1 then
return
end
local msg = table.remove(msgs, 1)
local new_cb_extra = {
destination = destination,
msgs = msgs
}
if type(msg) == 'string' then
send_msg(destination, msg, send_order_msg_callback, new_cb_extra)
elseif type(msg) == 'table' then
local typ = msg[1]
local nmsg = msg[2]
new_cb_extra.file_path = nmsg
if typ == 'document' then
send_document(destination, nmsg, send_order_msg_callback, new_cb_extra)
elseif typ == 'image' or typ == 'photo' then
send_photo(destination, nmsg, send_order_msg_callback, new_cb_extra)
elseif typ == 'audio' then
send_audio(destination, nmsg, send_order_msg_callback, new_cb_extra)
elseif typ == 'video' then
send_video(destination, nmsg, send_order_msg_callback, new_cb_extra)
else
send_file(destination, nmsg, send_order_msg_callback, new_cb_extra)
end
end
end
-- Same as send_large_msg_callback but friendly params
function send_large_msg(destination, text)
local cb_extra = {
destination = destination,
@ -486,17 +473,13 @@ function send_large_msg_callback(cb_extra, success, result)
end
-- Returns a table with matches or nil
function match_pattern(pattern, text, lower_case)
--function match_pattern(pattern, text, lower_case)
function match_pattern(pattern, text)
if text then
local matches = {}
if lower_case then
matches = { string.match(text:lower(), pattern) }
else
matches = { string.match(text, pattern) }
end
if next(matches) then
return matches
end
local matches = { string.match(text, pattern) }
if next(matches) then
return matches
end
end
-- nil
end
@ -521,7 +504,7 @@ function load_from_file(file, default_data)
return loadfile (file)()
end
function run_bash(str)
function run_bash(str)
local cmd = io.popen(str)
local result = cmd:read('*all')
cmd:close()
@ -536,11 +519,26 @@ function run_sh(msg)
return text
end
function round(num, idp)
if idp and idp>0 then
local mult = 10^idp
return math.floor(num * mult + 0.5) / mult
end
return math.floor(num + 0.5)
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, "&Auml;", "Ä")
str = string.gsub( str, "&auml;", "ä")
str = string.gsub( str, "&Ouml;", "Ö")
str = string.gsub( str, "&ouml;", "ö")
str = string.gsub( str, "Uuml;", "Ü")
str = string.gsub( str, "&uuml;", "ü")
str = string.gsub( str, "&szlig;", "ß")
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
@ -563,4 +561,83 @@ function unescape_html(str)
return var
end)
return new
end
function post_petition(url, arguments)
local url, h = string.gsub(url, "http://", "")
local url, hs = string.gsub(url, "https://", "")
local post_prot = "http"
if hs == 1 then
post_prot = "https"
end
local response_body = {}
local request_constructor = {
url = post_prot..'://'..url,
method = "POST",
sink = ltn12.sink.table(response_body),
headers = {},
redirect = false
}
local source = arguments
if type(arguments) == "table" then
local source = helpers.url_encode_arguments(arguments)
end
request_constructor.headers["Content-Type"] = "application/x-www-form-urlencoded"
request_constructor.headers["Content-Length"] = tostring(#source)
request_constructor.source = ltn12.source.string(source)
if post_prot == "http" then
ok, response_code, response_headers, response_status_line = http.request(request_constructor)
else
ok, response_code, response_headers, response_status_line = https.request(request_constructor)
end
if not ok then
return nil
end
response_body = json:decode(table.concat(response_body))
return response_body
end
function get_redis_hash(msg, var)
if msg.to.type == 'chat' then
return 'chat:'..msg.to.id..':'..var
end
if msg.to.type == 'user' then
return 'user:'..msg.from.id..':'..var
end
end
function tablelength(T)
local count = 0
for _ in pairs(T) do count = count + 1 end
return count
end
function comma_value(amount)
local formatted = amount
while true do
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1.%2')
if (k==0) then
break
end
end
return formatted
end
function string.ends(str, fin)
return fin=='' or string.sub(str,-string.len(fin)) == fin
end
function get_location(user_id)
local hash = 'user:'..user_id
local set_location = redis:hget(hash, 'location')
if set_location == 'false' or set_location == nil then
return false
else
return set_location
end
end

BIN
pictures/inlove.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

View File

@ -6,8 +6,7 @@ local function get_9GAG()
if c ~= 200 then return nil end
local gag = json:decode(b)
-- random max json table size
local i = math.random(#gag)
local link_image = gag[i].src
local i = math.random(#gag) local link_image = gag[i].src
local title = gag[i].title
if link_image:sub(0,2) == '//' then
link_image = msg.text:sub(3,-1)
@ -15,23 +14,22 @@ local function get_9GAG()
return link_image, title
end
local function send_title(cb_extra, success, result)
if success then
send_msg(cb_extra[1], cb_extra[2], ok_cb, false)
end
end
local function run(msg, matches)
local receiver = get_receiver(msg)
local url, title = get_9GAG()
send_photo_from_url(receiver, url, send_title, {receiver, title})
return false
local cb_extra = {
receiver=receiver,
url=url
}
send_msg(receiver, title, send_photo_from_url_callback, cb_extra)
end
return {
description = "9GAG",
usage = {"/9gag"},
patterns = {"^/9gag$"},
description = "Sendet ein zufälliges Bild von 9GAG",
usage = "/9gag: Sendet ein zufälliges Bild von 9GAG.",
patterns = {
"^/9gag$"
},
run = run
}

View File

@ -1,23 +1,102 @@
function run(msg, matches)
local text = matches[2]
do
local function is_offline(hash)
local afk = redis:hget(hash, 'afk')
if afk == "true" then
return true
else
return false
end
end
local function get_afk_text(hash)
local afk_text = redis:hget(hash, 'afk_text')
if afk_text ~= nil and afk_text ~= "" and afk_text ~= "false" then
return afk_text
else
return false
end
end
local function switch_afk(user_name, user_id, chat_id, text)
local hash = 'afk:'..chat_id..':'..user_id
if is_offline(hash) then
local afk_text = get_afk_text(hash)
if afk_text then
return 'Du bist bereits AFK ('..afk_text..')!'
else
return 'Du bist bereits AFK!'
end
end
print('Setting redis hash afk in '..hash..' to true')
redis:hset(hash, 'afk', true)
if text then
print('Setting redis hash afk_text in '..hash..' to '..text)
redis:hset(hash, 'afk_text', text)
return user_name..' ist AFK ('..text..')'
else
return user_name..' ist AFK'
end
end
local function pre_process(msg)
if msg.to.type ~= "chat" then
-- Ignore
return msg
end
local receiver = get_receiver(msg)
local user_name = get_name(msg)
local user_id = msg.from.id
local chat_id = msg.to.id
local hash = 'afk:'..chat_id..':'..user_id
if is_offline(hash) then
local afk_text = get_afk_text(hash)
redis:hset(hash, 'afk', false)
if afk_text then
redis:hset(hash, 'afk_text', false)
send_msg(receiver, user_name..' ist wieder da (war: '..afk_text..')!', ok_cb, false)
else
send_msg(receiver, user_name..' ist wieder da!', ok_cb, false)
end
end
return msg
end
local function run(msg, matches)
if msg.to.type ~= "chat" then
return "Mir ist's egal, ob du AFK bist ._."
end
local user_id = msg.from.id
local chat_id = msg.to.id
local user_name = get_name(msg)
if string.starts(msg.text, '/afk') and (text == nil) then
return user_name .. ' ist nun AFK'
else
return user_name .. ' ist nun AFK (' .. text .. ')'
end
--[[if string.starts(msg.text, '/re') or string.starts(msg.text, '/wd') then
return user_name .. ' ist wieder da!'
end]]
if matches[2] then
return switch_afk(user_name, user_id, chat_id, matches[2])
else
return switch_afk(user_name, user_id, chat_id)
end
end
return {
description = 'Sagt dass ihr afk oder wieder da seid',
usage = {'/afk','/re','/wd'},
patterns = {'^/([A|a][F|f][K|k])$','^/([A|a][F|f][K|k]) (.*)$','^/([R|r][E|e])$','^/([W|w][D|d])$'},
run = run
description = 'AFK und online schalten',
usage = "/afk (Text): Setzt Status auf AFK mit optionalem Text",
patterns = {
"^/([A|a][F|f][K|k])$",
"^/([A|a][F|f][K|k]) (.*)$"
},
run = run,
pre_process = pre_process
}
--by Akamaru [https://ponywave.de]
-- by Akamaru [https://ponywave.de]
-- modified by iCON [http://wiidatabase.de]
end

54
plugins/aktien.lua Normal file
View File

@ -0,0 +1,54 @@
-- 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 function get_stock (symbol)
local BASE_URL = 'https://query.yahooapis.com/v1/public/yql'
local url = BASE_URL..'?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol="'..symbol..'"&env=http%3A%2F%2Fdatatables.org%2Falltables.env&format=json'
local res,code = https.request(url)
if code ~= 200 then return "HTTP-FEHLER" end
local data = json:decode(res).query.results.quote
return data
end
function send_stock_data(data, receiver)
-- local ask = data.Ask
local bid = data.Bid
local change = data.Change
local percent = data.ChangeinPercent
local currency = data.Currency
local range = data.DaysRange
local name = data.Name
local yesterday = data.PreviousClose
local year_range = data.YearRange
local symbol = data.symbol
local text = name..' ('..symbol..') Aktien in '..currency..':\nAktueller Preis: '..bid..' ('..change..' / '..percent..')\nGestriger Preis: '..yesterday..'\nHeute: '..range..'\nDieses Jahr: '..year_range
send_msg(receiver, text, ok_cb, false)
end
local function run(msg, matches)
local symbol = string.upper(matches[1])
local data = get_stock(symbol)
local receiver = get_receiver(msg)
if data.Bid ~= nil then
send_stock_data(data, receiver)
else
return "Dieses Symbol existiert nicht."
end
end
return {
description = "Sendet Aktieninfos",
usage = "/aktien [Symbol]: Sendet Aktieninfos",
patterns = {
"^/aktien ([A-Za-z0-9]+)$",
"^/stocks ([A-Za-z0-9]+)$",
"^/aktie ([A-Za-z0-9]+)$",
"^/stock ([A-Za-z0-9]+)$"
},
run = run
}
end

View File

@ -8,7 +8,9 @@ end
return {
description = "Ist der Bot noch da?",
usage = {"Miku"},
patterns = {"^[M|m]iku(?)$","^[M|m]iku$"},
patterns = {"^[Mm][Ii][Kk][Uu](?)$",
"^[Mm][Ii][Kk][Uu]$"
},
run = run
}
--by Akamaru [https://ponywave.de]

122
plugins/app_store.lua Normal file
View File

@ -0,0 +1,122 @@
-- 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://itunes.apple.com/lookup'
local makeOurDate = function(dateString)
local pattern = "(%d+)%-(%d+)%-(%d+)T"
local year, month, day = dateString:match(pattern)
return day..'.'..month..'.'..year
end
local function get_appstore_data()
local url = BASE_URL..'/?id='..appid..'&country=de'
local res,code = https.request(url)
if code ~= 200 then return "HTTP-FEHLER" end
local data = json:decode(res).results[1]
if data == nil then return 'NOTFOUND' end
if data.wrapperType ~= 'software' then return nil end
return data
end
local function send_appstore_data(data, receiver)
-- Header
local name = data.trackName
local author = data.sellerName
local price = data.formattedPrice
local version = data.version
-- Body
local description = string.sub(unescape(data.description), 1, 150) .. '...'
local min_ios_ver = data.minimumOsVersion
local size = string.gsub(round(data.fileSizeBytes / 1000000, 2), "%.", "%,") -- wtf Apple, it's 1024, not 1000!
local release = makeOurDate(data.releaseDate)
if data.isGameCenterEnabled then
game_center = '\nUnterstützt Game Center'
else
game_center = ''
end
local category_count = tablelength(data.genres)
if category_count == 1 then
category = '\nKategorie: '..data.genres[1]
else
local category_loop = '\nKategorien: '
for v in pairs(data.genres) do
if v < category_count then
category_loop = category_loop..data.genres[v]..', '
else
category_loop = category_loop..data.genres[v]
end
end
category = category_loop
end
-- Footer
if data.averageUserRating and data.userRatingCount then
avg_rating = 'Bewertung: '..string.gsub(data.averageUserRating, "%.", "%,")..' Sterne '
ratings = 'von '..comma_value(data.userRatingCount)..' Bewertungen'
else
avg_rating = ""
ratings = ""
end
local header = name..' v'..version..' von '..author..' ('..price..'):'
local body = '\n'..description..'\nBenötigt mind. iOS '..min_ios_ver..'\nGröße: '..size..' MB\nErstveröffentlicht am '..release..game_center..category
local footer = '\n'..avg_rating..ratings
local text = header..body..footer
-- Picture
if data.screenshotUrls[1] and data.ipadScreenshotUrls[1] then
image_url = data.screenshotUrls[1]
elseif data.screenshotUrls[1] and not data.ipadScreenshotUrls[1] then
image_url = data.screenshotUrls[1]
elseif not data.screenshotUrls[1] and data.ipadScreenshotUrls[1] then
image_url = data.ipadScreenshotUrls[1]
else
image_url = nil
end
if image_url then
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 receiver = get_receiver(msg)
if not matches[3] then
appid = matches[1]
else
appid = matches[3]
end
local data = get_appstore_data()
if data == nil then print('Das Appstore-Plugin unterstützt zurzeit nur Apps!') end
if data == 'HTTP-FEHLER' or data == 'NOTFOUND' then
return 'App nicht gefunden!'
else
send_appstore_data(data, receiver)
end
end
return {
description = "Sendet iPhone App-Store Info.",
usage = {"Link zu App auf iTunes",
"/itunes (ID)"
},
patterns = {"itunes.apple.com/(.*)/app/(.*)/id(%d+)",
"^/itunes (%d+)$"
},
run = run
}
end

51
plugins/birthday_get.lua Normal file
View File

@ -0,0 +1,51 @@
local function get_value(msg, var_name)
local hash = 'telegram:birthdays'
if hash then
local value = redis:hget(hash, var_name)
if not value then
return'Geburtstag nicht gefunden, benutze "/getbd", um alle Geburtstage aufzulisten.'
else
return var_name..' hat am '..value..' Geburtstag'
end
end
end
local function list_variables(msg)
local hash = 'telegram:birthdays'
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 'Keine Geburtstage vorhanden!'
else
return text
end
end
end
local function run(msg, matches)
if matches[2] then
return get_value(msg, matches[2])
else
return 'Geburtstagsliste:\n\n'..list_variables(msg)
end
end
return {
description = "Zeigt Geburtstage, die mit /setbd gesetzt wurden",
usage = {
"/getbd: Gibt alle Geburtstage aus",
"/getbd (Name): Gibt den Geburtstag aus."
},
patterns = {
"^(/getbd) (.+)$",
"^/getbd$"
},
run = run
}

47
plugins/birthday_set.lua Normal file
View File

@ -0,0 +1,47 @@
local function save_value(msg, name, value)
if (not name or not value) then
return "Benutzung: /setbd [Name] [Tag. Monat]"
end
local hash = 'telegram:birthdays'
if hash then
print('Saving variable to redis hash '..hash)
redis:hset(hash, name, value)
return "Geburtstag von "..name.." am "..value.." gespeichert!"
end
end
local function delete_value(msg, name)
local hash = 'telegram:birthdays'
if redis:hexists(hash, name) == true then
print('Deleting birthday from redis hash '..hash)
redis:hdel(hash, name)
return 'Geburtstag von "'..name..'" erfolgreich gelöscht!'
else
return 'Du kannst keinen Geburtstag löschen, der nicht existiert ._.'
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 = "Speichert Geburtstage.",
usage = {
"/setbd [Name] [Tag. Monat]: Speichert ein Geburtstag.",
"/setbd (Name) nil: Löscht Geburtstag"
},
patterns = {
"^/setbd ([^%s]+) (.+)$"
},
run = run
}

34
plugins/bitly.lua Normal file
View File

@ -0,0 +1,34 @@
-- 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://api-ssl.bitly.com/v3/expand'
local function expand_bitly_link (shorturl)
local access_token = cred_data.bitly_access_token
local url = BASE_URL..'?access_token='..access_token..'&shortUrl=https://bit.ly/'..shorturl
local res,code = https.request(url)
if code ~= 200 then return "HTTP-FEHLER" end
local data = json:decode(res).data
return data.expand[1].long_url
end
local function run(msg, matches)
local shorturl = matches[1]
return expand_bitly_link(shorturl)
end
return {
description = "Verlängert Bitly-Links",
usage = "Verlängert bit.ly, bitly.com, j.mp und andib.tk Links",
patterns = {
"bit.ly/([A-Za-z0-9-_-]+)",
"bitly.com/([A-Za-z0-9-_-]+)",
"j.mp/([A-Za-z0-9-_-]+)",
"andib.tk/([A-Za-z0-9-_-]+)"
},
run = run
}
end

43
plugins/bitly_create.lua Normal file
View File

@ -0,0 +1,43 @@
-- 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://api-ssl.bitly.com/v3/shorten'
local access_token = cred_data.bitly_access_token
function create_bitlink (long_url, domain)
local url = BASE_URL..'?access_token='..access_token..'&domain='..domain..'&longUrl='..long_url..'&format=txt'
local text,code = https.request(url)
if code ~= 200 then return 'FEHLER: '..text end
return text
end
function run(msg, matches)
if matches[2] == nil then
long_url = url_encode(matches[1])
domain = 'bit.ly'
else
long_url = url_encode(matches[2])
domain = matches[1]
end
return create_bitlink(long_url, domain)
end
return {
description = "Kürzt einen Link",
usage = {
"/short [Link]: Kürzt einen Link mit Bitly",
"/short [j.mp|bit.ly|bitly.com|andib.tk] [Link]: Kürzt einen Link mit der ausgewählten Kurz-URL"
},
patterns = {
"^/short (j.mp) (https?://[%w-_%.%?%.:/%+=&]+)$",
"^/short (bit.ly) (https?://[%w-_%.%?%.:/%+=&]+)$",
"^/short (bitly.com) (https?://[%w-_%.%?%.:/%+=&]+)$",
"^/short (andib.tk) (https?://[%w-_%.%?%.:/%+=&]+)$",
"^/short (https?://[%w-_%.%?%.:/%+=&]+)$"
},
run = run
}
end

View File

@ -6,9 +6,11 @@ local function getBTCX(amount,currency)
if code ~= 200 then return nil end
local data = json:decode(res)
local ask = string.gsub(data.ask, "%.", "%,")
local bid = string.gsub(data.bid, "%.", "%,")
-- Easy, it's right there
text = "BTC/"..currency..'\n'..'Buy: '..data.ask..'\n'..'Sell: '..data.bid
text = "BTC/"..currency..'\n'..'Kaufen: '..ask..'\n'..'Verkaufen: '..bid
-- If we have a number as second parameter, calculate the bitcoin amount
if amount~=nil then
@ -39,14 +41,17 @@ local function run(msg, matches)
end
return {
description = "Bitcoin global average market value (in EUR or USD)",
usage = "!btc [EUR|USD] [amount]",
description = "Globaler Bitcoin-Wert (in EUR oder USD)",
usage = {
"/btc: Zeigt aktuellen Bitcoin-Kurs",
"/btc [EUR|USD] [Menge]: Rechnet Bitcoin in Euro/USD um"
},
patterns = {
"^!btc$",
"^!btc ([Ee][Uu][Rr])$",
"^!btc ([Uu][Ss][Dd])$",
"^!btc (EUR) (%d+[%d%.]*)$",
"^!btc (USD) (%d+[%d%.]*)$"
"^/btc$",
"^/btc ([Ee][Uu][Rr])$",
"^/btc ([Uu][Ss][Dd])$",
"^/btc (EUR) (%d+[%d%.]*)$",
"^/btc (USD) (%d+[%d%.]*)$"
},
run = run
}
}

View File

@ -10,6 +10,7 @@ return {
description = "",
usage = {""},
patterns = {"^/pic (.*)$"},
run = run
run = run,
notyping = true
}
--by Akamaru [https://ponywave.de]

View File

@ -1,53 +1,50 @@
-- Checks if bot was disabled on specific chat
local function is_channel_disabled( receiver )
if not _config.disabled_channels then
local function is_channel_disabled(msg)
local hash = 'chat:'..msg.to.id..':disabled'
local disabled = redis:get(hash)
if not disabled or disabled == "false" then
return false
end
if _config.disabled_channels[receiver] == nil then
return false
end
return _config.disabled_channels[receiver]
return disabled
end
local function enable_channel(receiver)
if not _config.disabled_channels then
_config.disabled_channels = {}
end
if _config.disabled_channels[receiver] == nil then
return 'Channel ist nicht deaktiviert!'
end
_config.disabled_channels[receiver] = false
save_config()
return "Channel wieder aktiviert!"
local function enable_channel(msg)
local hash = 'chat:'..msg.to.id..':disabled'
local disabled = redis:get(hash)
if disabled then
print('Setze Redis Variable "'..hash..'" auf false')
redis:set(hash, false)
return 'Channel aktiviert'
else
return 'Channel ist nicht deaktiviert!'
end
end
local function disable_channel( receiver )
if not _config.disabled_channels then
_config.disabled_channels = {}
end
_config.disabled_channels[receiver] = true
save_config()
return "Channel deaktiviert!"
local function disable_channel(msg)
local hash = 'chat:'..msg.to.id..':disabled'
local disabled = redis:get(hash)
if disabled ~= "true" then
print('Setze Redis Variable "'..hash..'" auf true')
redis:set(hash, true)
return 'Channel deaktiviert'
else
return 'Channel ist bereits deaktiviert!'
end
end
local function pre_process(msg)
local receiver = get_receiver(msg)
-- If sender is sudo then re-enable the channel
-- If is sudo can reeanble the channel
if is_sudo(msg) then
if msg.text == "/channel enable" then
enable_channel(receiver)
enable_channel(msg)
end
end
if is_channel_disabled(receiver) then
if is_channel_disabled(msg) then
print('Channel wurde deaktiviert')
msg.text = ""
end
@ -55,22 +52,28 @@ local function pre_process(msg)
end
local function run(msg, matches)
local receiver = get_receiver(msg)
-- Enable a channel
if matches[1] == 'enable' then
return enable_channel(receiver)
return enable_channel(msg)
end
-- Disable a channel
if matches[1] == 'disable' then
return disable_channel(receiver)
return disable_channel(msg)
end
end
return {
description = "",
usage = {"/channel kann nur Akamaru"},
patterns = {"^/channel? (enable)","^/channel? (disable)" },
run = run,
privileged = true,
pre_process = pre_process
description = "(De)aktiviert den Bot im Chat (nur Superuser).",
usage = {
"/channel enable: Aktiviert den Bot im Chat",
"/channel disable: Deaktiviert den Bot im Chat"
},
patterns = {
"^/channel? (enable)",
"^/channel? (disable)"
},
run = run,
privileged = true,
pre_process = pre_process,
notyping = true
}

27
plugins/cleverbot.lua Normal file
View File

@ -0,0 +1,27 @@
do
function run(msg, matches)
local text = msg.text
local url = "http://nocf.andibi.tk/dl/chatter-bot-api/cleverbot.php?text="..URL.escape(text)
local query = http.request(url)
if query == nil then return 'Ein Fehler ist aufgetreten :(' end
local decode = json:decode(query)
local answer = string.gsub(decode.clever, "&Auml;", "Ä")
local answer = string.gsub(answer, "&auml;", "ä")
local answer = string.gsub(answer, "&Ouml;", "Ö")
local answer = string.gsub(answer, "&ouml;", "ö")
local answer = string.gsub(answer, "&Uuml;", "Ü")
local answer = string.gsub(answer, "&uuml;", "ü")
local answer = string.gsub(answer, "&szlig;", "ß")
return answer
end
return {
description = "Chat mit CleverBot",
usage = "/cbot [Text]: Befragt den Cleverbot",
patterns = {"^/cbot (.*)$"},
run = run
}
end

View File

@ -0,0 +1,57 @@
-- 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

@ -0,0 +1,118 @@
-- This file is part of the Telegram Bot "Brawlbot" (telegram.me/Brawlbot) by Andreas Bielawski (telegram.me/Brawl)
-- Released unter the MPLv2
local hash = "telegram:credentials"
-- See: http://www.lua.org/pil/19.3.html
function pairsByKeys (t, f)
local a = {}
for n in pairs(t) do table.insert(a, n) end
table.sort(a, f)
local i = 0 -- iterator variable
local iter = function () -- iterator function
i = i + 1
if a[i] == nil then
return nil
else
return a[i], t[a[i]]
end
end
return iter
end
function reload_creds()
cred_data = redis:hgetall(hash)
end
function list_creds()
reload_creds()
if redis:exists("telegram:credentials") == true then
local text = ""
for var, key in pairsByKeys(cred_data) do
text = text..var..' = '..key..'\n'
end
return text
else
create_cred()
return "Es wurden noch keine Logininformationen gespeichert, lege Tabelle an...\nSpeichere Keys mit !creds add [Variable] [Key] ein!"
end
end
function add_creds(var, key)
print('Saving credential for '..var..' to redis hash '..hash)
redis:hset(hash, var, key)
reload_creds()
return var..' = '..key..'\neingespeichert!'
end
function del_creds(var)
if redis:hexists(hash, var) == true then
print('Deleting credential for '..var..' from redis hash '..hash)
redis:hdel(hash, var)
reload_creds()
return 'Key von "'..var..'" erfolgreich gelöscht!'
else
return 'Du hast keine Logininformationen für diese Variable eingespeichert.'
end
end
function rename_creds(var, newvar)
if redis:hexists(hash, var) == true then
local key = redis:hget(hash, var)
if redis:hsetnx(hash, newvar, key) == true then
redis:hdel(hash, var)
reload_creds()
return '"'..var..'" erfolgreich zu "'..newvar..'" umbenannt.'
else
return "Variable konnte nicht umbenannt werden: Zielvariable existiert bereits."
end
else
return 'Die zu umbennende Variable existiert nicht.'
end
end
function run(msg, matches)
local receiver = get_receiver(msg)
if not is_sudo(msg) then
return 'Du bist kein Superuser. Dieser Vorfall wird gemeldet!'
end
if msg.to.type == 'chat' then
return 'Das Plugin solltest du nur per PN nutzen!'
end
if matches[1] == "!creds" then
return list_creds()
elseif matches[1] == "!creds add" then
local var = string.lower(string.sub(matches[2], 1, 50))
local key = string.sub(matches[3], 1, 1000)
return add_creds(var, key)
elseif matches[1] == "!creds del" then
local var = string.lower(matches[2])
return del_creds(var)
elseif matches[1] == "!creds rename" then
local var = string.lower(string.sub(matches[2], 1, 50))
local newvar = string.lower(string.sub(matches[3], 1, 1000))
return rename_creds(var, newvar)
end
end
return {
description = "Loginmanager für Telegram (nur Superuser)",
usage = {
"/creds: Zeigt alle Logindaten und API-Keys",
"/creds add [Variable] [Key]: Speichert Key mit der Variable ein",
"/creds del [Variable]: Löscht Key mit der Variable",
"/creds rename [Variable] [Neuer Name]: Benennt Variable um, behält Key bei"
},
patterns = {
"^(/creds)$",
"^(/creds add) ([^%s]+) (.+)$",
"^(/creds del) (.+)$",
"^(/creds rename) ([^%s]+) (.+)$"
},
run = run,
privileged = true,
notyping = true
}

View File

@ -5,9 +5,12 @@ function run(msg, matches)
return 'Vergiss es'
end
if string.match(msg.text, '/[Hh][Ee][Aa][Dd]') then
if string.match(msg.text, '[Hh][Ee][Aa][Dd]') then
text = run_bash('curl --head --insecure ' .. URL)
send_msg(receiver, text, ok_cb, false)
elseif string.match(msg.text, '[Dd][Ii][Gg]') then
text = run_bash('dig ' .. URL .. ' ANY')
send_msg(receiver, text, ok_cb, false)
end
end
@ -15,6 +18,7 @@ end
return {
description = "Führt Befehle in der Konsole aus",
usage = {""},
patterns = {"^/[Hh][Ee][Aa][Dd] (https?://[%w-_%.%?%.:/%+=&]+)$"},
patterns = {"^/[Hh][Ee][Aa][Dd] (.*)$","^/[Dd][Ii][Gg] (.*)"},
run = run
}
}
--by Akamaru [https://ponywave.de]

64
plugins/currency.lua Normal file
View File

@ -0,0 +1,64 @@
-- 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://currencyconverter.p.mashape.com'
local function get_currency_data (from, to, amount)
local apikey = cred_data.x_mashape_key
local url = BASE_URL..'/?from='..from..'&from_amount='..amount..'&to='..to..'&mashape-key='..apikey
local res,code = https.request(url)
if code ~= 200 then return "HTTP-FEHLER" end
local data = json:decode(res)
return data
end
local function send_currency_data(data, receiver)
if data.error ~= nil then
return
else
local from = data.from
local to = data.to
local from_amount = string.gsub(data.from_amount, "%.", "%,")
local dot_to_amount = round(data.to_amount, 2)
local to_amount = string.gsub(dot_to_amount, "%.", "%,")
local text = from_amount..' '..from..' = '..to_amount..' '..to
send_msg(receiver, text, ok_cb, false)
end
end
local function run(msg, matches)
local from = string.upper(matches[1])
if matches[2] == nil then
to = "EUR"
else
to = string.upper(matches[2])
end
if matches[3] == nil then
amount = 1
else
amount = string.gsub(matches[3],"%,","%.")
end
if matches[1] == "/eur" then
to = "USD"
from = "EUR"
end
local data = get_currency_data(from, to, amount)
local receiver = get_receiver(msg)
send_currency_data(data, receiver)
end
return {
description = "Wandelt Geldeinheiten um. ?? ?? ??",
usage = "/money [von] [zu] [Menge]: Wandelt Geldeinheiten um (Symbole: ponywave.de/a/botmoney)",
patterns = {
"^/money ([A-Za-z]+)$",
"^/money ([A-Za-z]+) ([A-Za-z]+)$",
"^(money ([A-Za-z]+) ([A-Za-z]+) (%d+[%d%.,]*)$",
"^(/eur)$"
},
run = run
}
end

37
plugins/dailymotion.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://api.dailymotion.com'
function get_dm_data (dm_code)
local url = BASE_URL..'/video/'..dm_code
local res,code = https.request(url)
if code ~= 200 then return "HTTP-FEHLER" end
local data = json:decode(res)
return data
end
function send_dailymotion_data(data, receiver)
local title = data.title
local channel = data.channel
local text = title..'\nHochgeladen in die Kategorie "'..channel..'"'
send_msg(receiver, text, ok_cb, false)
end
function run(msg, matches)
local dm_code = matches[1]
local data = get_dm_data(dm_code)
local receiver = get_receiver(msg)
send_dailymotion_data(data, receiver)
end
return {
description = "Sendet Dailymotion-Info.",
usage = "URL zu Dailymotion-Video",
patterns = {"dailymotion.com/video/([A-Za-z0-9-_-]+)"},
run = run
}
end

41
plugins/danbooru2.lua Normal file
View File

@ -0,0 +1,41 @@
-- 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 function get_db(tag)
local BASE_URL = 'http://danbooru.donmai.us'
local url = BASE_URL..'/posts.json?tags='..tag
local b,c = http.request(url)
if c ~= 200 then return nil end
local db = json:decode(b)
-- truly randomize
math.randomseed(os.time())
-- random max json table size
local i = math.random(#db)
local link_image = BASE_URL..db[i].file_url
return link_image
end
local function run(msg, matches)
local tag = matches[1]
local tag = string.gsub(tag, " ", '_' )
local tag = string.gsub(tag, ":", '%%3A' )
local receiver = get_receiver(msg)
local url = get_db(tag)
if string.ends(url, ".gif") or string.ends(url, ".zip") or string.ends(url, ".webm") then
send_document_from_url(receiver, url)
else
send_photo_from_url(receiver, url, send_title, {receiver, title})
end
return "Source: "..url
end
return {
description = "Sendet ein zufälliges Bild von Danbooru.",
usage = {"/danbooru [Tags]","/db [Tags]"},
patterns = {"^/danbooru (.*)$","^/db (.*)$"},
run = run
}
end

45
plugins/derpibooru.lua Normal file
View File

@ -0,0 +1,45 @@
-- 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 function get_dp(tag)
local BASE_URL = 'https://derpiboo.ru/'
local apikey = ""
-- Ohne API-Key: Safe for work - mit API-Key: Not safe for work
if apikey == nil then
url = BASE_URL..'/search.json?q='..tag
else
url = BASE_URL..'/search.json?key='..apikey..'&q='..tag
end
local b,c = https.request(url)
if c ~= 200 then return nil end
local dp = json:decode(b).search
-- truly randomize
math.randomseed(os.time())
-- random max json table size
local i = math.random(#dp)
local link_image = 'https:'..dp[i].image
source = 'https://derpiboo.ru/'..dp[i].id_number
return link_image
end
local function run(msg, matches)
local tag = matches[1]
local tag = string.gsub(tag, " ", '+' )
local receiver = get_receiver(msg)
local url = get_dp(tag)
send_photo_from_url(receiver, url, send_title, {receiver, title})
return "Source: "..source
end
return {
description = "Sendet zufälliges Bild von Derpibooru.",
usage = {"/derpibooru [Tags]","/dp [Tags]"},
patterns = {"^/derpibooru (.*)$","^/dp (.*)$"},
run = run
}
end

View File

@ -0,0 +1,45 @@
-- 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 function get_dp2(tag)
local BASE_URL = 'https://derpiboo.ru/'
local apikey = cred_data.derpibooru_apikey
-- Ohne API-Key: Safe for work - mit API-Key: Not safe for work
if apikey == nil then
url = BASE_URL..'/search.json?q='..tag
else
url = BASE_URL..'/search.json?key='..apikey..'&q='..tag
end
local b,c = https.request(url)
if c ~= 200 then return nil end
local dp = json:decode(b).search
-- truly randomize
math.randomseed(os.time())
-- random max json table size
local i = math.random(#dp)
local link_image = 'https:'..dp[i].image
source = 'https://derpiboo.ru/'..dp[i].id_number
return link_image
end
local function run(msg, matches)
local tag = matches[1]
local tag = string.gsub(tag, " ", '+' )
local receiver = get_receiver(msg)
local url = get_dp2(tag)
send_photo_from_url(receiver, url, send_title, {receiver, title})
return "Source: "..source
end
return {
description = "Sendet zufälliges Bild von Derpibooru.",
usage = {"/derpibooru2 [Tags]","/dp2 [Tags]"},
patterns = {"^/derpibooru2 (.*)$","^/dp2 (.*)$"},
run = run
}
end

48
plugins/deviantart.lua Normal file
View File

@ -0,0 +1,48 @@
-- 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://backend.deviantart.com'
function get_da_data (da_code)
local url = BASE_URL..'/oembed?url='..da_code
local res,code = https.request(url)
if code ~= 200 then return "HTTP-FEHLER" end
local data = json:decode(res)
return data
end
function send_da_data(data, receiver)
local title = data.title
local category = data.category
local author_name = data.author_name
local text = title..' von '..author_name..'\n'..category
local image_url = data.fullsize_url
if image_url == nil then
image_url = data.url
end
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 da_code = 'http://'..matches[1]..'.deviantart.com/art/'..matches[2]
local data = get_da_data(da_code)
local receiver = get_receiver(msg)
send_da_data(data, receiver)
end
return {
description = "Sendet deviantArt-Info.",
usage = {"deviantArt Link"},
patterns = {"http://(.*).deviantart.com/art/(.*)"},
run = run
}
end

40
plugins/dns.lua Normal file
View File

@ -0,0 +1,40 @@
-- 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://jack-dns-tools.p.mashape.com/dnstools.php'
local function get_domain_data (domain)
local apikey = cred_data.x_mashape_key
local url = BASE_URL..'?_method=DNS2IP&dns='..domain..'&mashape-key='..apikey
local res,code = https.request(url)
if code ~= 200 then return "HTTP-FEHLER" end
local data = json:decode(res)
return data
end
local function send_domain_data(data, receiver)
if domain == data.ip then
return
else
local text = data.ip
send_msg(receiver, text, ok_cb, false)
end
end
local function run(msg, matches)
domain = matches[1]
local data = get_domain_data(domain)
local receiver = get_receiver(msg)
send_domain_data(data, receiver)
end
return {
description = "Löst Domain nach IP auf.",
usage = "/dns [Domain]",
patterns = {"^/dns (.*)$"},
run = run
}
end

View File

@ -15,6 +15,6 @@ end
return {
description = "Erstelle ein Doge Bild mit Wörtern",
usage = {"/dogify das/was/du/willst"},
patterns = {"^/dogify (.+)$"},
patterns = {"^/dogify (.+)$","^/doge (.+)$"},
run = run
}

41
plugins/dropbox.lua Normal file
View File

@ -0,0 +1,41 @@
-- 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 function send_dropbox_data(link, receiver)
if string.ends(link, ".png") or string.ends(link, ".jpeg") or string.ends(link, ".jpg") then
send_photo_from_url(receiver, link)
elseif string.ends(link, ".webp") or string.ends(link, ".gif") then
send_document_from_url(receiver, link)
else
send_msg(receiver, link, ok_cb, false)
end
end
local function run(msg, matches)
local folder = matches[1]
local file = matches[2]
local receiver = get_receiver(msg)
local link = 'https://dl.dropboxusercontent.com/s/'..folder..'/'..file
local v,code = https.request(link)
if code == 200 then
send_dropbox_data(link, receiver)
else
return nil
end
end
return {
description = "Dropbox-Plugin",
usage = {
"Dropbox-URL: Postet Bild oder Direktlink"
},
patterns = {
"dropbox.com/s/([a-z0-9]+)/([A-Za-z0-9-_-.-.-]+)"
},
run = run
}
end

36
plugins/e621.lua Normal file
View File

@ -0,0 +1,36 @@
-- This is a proprietary plugin, property of Andreas Bielawski, (c) 2015 <andi (dot) b (at) outlook (dot) de>
-- DO NOT USE WITHOUT PERMISSION
-- Modified by Akamaru [https://ponywave.de]
do
local function get_e621(tag)
local BASE_URL = 'https://e621.net'
local url = BASE_URL..'/post/index.json?tags='..tag
local b,c = https.request(url)
if c ~= 200 then return nil end
local e621 = json:decode(b)
-- truly randomize
math.randomseed(os.time())
-- random max json table size
local i = math.random(#e621)
local link_image = e621[i].file_url
return link_image
end
local function run(msg, matches)
local tag = matches[1]
local receiver = get_receiver(msg)
local url = get_e621(tag)
send_photo_from_url(receiver, url, send_title, {receiver, title})
return "Source: "..url
end
return {
description = "Sendet zufälliges Bild von e621.",
usage = {"/e621 [Tags]"},
patterns = {"^/e621 (.*)$"},
run = run
}
end

40
plugins/facebook.lua Normal file
View File

@ -0,0 +1,40 @@
-- 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

@ -0,0 +1,46 @@
-- 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

@ -0,0 +1,39 @@
-- 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

50
plugins/flickr.lua Normal file
View File

@ -0,0 +1,50 @@
-- 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://api.flickr.com/services/rest'
function get_flickr_photo_data (photo_id)
local apikey = cred_data.flickr_apikey
local url = BASE_URL..'/?method=flickr.photos.getInfo&api_key='..apikey..'&photo_id='..photo_id..'&format=json&nojsoncallback=1'
local res,code = https.request(url)
if code ~= 200 then return "HTTP-FEHLER" end
local data = json:decode(res).photo
return data
end
function send_flickr_photo_data(data, receiver)
local title = data.title._content
local username = data.owner.username
local taken = data.dates.taken
local views = data.views
if data.usage.candownload == 1 then
local image_url = 'https://farm'..data.farm..'.staticflickr.com/'..data.server..'/'..data.id..'_'..data.originalsecret..'_o_d.'..data.originalformat
local cb_extra = {
receiver=receiver,
url=image_url
}
local text = '"'..title..'", aufgenommen '..taken..' von '..username..' ('..data.views..' Aufrufe)'
send_msg(receiver, text, send_photo_from_url_callback, cb_extra)
else
local text = '"'..title..'", aufgenommen '..taken..' von '..username..' ('..data.views..' Aufrufe)\nBild kann nicht gepostet werden (Keine Berechtigung)'
send_msg(receiver, text, ok_cb, false)
end
end
function run(msg, matches)
local photo_id = matches[2]
local data = get_flickr_photo_data(photo_id)
local receiver = get_receiver(msg)
send_flickr_photo_data(data, receiver)
end
return {
description = "Sendet Flickr-Info.",
usage = "Flickr-URL: Sendet Bild von Flickr",
patterns = {"flickr.com/photos/([A-Za-z0-9-_-]+)/([0-9]+)"},
run = run
}
end

38
plugins/flickr_search.lua Normal file
View File

@ -0,0 +1,38 @@
-- 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 function get_flickr(term)
local BASE_URL = 'https://api.flickr.com/services/rest'
local url = BASE_URL..'/?method=flickr.photos.search&api_key=c34eff1b204eaecae0de7141bd60d578&format=json&nojsoncallback=1&privacy_filter=1&extras=url_o&text='..term
local b,c = https.request(url)
if c ~= 200 then return nil end
local photo = json:decode(b).photos.photo
-- truly randomize
math.randomseed(os.time())
-- random max json table size
local i = math.random(#photo)
local link_image = photo[i].url_o
return link_image
end
local function run(msg, matches)
local term = matches[1]
local receiver = get_receiver(msg)
local url = get_flickr(term)
if string.ends(url, ".gif") then
send_document_from_url(receiver, url)
else
send_photo_from_url(receiver, url)
end
end
return {
description = "Sendet zufälliges Bild von Flickr.",
usage = "/flickr [Suchbegriff]: Postet Bild von Flickr",
patterns = {"^/flickr (.*)$"},
run = run
}
end

117
plugins/forecast.lua Normal file
View File

@ -0,0 +1,117 @@
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 ' ❄️'
else
return ''
end
end
local function get_temp(weather, n)
local day = string.gsub(round(weather.list[n].temp.day, 1), "%.", "%,")
local night = string.gsub(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] ~= '!/orecast' 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,7 +1,5 @@
do
local ftp = (loadfile "./libs/ftp.lua")()
local function send_ftp_data (text_file, receiver)
local BASE_URL = cred_data.ftp_site
local username = cred_data.ftp_username
@ -16,6 +14,10 @@ local function send_ftp_data (text_file, receiver)
end
local function run(msg, matches)
if not ftp then
print('ftp Library wird zum ersten Mal geladen...')
ftp = (loadfile "./libs/ftp.lua")()
end
local text_file = matches[1]
local receiver = get_receiver(msg)
send_ftp_data(text_file, receiver)

139
plugins/gamesdb.lua Normal file
View File

@ -0,0 +1,139 @@
-- 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://thegamesdb.net/api'
local makeOurDate = function(dateString)
local pattern = "(%d+)%/(%d+)%/(%d+)"
local month, day, year = dateString:match(pattern)
return day..'.'..month..'.'..year
end
local function get_game_id(game)
local url = BASE_URL..'/GetGamesList.php?name='..game
local res,code = http.request(url)
if code ~= 200 then return "HTTP-FEHLER" end
local result = xml.load(res)
if xml.find(result, 'id') then
local game = xml.find(result, 'id')[1]
return game
else
return nil
end
end
local function send_game_photo(result, receiver)
local BASE_URL = xml.find(result, 'baseImgUrl')[1]
local images = {}
--[[if xml.find(result, 'fanart') then
local fanart = xml.find(result, 'fanart')[1]
local fanrt_url = BASE_URL..fanart[1]
table.insert(images, fanrt_url)
end]]
if xml.find(result, 'boxart', 'side', 'front') then
local boxart = xml.find(result, 'boxart', 'side', 'front')[1]
local boxart_url = BASE_URL..boxart
table.insert(images, boxart_url)
end
local i = 0
for k, v in pairs(images) do
i = i+1
local file = download_to_file(v, 'game'..i..'.jpg')
send_photo(receiver, file, ok_cb, false)
end
end
local function send_game_data(game_id, receiver)
local url = BASE_URL..'/GetGame.php?id='..game_id
local res,code = http.request(url)
if code ~= 200 then return "HTTP-FEHLER" end
local result = xml.load(res)
local title = xml.find(result, 'GameTitle')[1]
local platform = xml.find(result, 'Platform')[1]
if xml.find(result, 'ReleaseDate') then
date = makeOurDate(xml.find(result, 'ReleaseDate')[1])
else
date = ''
end
if xml.find(result, 'Overview') then
desc = '\n'..string.sub(xml.find(result, 'Overview')[1], 1, 200) .. '...'
else
desc = ''
end
if xml.find(result, 'Genres') then
local genres = xml.find(result, 'Genres')
local genre_count = tablelength(genres)-1
if genre_count == 1 then
genre = '\nGenre: '..genres[1][1]
else
local genre_loop = '\nGenres: '
for v in pairs(genres) do
if v == 'xml' then break; end
if v < genre_count then
genre_loop = genre_loop..genres[v][1]..', '
else
genre_loop = genre_loop..genres[v][1]
end
end
genre = genre_loop
end
else
genre = ''
end
if xml.find(result, 'Players') then
players = '\nSpieler: '..xml.find(result, 'Players')[1]
else
players = ''
end
if xml.find(result, 'Youtube') then
video = '\nVideo: '..xml.find(result, 'Youtube')[1]
else
video = ''
end
if xml.find(result, 'Publisher') then
publisher = '\nPublisher: '..xml.find(result, 'Publisher')[1]
else
publisher = ''
end
local text = 'Titel: '..title..'\nPlattform: '..platform..'\nRelease: '..date..genre..players..publisher..video..'\nBeschreibung: '..desc
send_msg(receiver, text, ok_cb, false)
if xml.find(result, 'fanrt') or xml.find(result, 'boxart') then
send_game_photo(result, receiver)
end
end
local function run(msg, matches)
local game = URL.escape(matches[1])
local receiver = get_receiver(msg)
local game_id = get_game_id(game)
if not game_id then
return "Spiel nicht gefunden!"
else
send_game_data(game_id, receiver)
end
end
return {
description = "Sendet Infos zu einem Spiel.",
usage = "/game [Spiel]: Sendet Infos zum Spiel",
patterns = {"^/game (.+)$"},
run = run
}
end

View File

@ -22,30 +22,45 @@ function getGay(text)
end
-- Random image from table
local i = math.random(#data.results)
return data.results[i].url
-- 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 url = getGay(text)
if not url then
local results = getGay(text)
if not results then
return "Kein Bild gefunden."
end
local i = math.random(#results)
local url = nil;
if string.ends(url, ".svg") then
return "Fehler beim laden des Bildes."
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
print("Bilder-URL: ", url)
if string.ends(url, ".gif") then
send_document_from_url(receiver, url)
return "Source: "..url
if failed then
return "Fehler beim Laden des Bildes."
else
send_photo_from_url(receiver, url)
return "Source: "..url
return "Source: "..url
end
end

82
plugins/gdrive.lua Normal file
View File

@ -0,0 +1,82 @@
-- 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://www.googleapis.com/drive/v2'
local function get_drive_document_data (docid)
local apikey = cred_data.google_apikey
local url = BASE_URL..'/files/'..docid..'?key='..apikey..'&fields=id,title,mimeType,ownerNames,exportLinks,fileExtension'
local res,code = https.request(url)
local res = string.gsub(res, 'image/', '')
local res = string.gsub(res, 'application/', '')
if code ~= 200 then return "HTTP-FEHLER" end
local data = json:decode(res)
return data
end
local function send_drive_document_data(data, receiver)
local title = data.title
local mimetype = data.mimeType
local id = data.id
local owner = data.ownerNames[1]
local text = '"'..title..'", freigegeben von '..owner
if data.exportLinks then
if data.exportLinks.png then
local image_url = data.exportLinks.png
local cb_extra = {
receiver=receiver,
url=image_url
}
send_msg(receiver, text, send_photo_from_url_callback, cb_extra)
else
local pdf_url = data.exportLinks.pdf
send_msg(receiver, text, ok_cb, false)
send_document_from_url(receiver, pdf_url)
end
else
local get_file_url = 'https://drive.google.com/uc?id='..id
local ext = data.fileExtension
if mimetype == "png" or mimetype == "jpg" or mimetype == "jpeg" or mimetype == "gif" or mimetype == "webp" then
local respbody = {}
local options = {
url = get_file_url,
sink = ltn12.sink.table(respbody),
redirect = false
}
local response = {https.request(options)} -- luasec doesn't support 302 redirects, so we must contact gdrive again
local code = response[2]
local headers = response[3]
local file_url = headers.location
if ext == "jpg" or ext == "jpeg" or ext == "png" then
send_photo_from_url(receiver, file_url)
else
send_document_from_url(receiver, file_url)
end
else
local text = '"'..title..'", freigegeben von '..owner..'\nDirektlink: '..get_file_url
send_msg(receiver, text, ok_cb, false)
end
end
end
local function run(msg, matches)
local docid = matches[2]
local data = get_drive_document_data(docid)
local receiver = get_receiver(msg)
send_drive_document_data(data, receiver)
end
return {
description = "Sendet Google-Drive-Info und PDF",
usage = "URL zu Google-Drive-Dateien",
patterns = {
"docs.google.com/(.*)/d/([A-Za-z0-9-_-]+)",
"drive.google.com/(.*)/d/([A-Za-z0-9-_-]+)",
"drive.google.com/(open)%?id=([A-Za-z0-9-_-]+)"
},
run = run
}
end

46
plugins/gender.lua Normal file
View File

@ -0,0 +1,46 @@
-- 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://gender-api.com/get'
function get_gender_data (name)
local apikey = cred_data.gender_apikey
local url = BASE_URL..'?name='..name..'&key='..apikey
local res,code = https.request(url)
if code ~= 200 then return "HTTP-FEHLER" end
local data = json:decode(res)
return data
end
function send_gender_data(data, receiver)
if data.gender == "female" then
gender = 'weiblich'
end
if data.gender == "male" then
gender = 'männlich'
end
if data.gender == "unknown" then
gender = 'unbekanntem Geschlechts'
end
local accuracy = data.accuracy
local text = name..' ist zu '..accuracy..'% '..gender
send_msg(receiver, text, ok_cb, false)
end
function run(msg, matches)
name = matches[1]
local data = get_gender_data(name)
local receiver = get_receiver(msg)
send_gender_data(data, receiver)
end
return {
description = "Sendet Geschlecht",
usage = {"/geschlecht [Name]","/gender [Name]"},
patterns = {"^/geschlecht (.*)$","^/gender (.*)$"},
run = run
}
end

View File

@ -1,37 +1,34 @@
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)
local hash = get_redis_hash(msg, 'variables')
if hash then
local value = redis:hget(hash, var_name)
if not value then
return'Not found, use "/get" to list variables'
return'Nicht gefunden, benutze "!get", um alle Variablen aufzulisten.'
else
return var_name..' => '..value
return var_name..' = '..value
end
end
end
local function list_variables(msg)
local hash = get_redis_hash(msg, 'variables')
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 'Keine Variablen vorhanden!'
else
return text
end
end
end
local function run(msg, matches)
if matches[2] then
return get_value(msg, matches[2])
@ -41,9 +38,14 @@ local function run(msg, matches)
end
return {
description = "Bekommt Variable, die mit /set gesetzt wurde",
usage = {"/get (Variable)"},
patterns = {"^/get (%a+)$","^/get$"},
run = run,
pre_process = lex
}
description = "Bekommt Variablen, die mit !set gesetzt wurden",
usage = {
"/get: Gibt alle Variablen aus",
"/get (Variable): Gibt die Variable aus."
},
patterns = {
"^(/get) (.+)$",
"^/get$"
},
run = run
}

21
plugins/get_data.lua Normal file
View File

@ -0,0 +1,21 @@
local function run(msg, matches)
local receiver = get_receiver(msg)
local url = matches[1]
if string.match(msg.text, "[Gg][Ee][Tt][Dd][Aa][Tt][Aa]") or string.match(msg.text, "[Ww][Gg][Ee][Tt]") then
send_document_from_url(receiver, url)
elseif string.match(msg.text, "[Gg][Ee][Tt][Ii][Mm][Gg]") then
send_photo_from_url(receiver, url)
end
end
return {
description = "Ein plugin, um Bilder oder Dateien zu downloaden",
usage = {"/getdata [URL]",
"/getimg [URL]"},
patterns = {"^/getdata (.*)$",
"/[Ww][Gg][Ee][Tt]",
"^/getimg (.*)$"
},
run = run
}
--by Akamaru [https://ponywave.de]

13
plugins/get_txt.lua Normal file
View File

@ -0,0 +1,13 @@
local function run(msg, matches)
local res,code = http.request(matches[1]..'.txt')
if code ~= 200 then return nil end
return res
end
return {
description = "",
usage = "",
patterns = {"^(.*).txt$"},
run = run
}

46
plugins/gfycat.lua Normal file
View File

@ -0,0 +1,46 @@
do
local function send_gfycat_gif(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 cb_extra = {file_path=file}
if file == nil then
send_msg(receiver, 'Fehler beim Herunterladen von '..name, ok_cb, false)
else
send_document(receiver, file, rmtmp_cb, cb_extra)
end
end
local function send_gfycat_thumb(name, receiver)
local BASE_URL = "https://thumbs.gfycat.com"
local url = BASE_URL..'/'..name..'-poster.jpg'
local file = download_to_file(url)
local cb_extra = {file_path=file}
if file == nil then
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)
end
return {
description = "Postet Gfycat-Video",
usage = "gfycat-Link: Postet Gfycat-Video",
patterns = {
"gfycat.com/([A-Za-z0-9-_-]+)",
},
run = run
}
end

76
plugins/github.lua Normal file
View File

@ -0,0 +1,76 @@
-- 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://api.github.com'
function get_gh_data()
if gh_commit_sha == nil then
url = BASE_URL..'/repos/'..gh_code
else
url = BASE_URL..'/repos/'..gh_code..'/git/commits/'..gh_commit_sha
end
local res,code = https.request(url)
if code ~= 200 then return "HTTP-FEHLER" end
local data = json:decode(res)
return data
end
function send_github_data(data, receiver)
local name = data.name
local description = data.description
local owner = data.owner.login
local clone_url = data.clone_url
if data.language == nil or data.language == "" then
language = ''
else
language = '\nSprache: '..data.language
end
if data.open_issues_count == 0 then
issues = ''
else
issues = '\nOffene Bugreports: '..data.open_issues_count
end
if data.homepage == nil or data.homepage == "" then
homepage = ''
else
homepage = '\nHomepage: '..data.homepage
end
local text = name..' von '..owner..'\n'..description..'\ngit clone '..clone_url..language..issues..homepage
send_msg(receiver, text, ok_cb, false)
end
function send_gh_commit_data(data, receiver)
local committer = data.committer.name
local message = data.message
local text = gh_code..'@'..gh_commit_sha..' von '..committer..':\n'..message
send_msg(receiver, text, ok_cb, false)
end
function run(msg, matches)
gh_code = matches[1]..'/'..matches[2]
gh_commit_sha = matches[3]
local data = get_gh_data()
local receiver = get_receiver(msg)
if not gh_commit_sha then
send_github_data(data, receiver)
else
send_gh_commit_data(data, receiver)
end
end
return {
description = "Sendet GitHub-Info.",
usage = {
"Link zu GitHub-Repo",
"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-_-.-.]+)/?$"
},
run = run
}
end

38
plugins/googl.lua Normal file
View File

@ -0,0 +1,38 @@
-- 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://www.googleapis.com/urlshortener/v1'
local function get_shortlink_data (shorturl)
local apikey = cred_data.google_apikey
local url = BASE_URL..'/url?key='..apikey..'&shortUrl=http://goo.gl/'..shorturl..'&projection=FULL'
local res,code = https.request(url)
if code ~= 200 then return "HTTP-FEHLER" end
local data = json:decode(res)
return data
end
local function send_shortlink_data(data, receiver)
local longUrl = data.longUrl
local shortUrlClicks = data.analytics.allTime.shortUrlClicks
local text = longUrl..'\n'..shortUrlClicks..' mal geklickt'
send_msg(receiver, text, ok_cb, false)
end
local function run(msg, matches)
local shorturl = matches[1]
local data = get_shortlink_data(shorturl)
local receiver = get_receiver(msg)
send_shortlink_data(data, receiver)
end
return {
description = "Sendet Goo.gl-Info.",
usage = {"goo.gl URL"},
patterns = {"goo.gl/([A-Za-z0-9-_-]+)"},
run = run
}
end

View File

@ -1,38 +1,53 @@
local function googlethat(query)
local api = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&safe=active&hl=de&"
function googlethat(query)
local BASE_URL = 'https://www.googleapis.com/customsearch/v1'
local apikey = cred_data.google_apikey
local cseid = cred_data.google_cse_id
local number = 5 -- Set number of results
local api = BASE_URL.."/?key="..apikey.."&cx="..cseid.."&gl=de&num="..number.."&safe=medium&fields=searchInformation%28formattedSearchTime,formattedTotalResults%29,items%28title,link%29&"
local parameters = "q=".. (URL.escape(query) or "")
-- Do the request
local res, code = https.request(api..parameters)
if code ~=200 then return nil end
if code ~=200 then return nil end
local data = json:decode(res)
if data.searchInformation.formattedTotalResults == "0" then return nil end
local results = {}
for key,result in ipairs(data.responseData.results) do
local results={}
for key,result in ipairs(data.items) do
table.insert(results, {
result.titleNoFormatting,
result.unescapedUrl or result.url
result.title,
result.link
})
end
return results
local stats = data.searchInformation.formattedTotalResults..' Ergebnisse, gefunden in '..data.searchInformation.formattedSearchTime..' Sekunden'
return results, stats
end
local function stringlinks(results)
function stringlinks(results, stats)
local stringresults=""
for key,val in ipairs(results) do
stringresults=stringresults..val[1].." - "..val[2].."\n"
end
return stringresults
return stringresults..stats
end
local function run(msg, matches)
local results = googlethat(matches[1])
return stringlinks(results)
function run(msg, matches)
local results, stats = googlethat(matches[1])
if results == nil then
return 'Nichts gefunden!'
else
return stringlinks(results, stats)
end
end
return {
description = "Durchsucht Google und sendet die ersten 5 Ergebnisse",
usage = {"/google [Begriff]","/Google [Begriff]"},
patterns = {"^/google (.*)$","^/Google (.*)$"},
run = run
description = "Durchsucht Google",
usage = "/google [Suchbegriff]: Durchsucht Google",
patterns = {
"^/[Gg][Oo][Oo][Gg][Ll][Ee] (.*)$",
"^%.[Gg][Oo][Oo][Gg][Ll][Ee] (.*)$"
},
run = run
}

70
plugins/google_books.lua Normal file
View File

@ -0,0 +1,70 @@
-- 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://www.googleapis.com/books/v1'
local function get_books_data (term)
local url = BASE_URL..'/volumes?q='..term..'&maxResults=3&fields=totalItems,items%28volumeInfo%28title,authors,publisher,publishedDate,pageCount,canonicalVolumeLink%29,saleInfo%28country,listPrice%29%29'
local res,code = https.request(url)
if code ~= 200 then return "HTTP-FEHLER" end
local data = json:decode(res)
return data
end
local function send_books_data(data, receiver)
local text = ""
for book in pairs(data.items) do
text = text..'"'..data.items[book].volumeInfo.title..'"'
if data.items[book].volumeInfo.publisher == nil and data.items[book].volumeInfo.pageCount ~= nil then
text = text..'\n'..data.items[book].volumeInfo.authors[1]..', '
else
text = text..'\n'..data.items[book].volumeInfo.authors[1]..''
end
if data.items[book].volumeInfo.authors[1] == data.items[book].volumeInfo.publisher then data.items[book].volumeInfo.publisher = nil end
if data.items[book].volumeInfo.publisher then
if data.items[book].volumeInfo.pageCount then
text = text..', '..data.items[book].volumeInfo.publisher..', '
else
text = text..', '..data.items[book].volumeInfo.publisher
end
end
if data.items[book].volumeInfo.pageCount then
text = text..data.items[book].volumeInfo.pageCount..' Seiten'
end
if data.items[book].volumeInfo.publishedDate then
text = text..', erschienen '..data.items[book].volumeInfo.publishedDate
end
if data.items[book].saleInfo.listPrice then
text = text..'\nPreis: '..data.items[book].saleInfo.listPrice.amount..' '..data.items[book].saleInfo.listPrice.currencyCode
end
text = text..'\n'..data.items[book].volumeInfo.canonicalVolumeLink
text = text..'\n\n'
end
send_large_msg(receiver, text, ok_cb, false)
end
local function run(msg, matches)
local term = URL.escape(matches[1])
local data = get_books_data(term)
local receiver = get_receiver(msg)
send_books_data(data, receiver)
end
return {
description = "Sucht nach Büchern in Google Books.",
usage = "/books [Suchbegriff]: Sucht nach Büchern in Google Books",
patterns = {"^/books (.*)$"},
run = run
}
end

View File

@ -0,0 +1,33 @@
#Sounds from http://xufox.bplaced.net/GronkhSoundboard/
do
local function run(msg, matches)
local receiver = get_receiver(msg)
local url = "http://code.ponywave.de/workspace/mikubot/gronkhsounds/"..matches[1]..".mp3"
local file = download_to_file(url)
local cb_extra = {file_path=file}
if string.match(msg.text, "[Ll][Ii][Ss][Tt][Ee]") then
return "PonyWave.de/a/gronkhsounds"
end
if not file then
return "Nichts gefunden!"
else
print('Sende Sound')
send_document(receiver, file, rmtmp_cb, cb_extra)
end
end
return {
description = "Gronkh Soundboard",
usage = {"/gronkh [Name]"},
patterns = {
"^/gronkh (.*)$"
},
run = run
}
end

View File

@ -39,7 +39,7 @@ do
end
else
plugin = plugins[name]
if not plugin then return nil end
if not plugin then return 'Dieses Plugin existiert nicht.' end
end
local text = ""

View File

@ -10,7 +10,7 @@ end
return {
description = "Wenn ein Link zu einem Bild gesendet wird, läd und sendet der Bot das Bild.",
usage = {"Link zum Bild"},
patterns = {"^(https?://[%w-_%.%?%.:/%+=&]+%.png)$","^(https?://[%w-_%.%?%.:/%+=&]+%.jpg)$","^(https?://[%w-_%.%?%.:/%+=&]+%.jpeg)$",},
patterns = {"^(https?://[%w-_%.%?%.:/%+=&]+%.png)","^(https?://[%w-_%.%?%.:/%+=&]+%.jpg)","^(https?://[%w-_%.%?%.:/%+=&]+%.jpeg)",},
run = run
}

View File

@ -1,10 +1,14 @@
do
local BASE_URL = 'http://www.imdbapi.com'
local BASE_URL = 'https://www.omdbapi.com'
function get_imdb_data (movie)
local url = BASE_URL..'/?t='..movie
local res,code = http.request(url)
function get_imdb_data (movie, id)
if id then
url = BASE_URL..'/?i=tt'..movie
else
url = BASE_URL..'/?t='..movie
end
local res,code = https.request(url)
if code ~= 200 then return "HTTP-FEHLER" end
local data = json:decode(res)
return data
@ -17,6 +21,7 @@ function send_imdb_data(data, receiver)
else
local title = data.Title
local release = data.Released
if data.Type ~= "movie" then Type = '\nTyp: '..data.Type else Type = '' end
if data.Runtime ~= "N/A" then runtime = '\nLaufzeit: '..data.Runtime else runtime = '' end
if data.Genre ~= "N/A" then genre = '\nGenre: '..data.Genre else genre = '' end
local director = data.Director
@ -33,8 +38,8 @@ function send_imdb_data(data, receiver)
score = ''
end
local link = 'http://imdb.com/title/'..data.imdbID
local text = title..'\nErscheinungsdatm: '..release..runtime..genre..'\nDirector: '..director..writer..'\nSchauspieler: '..actors..plot..score..'\n-- '..link
if data.Poster ~= "N/A" then
local text = title..Type..'\nErscheinungsdatm: '..release..runtime..genre..'\nDirector: '..director..writer..'\nSchauspieler: '..actors..plot..score..'\n-- '..link
if data.Poster ~= "N/A" then
local image_url = data.Poster
local cb_extra = {
receiver=receiver,
@ -48,8 +53,13 @@ function send_imdb_data(data, receiver)
end
function run(msg, matches)
local movie = matches[1]:gsub(' ', '+')
local data = get_imdb_data(movie)
if matches[2] then
local movie = matches[2]
data = get_imdb_data(movie, true)
else
local movie = url_encode(matches[1]:gsub(' ', '+'))
data = get_imdb_data(movie, nil)
end
local receiver = get_receiver(msg)
send_imdb_data(data, receiver)
end
@ -57,7 +67,9 @@ end
return {
description = "Zeigt Info zu einem Film (von IMDB, englisch)",
usage = "/imdb [Film]: Zeigt Info zu Film",
patterns = {"^/imdb (.+)"},
patterns = {"^/imdb (.+)",
"imdb.com/title/(tt)(%d+[%d%.,]*)"
},
run = run
}

View File

@ -1,6 +1,8 @@
do
function getGoogleImage(text)
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)
@ -21,38 +23,144 @@ function getGoogleImage(text)
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 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]
local url = getGoogleImage(text)
if matches[2] then word = string.lower(matches[2]) end
if not url then
return "Kein Bild gefunden."
_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 string.ends(url, ".svg") then
return "Fehler beim laden des Bildes."
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
print("Bilder-URL: ", url)
if string.ends(url, ".gif") then
send_document_from_url(receiver, url)
return "Source: "..url
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
send_photo_from_url(receiver, url)
return "Source: "..url
return "Source: "..url
end
end
return {
description = "Sucht Bild mit Google-API und versendet es (SafeSearch aktiv)",
usage = {"/img [Suchbegriff]"},
patterns = {"^/img (.*)$"},
run = run
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
end

View File

@ -1,6 +1,8 @@
do
function getGoogleImage2(text)
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)
@ -21,38 +23,139 @@ function getGoogleImage2(text)
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 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]
local url = getGoogleImage2(text)
if matches[2] then word = string.lower(matches[2]) end
if not url then
return "Kein Bild gefunden."
_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 string.ends(url, ".svg") then
return "Fehler beim laden des Bildes."
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
print("Bilder-URL: ", url)
if string.ends(url, ".gif") then
send_document_from_url(receiver, url)
return "Source: "..url
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
send_photo_from_url(receiver, url)
return "Source: "..url
return "Source: "..url
end
end
return {
description = "Sucht Bild mit Google-API und versendet es [NSFW]",
usage = {"/img2 [Suchbegriff]","/nsfwimg [Suchbegriff]"},
patterns = {"^/img2 (.*)$","^/nsfwimg (.*)$"},
patterns = {"^/img2 (.*)$",
"^/nsfwimg (.*)$"--[[,
"^(/imgblacklist show)$",
"^(/imgblacklist add) (.*)$",
"^(/imgblacklist del) (.*)$"]]
},
run = run
}
end

72
plugins/instagram.lua Normal file
View File

@ -0,0 +1,72 @@
-- 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://api.instagram.com/v1'
local access_token = cred_data.instagram_access_token
function get_insta_data (insta_code)
local url = BASE_URL..'/media/shortcode/'..insta_code..'?access_token='..access_token
local res,code = https.request(url)
if code ~= 200 then return "HTTP-FEHLER" end
local data = json:decode(res).data
return data
end
function send_instagram_data(data, receiver)
-- Header
local username = data.user.username
local full_name = data.user.full_name
if username == full_name then
header = full_name..' hat ein'
else
header = full_name..' ('..username..') hat ein'
end
if data.type == 'video' then
header = header..' Video gepostet'
else
header = header..' Foto gepostet'
end
-- Caption
if data.caption == nil then
caption = ''
else
caption = ':\n'..data.caption.text
end
-- Footer
local comments = comma_value(data.comments.count)
local likes = comma_value(data.likes.count)
local footer = '\n'..likes..' Likes, '..comments..' Kommentare'
if data.type == 'video' then
footer = '\n'..data.videos.standard_resolution.url..footer
end
-- Image
local image_url = data.images.standard_resolution.url
local cb_extra = {
receiver=receiver,
url=image_url
}
-- Send all
send_msg(receiver, header..caption..footer, send_photo_from_url_callback, cb_extra)
end
function run(msg, matches)
local insta_code = matches[1]
local data = get_insta_data(insta_code)
local receiver = get_receiver(msg)
send_instagram_data(data, receiver)
end
return {
description = "Sendet Instagram-Info.",
usage = "URL zu Instagram-Post",
patterns = {"instagram.com/p/([A-Za-z0-9-_-]+)"},
run = run
}
end

63
plugins/ip_info.lua Normal file
View File

@ -0,0 +1,63 @@
-- 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 = 'http://ipinfo.io'
function get_ip_data (ip)
local url = BASE_URL..'/'..ip..'/json'
local res,code = http.request(url)
if code == 404 then return "Diese IP gibt es nicht!" end
if code ~= 200 then return "HTTP-FEHLER: "..code end
local data = json:decode(res)
if data.hostname == "No Hostname" then
hostname = ""
else
hostname = ' ('..data.hostname..')'
end
if data.org then
org = data.org
else
org = 'Unbekannt'
end
if data.city == "" or data.city == nil then
city = "Unbekannt"
else
city = data.city
end
local country = data.country
if data.region == "" or data.region == nil then
region = ""
else
region = ', '..data.region
end
if data.postal then
postal = ' (PLZ: '..data.postal..')'
else
postal = ''
end
local text = 'Der Server von '..ip..' gehört zu '..org..hostname..' und steht in '..country..', genauer in '..city..region..postal
return text
end
function run(msg, matches)
local ip = matches[1]
return get_ip_data(ip)
end
return {
description = "Sendet IP-Info",
usage = "/ip [IP]: Sendet Server-Infos",
patterns = {"^/ip (.*)$"},
run = run
}
end

View File

@ -1,25 +1,79 @@
do
local socket = require("socket")
local cronned = load_from_file('data/isup.lua')
local function save_cron(msg, url, delete)
local origin = get_receiver(msg)
if not cronned[origin] then
cronned[origin] = {}
end
if not delete then
table.insert(cronned[origin], url)
else
for k,v in pairs(cronned[origin]) do
if v == url then
table.remove(cronned[origin], k)
end
end
end
serialize_to_file(cronned, 'data/isup.lua')
return 'Gespeichert!'
local function prot_url(url)
local url, h = string.gsub(url, "http://", "")
local url, hs = string.gsub(url, "https://", "")
local protocol = "http"
if hs == 1 then
protocol = "https"
end
return url, protocol
end
local function get_base_redis(id, option, extra)
local ex = ''
if option ~= nil then
ex = ex .. ':' .. option
if extra ~= nil then
ex = ex .. ':' .. extra
end
end
return 'isup:' .. id .. ex
end
local function print_cron(id)
local uhash = get_base_redis(id)
local subs = redis:smembers(uhash)
local text = id .. ' prüft folgende Webseiten:\n---------\n'
for k,v in pairs(subs) do
text = text .. k .. ") " .. v .. '\n'
end
return text
end
local function save_cron(id, url)
local url = string.lower(url)
local baseurl, protocol = prot_url(url)
local prothash = get_base_redis(baseurl, "protocol")
local checkhash = get_base_redis(baseurl, "check")
local uhash = get_base_redis(id)
if redis:sismember(uhash, baseurl) then
return url..' wird bereits geprüft.'
end
print('Saving...')
redis:set(prothash, protocol)
redis:sadd(checkhash, id)
redis:sadd(uhash, baseurl)
return url.." wird jetzt alle fünf Minuten geprüft!"
end
local function delete_cron(id, n)
n = tonumber(n)
local uhash = get_base_redis(id)
local subs = redis:smembers(uhash)
if n < 1 or n > #subs then
return "ID zu hoch!"
end
local sub = subs[n]
local lhash = get_base_redis(sub, "check")
redis:srem(uhash, sub)
redis:srem(lhash, id)
local left = redis:smembers(lhash)
if #left < 1 then -- no one subscribed, remove it
local prothash = get_base_redis(sub, "protocol")
local downhash = get_base_redis(sub, "down")
redis:del(prothash)
redis:del(downhash)
end
return sub.." wird nicht mehr geprüft."
end
local function is_up_socket(ip, port)
print('Connect to', ip, port)
local c = socket.try(socket.tcp())
@ -73,56 +127,96 @@ local function isup(url)
else
result = is_up_http(url)
end
return result
end
local function cron()
for chan, urls in pairs(cronned) do
for k,url in pairs(urls) do
print('Checking', url)
if not isup(url) then
local text = url..' scheint DOWN zu sein'
send_msg(chan, text, ok_cb, false)
end
local keys = redis:keys(get_base_redis("*", "check"))
for k,v in pairs(keys) do
local base = string.match(v, "isup:(.+):check") -- Get the URL base
print('ISUP: '..base)
local prot = redis:get(get_base_redis(base, "protocol"))
local url = prot .. "://" .. base
local hash = 'isup:'..base..':down'
local isdown = redis:get(hash)
if not isup(url) then
if isdown ~= 'true' then
redis:set(hash, 'true')
local text = url..' ist DOWN! ❌'
for e, receiver in pairs(redis:smembers(v)) do
send_msg(receiver, text, ok_cb, false)
end
else
print(base..' ist immer noch down')
end
else
if isdown == 'true' then
redis:set(hash, 'false')
local text = url..' ist wieder UP! ✅'
for e, receiver in pairs(redis:smembers(v)) do
send_msg(receiver, text, ok_cb, false)
end
end
end
end
end
local function run(msg, matches)
if matches[1] == 'remove' then
if not is_sudo(msg) then
return 'Du darfst diesen Befehl nicht nutzen!'
end
return save_cron(msg, matches[2], true)
local id = "user#id" .. msg.from.id
elseif matches[1] == 'save' then
if is_chat_msg(msg) then
id = "chat#id" .. msg.to.id
end
if matches[1] == 'cron show' then
if not is_sudo(msg) then
return 'Du darfst diesen Befehl nicht nutzen!'
return 'Du darfst diesen Befehl nicht benutzen!'
end
return save_cron(msg, matches[2])
return print_cron(id)
elseif matches[1] == 'cron check' then
if not is_sudo(msg) then
return 'Du darfst diesen Befehl nicht benutzen!'
end
return cron()
elseif matches[1] == 'cron delete' then
if not is_sudo(msg) then
return 'Du darfst diesen Befehl nicht benutzen!'
end
return delete_cron(id, matches[2])
elseif matches[1] == 'cron' then
if not is_sudo(msg) then
return 'Du darfst diesen Befehl nicht benutzen!'
end
return save_cron(id, matches[2])
elseif isup(matches[1]) then
return matches[1]..' ist UP ✔'
return matches[1]..' ist UP! ✅'
else
return matches[1]..' scheint DOWN zu sein ❌'
return matches[1]..' ist DOWN!'
end
end
return {
description = "Check if a website or server is up.",
description = "Checkt, ob eine Webseite up ist.",
usage = {
"/isup [host]: Performs a HTTP request or Socket (ip:port) connexion",
"/isup save [host]: Every 5mins check if host is up. (Requires privileged user)",
"/isup remove [host]: Disable checking that host."
"/isup [Host]: Checkt, ob die Seite up ist",
"/isup cron [Host]: Checkt diese Seite alle 5 Minuten (nur Superuser)",
"/isup cron check: Prüfe alle Seiten jetzt",
"/isup cron show: Listet alle zu prüfenden Seiten auf",
"/isup cron delete [ID]: Checkt diese Seite nicht mehr"
},
patterns = {
"^/isup (remove) (.*)$",
"^/isup (save) (.*)$",
"^/isup (cron check)$",
"^/isup (cron show)$",
"^/isup (cron delete) (%d+)$",
"^/isup (cron) (.*)$",
"^/isup (.*)$",
"^/ping (.*)$",
"^/ping (remove) (.*)$",
"^/ping (save) (.*)$"
"^/ping (.*)$"
},
run = run,
cron = cron

32
plugins/konachan.lua Normal file
View File

@ -0,0 +1,32 @@
do
local function get_kc(tag)
local url = 'http://konachan.net/post.json?tags='..tag..' -rating:explicit'
local b,c = http.request(url)
if c ~= 200 then return nil end
local kc = json:decode(b)
-- truly randomize
math.randomseed(os.time())
-- random max json table size
local i = math.random(#kc)
local link_image = kc[i].file_url
return link_image
end
local function run(msg, matches)
local tag = matches[1]
local tag = string.gsub(tag, " ", '_' )
local receiver = get_receiver(msg)
local url = get_kc(tag)
send_photo_from_url(receiver, url, send_title, {receiver, title})
return "Source: "..url
end
return {
description = "Sendet ein Bild von Konachan.net [SFW]",
usage = {"/konachan [Tags]","/kc"},
patterns = {"^/konachan (.*)$","^/kc (.*)$"},
run = run
}
end

32
plugins/konachan_nsfw.lua Normal file
View File

@ -0,0 +1,32 @@
do
local function get_kc2(tag)
local url = 'http://konachan.com/post.json?tags='..tag..''
local b,c = http.request(url)
if c ~= 200 then return nil end
local kc = json:decode(b)
-- truly randomize
math.randomseed(os.time())
-- random max json table size
local i = math.random(#kc)
local link_image = kc[i].file_url
return link_image
end
local function run(msg, matches)
local tag = matches[1]
local tag = string.gsub(tag, " ", '_' )
local receiver = get_receiver(msg)
local url = get_kc2(tag)
send_photo_from_url(receiver, url, send_title, {receiver, title})
return "Source: "..url
end
return {
description = "Sendet Bild von Konachan.com [NSFW]",
usage = {"/konansfw [Tags]","/kcn [Tags]"},
patterns = {"^/konansfw (.*)$","^/kcn (.*)$"},
run = run
}
end

View File

@ -0,0 +1,63 @@
-- This file is part of the Telegram Bot "Brawlbot" (telegram.me/Brawlbot) by Andreas Bielawski (telegram.me/Brawl)
-- Released unter the MPLv2
do
local function set_location(user_id, location)
local hash = 'user:'..user_id
local set_location = get_location(user_id)
if set_location == location then
return 'Dieser Ort wurde bereits gesetzt'
else
print('Setting location in redis hash '..hash..' to location')
redis:hset(hash, 'location', location)
return 'Dein Wohnort wurde auf "'..location..'" festgelegt.'
end
end
local function del_location(user_id)
local hash = 'user:'..user_id
local set_location = get_location(user_id)
if not set_location then
return 'Du hast keinen Ort gesetzt'
else
print('Setting location in redis hash '..hash..' to false')
-- We set the location to false, because deleting the value blocks redis for a few milliseconds
redis:hset(hash, 'location', false)
return 'Dein Wohnort "'..set_location..'" wurde gelöscht!'
end
end
local function run(msg, matches)
local user_id = msg.from.id
if matches[1] == 'set' then
return set_location(user_id, matches[2])
elseif matches[1] == 'del' then
return del_location(user_id)
else
local set_location = get_location(user_id)
if not set_location then
return 'Du hast keinen Ort gesetzt'
else
return 'Gesetzter Wohnort: '..set_location
end
end
end
return {
description = "Orte-Manager",
usage = {
"/location: Gibt deinen gesetzten Wohnort aus",
"/location set (Ort): Setzt deinen Wohnort auf diesen Ort",
"/location del: Löscht deinen angegebenen Wohnort"
},
patterns = {
"^/location (set) (.*)$",
"^/location (del)$",
"^/location$"
},
run = run
}
end

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://love-calculator.p.mashape.com'
local function love_result(first_name, second_name)
local apikey = cred_data.x_mashape_key
local url = BASE_URL..'/getPercentage?mashape-key='..apikey..'&fname='..first_name..'&sname='..second_name
print(url)
local res,code = https.request(url)
if code ~= 200 then return "HTTP-FEHLER" end
local data = json:decode(res)
local first_name = data.fname
local second_name = data.sname
local percentage = data.percentage
local result = data.result
return first_name..' und '..second_name..' lieben sich zu '..percentage..'% ❤️\n'..result
end
local function run(msg, matches)
local first_name = url_encode(matches[1])
local second_name = url_encode(matches[2])
return love_result(first_name, second_name)
end
return {
description = "Liebestest ❤️ (kommt sogar ohne Jamba-Abo!)",
usage = "/love [Erster Name]+[Zweiter Name]: Führt einen Liebestest durch ❤️",
patterns = {
"^/love (.+)+(.+)$"
},
run = run
}
end

View File

@ -30,6 +30,34 @@ local function is_banned(user_id, chat_id)
return banned or false
end
local function makesudo(user_id, msg, delete)
local set = 'telegram:sudo_users'
local is_sudo = redis:sismember(set, user_id)
if delete then
if not is_sudo then
return user_id..' ist kein Superuser.'
else
if string.match(user_id, msg.from.id) then
return 'Das Löschen deiner User-ID aus den Superusern wird feige verweigert.'
else
print('deleting user id '..user_id..' from redis set '..set)
redis:srem(set, user_id)
sudo_users = load_sudo_users()
return user_id..' ist jetzt kein Superuser mehr.'
end
end
else
if not is_sudo then
print('saving user id '..user_id..' to redis set '..set)
redis:sadd(set, user_id)
sudo_users = load_sudo_users()
return user_id..' ist jetzt ein Superuser.'
else
return user_id..' ist bereits ein Superuser.'
end
end
end
local function pre_process(msg)
-- SERVICE MESSAGE
@ -86,6 +114,10 @@ local function pre_process(msg)
else
--print ('Chat '..msg.to.id..' whitelisted :)')
end
else
local user_name = get_name(msg)
local receiver = get_receiver(msg)
send_msg(receiver, "Hey "..user_name..", dies ist der Bot von @Akamaru und kann nur nach Freischaltung durch ihn benutzt werden." , ok_cb, false)
end
else
--print('User '..msg.from.id..' allowed :)')
@ -127,6 +159,16 @@ local function run(msg, matches)
return 'Das hier ist keine Chat-Gruppe'
end
end
if matches[1] == 'makesudo' then
local user_id = matches[3]
if matches[2] == 'user' then
return makesudo(user_id)
end
if matches[2] == 'delete' then
return makesudo(user_id, msg, true)
end
end
if matches[1] == 'kick' then
if msg.to.type == 'chat' then
@ -183,16 +225,18 @@ local function run(msg, matches)
end
return {
description = "Plugin to manage bans, kicks and white/black lists.",
description = "Manager-Plugin für Whitelist, Kicks und Banns (nur Superuser)",
usage = {
"/whitelist <enable>/<disable>: Enable or disable whitelist mode",
"/whitelist user <user_id>: Allow user to use the bot when whitelist mode is enabled",
"/whitelist chat: Allow everybody on current chat to use the bot when whitelist mode is enabled",
"/whitelist delete user <user_id>: Remove user from whitelist",
"/whitelist delete chat: Remove chat from whitelist",
"/ban user <user_id>: Kick user from chat and kicks it if joins chat again",
"/ban delete <user_id>: Unban user",
"/kick <user_id> Kick user from chat group"
"/whitelist <enable>/<disable>: Aktiviert/deaktiviert Whitelist",
"/whitelist user <user_id>: Whiteliste User",
"/whitelist chat: Whiteliste ganze Gruppe",
"/whitelist delete user <user_id>: Lösche User von der Whitelist",
"/whitelist delete chat: Lösche ganze Gruppe von der Whitelist",
"/ban user <user_id>: Kicke User vom Chat und kicke ihn, wenn er erneut beitritt",
"/ban delete <user_id>: Entbanne User",
"/kick <user_id>: Kicke User vom Chat",
"/makesudo user <user_id>: Macht User zum Superuser",
"/makesudo delete <user_id>: Macht User zum Superuser"
},
patterns = {
"^/(whitelist) (enable)$",
@ -205,6 +249,8 @@ return {
"^/(ban) (delete) (%d+)$",
"^/(kick) (%d+)$",
--"^//tgservice (.+)$",
"^/(makesudo) (user) (%d+)$",
"^/(makesudo) (delete) (%d+)$"
},
run = run,
pre_process = pre_process,

View File

@ -36,5 +36,6 @@ return {
usage = {'Irgendeine Datei'},
run = run,
patterns = {'%[(document)%]','%[(photo)%]','%[(video)%]','%[(audio)%]'},
pre_process = pre_process
pre_process = pre_process,
notyping = true
}

89
plugins/miiverse.lua Normal file
View File

@ -0,0 +1,89 @@
-- 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 +1,13 @@
local usage = "/mine [IP]: Sucht Minecraft-Server und sendet Infos. Standard-Port: 25565, /mine [IP] [Port]: Sucht Minecraft-Server auf Port und sendet Infos."
local ltn12 = require "ltn12"
local usage = {
"/mine [IP]: Sucht Minecraft-Server und sendet Infos. Standard-Port: 25565",
"/mine [IP] [Port]: Sucht Minecraft-Server auf Port und sendet Infos.",
}
local function mineSearch(ip, port, receiver) --25565
local responseText = ""
local api = "https://api.syfaro.net/server/status"
local parameters = "?ip="..(URL.escape(ip) or "").."&port="..(URL.escape(port) or "").."&players=true&favicon=true"
local http = require("socket.http")
local api = "https://mcapi.us/server/status"
local parameters = "?ip="..(URL.escape(ip) or "").."&port="..(URL.escape(port) or "").."&players=true"
print(api..parameters)
local respbody = {}
local body, code, headers, status = http.request{
url = api..parameters,
@ -17,8 +19,8 @@ local function mineSearch(ip, port, receiver) --25565
if (status == nil) then return "FEHLER: status = nil" end
if code ~=200 then return "FEHLER: "..code..". Status: "..status end
local jsonData = json:decode(body)
responseText = responseText..ip..":"..port.." ->\n"
if (jsonData.motd ~= nil) then
responseText = responseText..ip..":"..port..":\n"
if (jsonData.motd ~= nil and jsonData.motd ~= '') then
local tempMotd = ""
tempMotd = jsonData.motd:gsub('%§.', '')
if (jsonData.motd ~= nil) then responseText = responseText.." MOTD: "..tempMotd.."\n" end
@ -32,18 +34,18 @@ local function mineSearch(ip, port, receiver) --25565
responseText = responseText.." Online: "..server_online.."\n"
end
if (jsonData.players ~= nil) then
if (jsonData.players.max ~= nil) then
if (jsonData.players.max ~= nil and jsonData.players.max ~= 0) then
responseText = responseText.." Slots: "..jsonData.players.max.."\n"
end
if (jsonData.players.now ~= nil) then
if (jsonData.players.now ~= nil and jsonData.players.max ~= 0) then
responseText = responseText.." Spieler online: "..jsonData.players.now.."\n"
end
if (jsonData.players.sample ~= nil and jsonData.players.sample ~= false) then
responseText = responseText.." Spieler: "..table.concat(jsonData.players.sample, ", ").."\n"
end
end
if (jsonData.favicon ~= nil and false) then
--send_photo(receiver, jsonData.favicon) --(decode base64 and send)
if (jsonData.server.name ~= nil and jsonData.server.name ~= "") then
responseText = responseText.." Server: "..jsonData.server.name.."\n"
end
end
return responseText
end
@ -60,7 +62,7 @@ local function parseText(chat, text)
if (ip ~= nil) then
return mineSearch(ip, "25565", chat)
end
return "FEHLER: Keine Input IP?"
return "FEHLER: Keine Input IP??"
end
@ -73,6 +75,8 @@ end
return {
description = "Dursucht Minecraft-Server und sendet Infos",
usage = usage,
patterns = {"^/mine (.*)$"},
patterns = {
"^/mine (.*)$"
},
run = run
}

53
plugins/music163.lua Normal file
View File

@ -0,0 +1,53 @@
-- 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 = 'http://music.163.com/api'
local function get_netease_data(id)
local url = BASE_URL..'/song/detail/?ids=['..id..']'
local res,code = http.request(url)
if code ~= 200 then return "HTTP-FEHLER" end
local data = json:decode(res).songs[1]
return data
end
local function send_netease_data(data, receiver)
local mp3_url = data.mp3Url
local title = data.name
local artist = data.artists[1].name
local cb_extra = {
receiver=receiver,
url=mp3_url
}
local text = '"'..title..'" von '..artist
send_msg(receiver, text, send_document_from_url_callback, cb_extra)
end
local function run(msg, matches)
local id = matches[1]
local data = get_netease_data(id)
local receiver = get_receiver(msg)
if mp3url == "HTTP-FEHLER" then
return "Keinen Song gefunden :("
else
send_netease_data(data, receiver)
end
end
return {
description = "Sendet MP3 und Infos eines Tracks von music.163.com",
usage = {
"/getmp3 [ID]: Downloadet MP3 und sendet Infos",
"Link zu music.163.com-Track: Downloadet MP3 und sendet Infos"
},
patterns = {
"^/getmp3 (%d+[%d%.]*)",
"music.163.com/%#/song%?id=(%d+[%d%.]*)",
"music.163.com/song%?id=(%d+[%d%.]*)"
},
run = run
}
end

View File

@ -1,40 +1,117 @@
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 "")
-- This is a proprietary plugin, property of Andreas Bielawski, (c) 2015 <andi (dot) b (at) outlook (dot) de>
-- DO NOT USE WITHOUT PERMISSION
-- Do the request
local res, code = https.request(api..parameters)
if code ~=200 then return nil end
local data = json:decode(res)
do
local xml = require("xml")
local user = cred_data.mal_username
local password = cred_data.mal_pw
local BASE_URL = 'http://'..user..':'..password..'@myanimelist.net/api/anime'
local function delete_tags(str)
str = string.gsub( str, '<br />', '')
str = string.gsub( str, '%[i%]', '')
str = string.gsub( str, '%[/i%]', '')
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_anime_info(anime)
local url = BASE_URL..'/search.xml?q='..anime
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_anime_data(result, receiver)
local title = xml.find(result, 'title')[1]
local id = xml.find(result, 'id')[1]
local mal_url = 'http://myanimelist.net/anime/'..id
local results={}
for key,result in ipairs(data.responseData.results) do
table.insert(results, {
result.titleNoFormatting,
result.unescapedUrl or result.url
})
if xml.find(result, 'synopsis')[1] then
desc = '\n'..delete_tags(string.sub(xml.find(result, 'synopsis')[1], 1, 200)) .. '...'
else
desc = ''
end
return results
if xml.find(result, 'episodes')[1] then
episodes = '\nEpisoden: '..xml.find(result, 'episodes')[1]
else
episodes = ''
end
if xml.find(result, 'status')[1] then
status = ' ('..xml.find(result, 'status')[1]..')'
else
status = ''
end
--[[if xml.find(result, 'score')[1] ~= "0.00" then
score = '\nScore: '..string.gsub(xml.find(result, 'score')[1], "%.", "%,")
else
score = ''
end]]
if xml.find(result, 'type')[1] then
typ = '\nTyp: '..xml.find(result, 'type')[1]
else
typ = ''
end
if xml.find(result, 'start_date')[1] ~= "0000-00-00" then
startdate = '\nStart: '..makeOurDate(xml.find(result, 'start_date')[1])
else
startdate = ''
end
if xml.find(result, 'end_date')[1] ~= "0000-00-00" then
enddate = '\nEnde: '..makeOurDate(xml.find(result, 'end_date')[1])
else
enddate = ''
end
--local text = title..desc..episodes..status..score..typ..startdate..enddate..'\n— '..mal_url
local text = title..desc..episodes..status..typ..startdate..enddate..'\n'..mal_url
if xml.find(result, 'image') then
local image_url = xml.find(result, 'image')[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
function stringlinks(results)
local stringresults=""
for key,val in ipairs(results) do
stringresults=stringresults..val[1].." - "..val[2].."\n"
local function run(msg, matches)
local anime = URL.escape(matches[1])
local receiver = get_receiver(msg)
local anime_info = get_anime_info(anime)
if anime_info == "HTTP-Fehler" then
return "Anime nicht gefunden!"
else
send_anime_data(anime_info, receiver)
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]
description = "Sendet Infos zu einem Anime.",
usage = "/anime [Anime]: Sendet Infos zum Anime",
patterns = {"^/anime (.+)$",
"^/mal (.*)$",
"^/myanimelist (.*)$)",
"^https?://myanimelist.net/anime/[0-9]+/(.*)$"
},
run = run
}
end

61
plugins/page2image.lua Normal file
View File

@ -0,0 +1,61 @@
-- 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 = 'http://api.page2images.com/'
local restkey = cred_data.page2images_restkey
function get_scrot_data (scrot_url)
local url = BASE_URL..'/restfullink?p2i_url='..scrot_url..'&p2i_key='..restkey..'&p2i_imageformat=png&p2i_quality=85&p2i_size=1366x768'
local res,code = http.request(url)
if code ~= 200 then return "HTTP-FEHLER" end
local data = json:decode(res)
return data
end
function send_scrot_data(data, receiver)
if data.status == "processing" then
print('Screenshot wird erstellt. Ungefähre Dauer: '..data.estimated_need_time..' Sekunden')
end
while data.status == "processing" do
sleep(5)
data = get_scrot_data(scrot_url)
if data.estimated_need_time ~= nil then
print('Noch '..data.estimated_need_time..' Sekunden')
end
end
if data.status == "error" then
text = data.ori_url..' konnte nicht fotografiert werden, weil der Fehler "'..data.msg..'" '..data.errno..' auftrat.'
send_msg(receiver, text, ok_cb, false)
end
if data.status == "finished" then
left_calls = data.left_calls
text = data.ori_url..' wurde fotografiert. Verbleibende API-Calls: '..left_calls
image_url = data.image_url
cb_extra = {
receiver=receiver,
url=image_url
}
send_msg(receiver, text, send_photo_from_url_callback, cb_extra)
end
end
function run(msg, matches)
scrot_url = matches[1]
local data = get_scrot_data(scrot_url)
local receiver = get_receiver(msg)
send_scrot_data(data, receiver)
end
return {
description = "Sendet Webseiten-Screenshot.",
usage = {"/scrot2 [URL]"},
patterns = {"^/scrot2 (https?://[%w-_%.%?%.:/%+=&]+)"},
run = run
}
end

View File

@ -0,0 +1,29 @@
-- 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://www.googleapis.com/pagespeedonline/v2'
function get_pagespeed (test_url)
local apikey = cred_data.google_apikey
local url = BASE_URL..'/runPagespeed?url='..test_url..'&key='..apikey..'&fields=id,ruleGroups(SPEED(score))'
local res,code = https.request(url)
if code ~= 200 then return "HTTP-FEHLER" end
local data = json:decode(res)
return data.id..' hat einen PageSpeed-Score von '..data.ruleGroups.SPEED.score..' Punkten.'
end
function run(msg, matches)
local test_url = matches[1]
return get_pagespeed(test_url)
end
return {
description = "Sendet PageSpeed-Score.",
usage = "/speed [URL]: Sendet PageSpeed-Score dieser Seite",
patterns = {"^/speed (https?://[%w-_%.%?%.:/%+=&]+)"},
run = run
}
end

55
plugins/play_store.lua Normal file
View File

@ -0,0 +1,55 @@
-- 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://apps.p.mashape.com/google/application'
local function get_playstore_data (appid)
local apikey = cred_data.x_mashape_key
local url = BASE_URL..'/'..appid..'?mashape-key='..apikey
local res,code = https.request(url)
if code ~= 200 then return "HTTP-FEHLER" end
local data = json:decode(res).data
return data
end
local function send_playstore_data(data, receiver)
local title = data.title
local developer = data.developer.id
local category = data.category.name
local rating = data.rating.average
local installs = data.performance.installs
local description = data.description
if data.version == "Varies with device" then
appversion = "variiert je nach Gerät"
else
appversion = data.version
end
if data.price == 0 then
price = "Gratis"
else
price = data.price
end
local text = title..' von '..developer..' aus der Kategorie '..category..', durschnittlich bewertet mit '..rating..' Sternen.\n'..description..'\n'..installs..' Installationen, Version '..appversion
send_msg(receiver, text, ok_cb, false)
end
local function run(msg, matches)
local appid = matches[1]
local data = get_playstore_data(appid)
if data.title == nil then
return
else
local receiver = get_receiver(msg)
send_playstore_data(data, receiver)
end
end
return {
description = "Sendet Play Store Info.",
usage = {"play.google.com/store/apps/details Link"},
patterns = {"play.google.com/store/apps/details%?id=(.*)"},
run = run
}
end

View File

@ -1,8 +1,8 @@
do
-- Returns the key (index) in the config.enabled_plugins table
local function plugin_enabled( name )
for k,v in pairs(_config.enabled_plugins) do
local function plugin_enabled( name, chat )
for k,v in pairs(enabled_plugins) do
if name == v then
return k
end
@ -27,7 +27,7 @@ local function list_plugins(only_enabled)
-- ✔ enabled, ❌ disabled
local status = ''
-- Check if is enabled
for k2, v2 in pairs(_config.enabled_plugins) do
for k2, v2 in pairs(enabled_plugins) do
if v == v2..'.lua' then
status = ''
end
@ -41,83 +41,85 @@ local function list_plugins(only_enabled)
return text
end
local function reload_plugins( )
local function reload_plugins(plugin_name, status)
plugins = {}
load_plugins()
return list_plugins(true)
if plugin_name then
return 'Das Plugin "'..plugin_name..'" wurde '..status
else
return 'Plugins wurden neu geladen'
end
end
local function enable_plugin( plugin_name )
print('Überprüfe ob "'..plugin_name..'" existiert')
print('überprüfe ob "'..plugin_name..'" existiert')
-- Check if plugin is enabled
if plugin_enabled(plugin_name) then
return 'Plugin "'..plugin_name..'" ist aktiviert!'
return 'Das Plugin "'..plugin_name..'" ist bereits aktiviert'
end
-- Checks if plugin exists
if plugin_exists(plugin_name) then
-- Add to the config table
table.insert(_config.enabled_plugins, plugin_name)
print(plugin_name..' zu to _config table hinzugefügt')
save_config()
-- Add to redis set
redis:sadd('telegram:enabled_plugins', plugin_name)
print(plugin_name..' saved to redis set telegram:enabled_plugins')
-- Reload the plugins
return reload_plugins( )
return reload_plugins(plugin_name, 'aktiviert')
else
return 'Das Plugin "'..plugin_name..'" existiert nicht!'
return 'Plugin '..plugin_name..' existiert nicht'
end
end
local function disable_plugin( name, chat )
-- Check if plugins exists
if not plugin_exists(name) then
return 'Das Plugin "'..plugin_name..'" existiert nicht!'
return 'Das Plugin "'..name..'" existiert nicht'
end
local k = plugin_enabled(name)
-- Check if plugin is enabled
if not k then
return 'Das Plugin "'..name..'" ist nicht aktiviert!'
return 'Plugin '..name..' ist nicht aktiviert'
end
-- Disable and reload
table.remove(_config.enabled_plugins, k)
save_config( )
return reload_plugins(true)
redis:srem('telegram:enabled_plugins', name)
print(name..' saved to redis set telegram:enabled_plugins')
return reload_plugins(name, 'deaktiviert')
end
local function disable_plugin_on_chat(receiver, plugin)
local function disable_plugin_on_chat(msg, plugin)
if not plugin_exists(plugin) then
return "Dieses Plugin existiert nicht!"
end
local hash = get_redis_hash(msg, 'disabled_plugins')
local disabled = redis:hget(hash, plugin)
if not _config.disabled_plugin_on_chat then
_config.disabled_plugin_on_chat = {}
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.'
else
return 'Das Plugin "'..plugin..'" wurde für diesen Chat bereits deaktiviert.'
end
if not _config.disabled_plugin_on_chat[receiver] then
_config.disabled_plugin_on_chat[receiver] = {}
end
_config.disabled_plugin_on_chat[receiver][plugin] = true
save_config()
return 'Das Plugin "'..plugin..'" ist hier nun deaktiviert!'
end
local function reenable_plugin_on_chat(receiver, plugin)
if not _config.disabled_plugin_on_chat then
return 'Hier sind keine Plugins deaktiviert.'
local function reenable_plugin_on_chat(msg, plugin)
if not plugin_exists(plugin) then
return "Dieses Plugin existiert nicht!"
end
local hash = get_redis_hash(msg, 'disabled_plugins')
local disabled = redis:hget(hash, plugin)
if disabled == nil then return 'Es gibt keine deaktivierten Plugins für disen Chat.' end
if not _config.disabled_plugin_on_chat[receiver] then
return 'Hier sind keine Plugins deaktiviert.'
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.'
else
return 'Das Plugin "'..plugin..'" ist nicht deaktiviert.'
end
if not _config.disabled_plugin_on_chat[receiver][plugin] then
return 'Dieses Plugin ist nicht deaktiviert!'
end
_config.disabled_plugin_on_chat[receiver][plugin] = false
save_config()
return 'Das Plugin "'..plugin..'" ist wieder aktiviert!'
end
local function run(msg, matches)
@ -126,46 +128,61 @@ local function run(msg, matches)
return list_plugins()
end
-- Re-enable a plugin for this chat
-- Reenable a plugin for this chat
if matches[1] == 'enable' and matches[3] == 'chat' then
local receiver = get_receiver(msg)
local plugin = matches[2]
print('Aktiviere "'..plugin..'" in diesem Chat')
return reenable_plugin_on_chat(receiver, plugin)
return reenable_plugin_on_chat(msg, plugin)
end
-- Enable a plugin
if matches[1] == 'enable' then
local plugin_name = matches[2]
print("A+: "..matches[2])
print('Aktiviere: "'..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]
local receiver = get_receiver(msg)
print('Deaktiviere "'..plugin..'" in diesem Chat')
return disable_plugin_on_chat(receiver, plugin)
return disable_plugin_on_chat(msg, plugin)
end
-- Disable a plugin
if matches[1] == 'disable' then
print("Deaktiviere: "..matches[2])
print('Deaktiviere: "'..matches[2]..'"')
return disable_plugin(matches[2])
end
-- Reload all the plugins!
if matches[1] == 'reload' then
return reload_plugins(true)
if matches[1] == 'reload' or '/reload' then
return reload_plugins()
end
end
return {
description = "Plugin Verwaltung",
usage = { "Das kann nur Akamaru" },
patterns = {"^/plugins$","^/plugins? (enable) ([%w_%.%-]+)$","^/plugins? (disable) ([%w_%.%-]+)$","^/plugins? (enable) ([%w_%.%-]+) (chat)","^/plugins? (disable) ([%w_%.%-]+) (chat)","^/plugins? (reload)$" },
description = "Aktiviert, deaktiviert und lädt Plugins (nur Superuser)",
usage = {
"/plugins: Liste alle Plugins auf.",
"/plugins enable [plugin]: Aktiviert Plugin.",
"/plugins disable [plugin]: Deaktiviert Plugin.",
"/plugins enable [plugin] chat: Aktiviert Plugin in diesem Chat.",
"/plugins disable [plugin] chat: Deaktiviert Plugin in diesem Chat.",
"/plugins reload: Lädt alle Plugins neu (Alias: /reload)."
},
patterns = {
"^/plugins$",
"^/plugins? (enable) ([%w_%.%-]+)$",
"^/plugins? (disable) ([%w_%.%-]+)$",
"^/plugins? (enable) ([%w_%.%-]+) (chat)",
"^/plugins? (disable) ([%w_%.%-]+) (chat)",
"^/plugins? (reload)$",
"^/reload$"
},
run = run,
privileged = true
}
end
privileged = true,
notyping = true
}
end

View File

@ -0,0 +1,49 @@
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

@ -0,0 +1,40 @@
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

@ -0,0 +1,65 @@
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

@ -0,0 +1,30 @@
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
}

52
plugins/ponyfaces.lua Normal file
View File

@ -0,0 +1,52 @@
-- 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 = 'http://ponyfac.es/api.json'
local function get_ponyface(tag)
local url = BASE_URL..'/tag:'..tag
local b,c = http.request(url)
if c ~= 200 then return nil end
local pf = json:decode(b).faces
-- truly randomize
math.randomseed(os.time())
-- random max json table size
local i = math.random(#pf)
local link_image = pf[i].image
return link_image
end
local function get_ponyface_by_id(id)
local url = BASE_URL..'/id:'..id
local res,code = http.request(url)
if code ~= 200 then return "HTTP-FEHLER" end
local data = json:decode(res)
return data.faces[1].image
end
local function run(msg, matches)
if tonumber(matches[1]) ~= nil then
local id = matches[1]
url = get_ponyface_by_id(id)
else
local tag = matches[1]
url = get_ponyface(tag)
end
local receiver = get_receiver(msg)
if url == "HTTP-FEHLER" then
return "Kein Ponyface gefunden :("
else
send_photo_from_url(receiver, url)
end
end
return {
description = "Sendet zufälliges Ponyface",
usage = "/ponyface [Tags]","/pf [Tags]",
patterns = {"^/ponyface (.*)$","^/pf (.*)$","ponyfac.es/(%d+[%d%.]*)"},
run = run
}
end

31
plugins/ponywave_img.lua Normal file
View File

@ -0,0 +1,31 @@
do
local function get_ponywave(part)
local url = 'http://img.ponywave.de/'..part..'.html'
local res,code = http.request(url)
if code ~= 200 then return "Fehler beim Abrufen von img.ponywave.de" end
local url = string.match(res, "id=\"codedirect\" value%=\"(.-)\" onclick")
return url
end
local function run(msg, matches)
local receiver = get_receiver(msg)
local part = matches[1]
local url = get_ponywave(part)
if string.ends(url, ".gif") then
send_document_from_url(receiver, url)
else
send_photo_from_url(receiver, url)
end
end
return {
description = "Mirrored Bild bei Link auf Preview-Seite von img.ponywave.de",
usage = "Preview-Link von img.ponywave.de",
patterns = {
"https?://img.ponywave.de/(.*).html"
},
run = run
}
end

15
plugins/porndoge.lua Normal file
View File

@ -0,0 +1,15 @@
function run(msg, matches)
local receiver = get_receiver(msg)
local url = 'https://porndoge.herokuapp.com/'
local file = download_to_file(url)
local cb_extra = {file_path=file}
send_photo(receiver, file, ok_cb, false)
end
return {
description = "",
usage = {""},
patterns = {"^/pdoge$"},
run = run
}
--by Akamaru [https://ponywave.de]

19
plugins/pornhub_gif.lua Normal file
View File

@ -0,0 +1,19 @@
local function run(msg, matches)
local receiver = get_receiver(msg)
local url = 'http://img.pornhub.com/gif/'..matches[1]..'.gif'
print("GIF URL: "..url)
send_document_from_url(receiver, url)
if string.starts(msg.text, '/phg') or string.starts(msg.text, '/porngif') then
return 'Source: http://www.pornhub.com/gif/'..matches[1]
else
return
end
end
return {
description = "Sendet GIFs von Pornhub.com",
usage = {"pornhub.com URL","/porngif [ID]","/phg [ID]"},
patterns = {"pornhub.com/gif/(.*)$","^/phg (.*)$","^/porngif (.*)$"},
run = run
}
--by Akamaru [https://ponywave.de]

43
plugins/pr0gramm.lua Normal file
View File

@ -0,0 +1,43 @@
function is_pr0_url(msg)
local url = split_by_space(msg.text)[1]
print(url)
if string.starts(url, "http://pr0gramm.com/") or string.starts(url, "http://www.pr0gramm.com/") then
return true
else
return false
end
end
if string.starts(msg.text, 'http://') or string.starts(msg.text, 'https://') then
if is_pr0_url(msg) then
local url = split_by_space(msg.text)[1]
local splited = split(url, "[\\/]+")
for a,x in pairs(splited) do
pr0_id = x
end
r, c, h = http.request("http://pr0gramm.com/api/items/get.json?id="..pr0_id)
local jsondata = json.decode(r)
local items = jsondata["items"]
for a, x in pairs(items) do
if tonumber(x["id"]) == tonumber(pr0_id) then
item = x
end
end
thumburl = item["thumb"]
local thumburlsplit = split(thumburl, "[\\/]+")
for a, x in pairs(thumburlsplit) do
thumbname = x
end
local file = "/tmp/"..thumbname
sh = "curl --insecure -o '"..file.."' ".."http://img.pr0gramm.com/"..thumburl
run_bash(sh)
send_photo(get_receiver(msg), file, ok_cb, false)
end
end
return {
description = "",
usage = {""},
patterns = {"https?://pr0gramm.com/"},
run = run
}

View File

@ -1,65 +1,75 @@
local quotes_file = './data/quotes.lua'
local quotes_table
do
function read_quotes_file()
local f = io.open(quotes_file, "r+")
local function save_quote(msg)
if msg.text:sub(11):isempty() then
return "Benutzung: !addquote [Zitat]"
end
local quote = msg.text:sub(11)
local hash = get_redis_hash(msg, 'quotes')
print('Saving quote to redis set '..hash)
redis:sadd(hash, quote)
return 'Gespeichert: "'..quote..'"'
end
if f == nil then
print ('Erstelle neue Zitat Datei '..quotes_file)
serialize_to_file({}, quotes_file)
local function delete_quote(msg)
if msg.text:sub(11):isempty() then
return "Benutzung: !delquote [Zitat]"
end
local quote = msg.text:sub(11)
local hash = get_redis_hash(msg, 'quotes')
print('Deleting quote from redis set '..hash)
if redis:sismember(hash, quote) == true then
redis:srem(hash, quote)
return 'Zitat erfolgreich gelöscht!'
else
return 'Dieses Zitat existiert nicht.'
end
end
local function get_quote(msg)
local to_id = tostring(msg.to.id)
local hash = get_redis_hash(msg, 'quotes')
if hash then
print('Getting quote from redis set '..hash)
quotes_table = redis:smembers(hash)
if not quotes_table[1] then
return 'Es wurden noch keine Zitate gespeichert.\nSpeichere doch welche mit !addquote [Zitat]'
else
return quotes_table[math.random(1,#quotes_table)]
end
end
end
local function run(msg, matches)
if string.match(msg.text, "/quote$") then
return get_quote(msg)
elseif matches[1] == "addquote" then
return save_quote(msg)
elseif matches[1] == "delquote" then
if not is_sudo(msg) then
return "Du bist kein Superuser. Dieser Vorfall wird gemeldet."
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
return delete_quote(msg)
end
end
end
return {
description = "Speichert Zitate",
usage = {"/addquote [Text]","/quote",},
patterns = {"^/addquote (.+)$","^/quote$",},
run = run
}
description = "Zitate speichern, löschen und abrufen.",
usage = {
"/addquote [Zitat]: Fügt Zitat hinzu.",
"/quote: Gibt zufälliges Zitat aus.",
"/delquote [Zitat]: Löscht das Zitat (nur Superuser)"
},
patterns = {
"^/(delquote) (.+)$",
"^/(addquote) (.+)$",
"^/quote$"
},
run = run
}
end

View File

@ -1,18 +1,19 @@
-- Function reference: http://mathjs.org/docs/reference/functions/categorical.html
local function mathjs(exp)
local exp = string.gsub(exp, "%,", "%.")
local url = 'http://api.mathjs.org/v1/'
url = url..'?expr='..URL.escape(exp)
local b,c = http.request(url)
local text = nil
if c == 200 then
text = 'Das Ergebnis ist '..b
text = 'Ergebnis: '..string.gsub(b, "%.", "%,")
elseif c == 400 then
text = b
else
text = 'Unexpected error\n'
..'Is api.mathjs.org up?'
text = 'Unerwarteter Fehler\n'
..'Ist api.mathjs.org erreichbar?'
end
return text
end
@ -22,8 +23,13 @@ local function run(msg, matches)
end
return {
description = "Ein simpler Taschenrechner",
usage = {"/calc [Rechnung]"},
patterns = {"^/calc (.*)$"},
description = "Rechnen mit der mathjs-API",
usage = {
"/calc [Ausdruck]: Rechnet",
"Weitere Hilfe: + = Plus, - = Minus, * = Mal, / = geteilt"
},
patterns = {
"^/calc (.*)$"
},
run = run
}

42
plugins/reddit.lua Normal file
View File

@ -0,0 +1,42 @@
-- 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://www.reddit.com'
function get_reddit_data (subreddit, reddit_code)
local url = BASE_URL..'/r/'..subreddit..'/comments/'..reddit_code..'.json'
local res,code = https.request(url)
if code ~= 200 then return "HTTP FEHLER" end
local data = json:decode(res)
return data
end
function send_reddit_data(data, receiver)
local title = data[1].data.children[1].data.title
local author = data[1].data.children[1].data.author
local subreddit = data[1].data.children[1].data.subreddit
local selftext = string.sub(unescape(data[1].data.children[1].data.selftext:gsub("%b<>", "")), 1, 300) .. '...'
local score = comma_value(data[1].data.children[1].data.score)
local comments = comma_value(data[1].data.children[1].data.num_comments)
local text = author..' in /r/'..subreddit..' ('..score..' Upvotes - '..comments..' Kommentare):\n'..title..'\n'..selftext
send_msg(receiver, text, ok_cb, false)
end
function run(msg, matches)
local subreddit = matches[1]
local reddit_code = matches[2]
local data = get_reddit_data(subreddit, reddit_code)
local receiver = get_receiver(msg)
send_reddit_data(data, receiver)
end
return {
description = "Gibt Reddit-Post aus.",
usage = "URL zu Reddit-Post.",
patterns = {"reddit.com/r/([A-Za-z0-9-/-_-.]+)/comments/([A-Za-z0-9-/-_-.]+)"},
run = run
}
end

View File

@ -9,5 +9,6 @@ return {
usage = {"/reload (kann nur Akamaru)"},
patterns = {"^/reload$"},
run = run,
privileged = true
privileged = true,
notyping = true
}

View File

@ -2,20 +2,28 @@ feedparser = (loadfile "./libs/feedparser.lua")()
local function unescape_for_rss(str)
-- Character encoding
str = string.gsub(str, "&#124;", "|")
str = string.gsub(str, "&#8249;", "")
str = string.gsub(str, "&lt;", "<")
str = string.gsub(str, "&acute;", "´")
str = string.gsub(str, "&gt;", ">")
str = string.gsub(str, "&#39;", "'")
str = string.gsub(str, "&#8217;", "'")
str = string.gsub(str, "&lt;", "<")
str = string.gsub(str, "&mdash;", "")
str = string.gsub(str, "&nabla;", "")
str = string.gsub(str, "&ndash;", "")
str = string.gsub(str, "&Psi;", "ψ")
str = string.gsub(str, "&psi;", "ψ")
str = string.gsub(str, "&raquo;", "»")
str = string.gsub(str, "&szlig;", "ß")
str = string.gsub(str, "&#39;", "'")
str = string.gsub(str, "&#124;", "|")
str = string.gsub(str, "&#160;", " ")
str = string.gsub(str, "&#187;", "»")
str = string.gsub(str, "&#223;", "ß")
str = string.gsub(str, "&#8211;", "")
str = string.gsub(str, "&#8217;", "'")
str = string.gsub(str, "&#8220;", "")
str = string.gsub(str, "&#8221;", "")
str = string.gsub(str, "&#8222;", "")
str = string.gsub(str, "&#8249;", "")
str = string.gsub(str, "&#8364;", "")
str = string.gsub(str, "&#223;", "ß")
-- Ä Ö Ü
str = string.gsub(str, "&auml;", "ä")
@ -30,7 +38,7 @@ local function unescape_for_rss(str)
str = string.gsub(str, "&Uuml;", "Ü")
str = string.gsub(str, "&#252;", "ü")
str = string.gsub(str, "&#220;", "Ü")
-- str = string.gsub( str, '&#(%d+);', function(n) return string.char(n) end ) <- There is a bug, but I don't know!?
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
@ -161,7 +169,7 @@ local function cron()
local keys = redis:keys(get_base_redis("*", "subs"))
for k,v in pairs(keys) do
local base = string.match(v, "rss:(.+):subs") -- Get the URL base
--print('Checke RSS: '..base)
print('Checke RSS: '..base)
local prot = redis:get(get_base_redis(base, "protocol"))
local last = redis:get(get_base_redis(base, "last_entry"))
local url = prot .. "://" .. base
@ -182,7 +190,7 @@ local function cron()
else
content = ''
end
text = text .. '[RSS] '.. title .. '\n'..content..'\n\n(' .. link .. ')\n\n'
text = text .. '[RSS] '.. title .. '\n'..content..'\n\n' .. link .. '\n\n'
end
if text ~= '' then
local newlast = newentr[1].id
@ -219,11 +227,11 @@ end
return {
description = "RSS-Feed Reader",
usage = {
"/rss: Feed-Abos anzeigen",
"/rss add (url): Diesen Feed abonnieren",
"/rss remove (id): Diesen Feed deabonnieren",
"/rss sync: Feeds aktualisieren"
usage = {"RSS Befehle kann nur Sudo\n",
"/rss (Feed-Abos anzeigen)",
"/rss add [URL] (Diesen Feed abonnieren)",
"/rss remove [NR] (Diesen Feed deabonnieren)",
"/rss sync (Feeds aktualisieren)"
},
patterns = {
"^/rss$",
@ -233,5 +241,6 @@ return {
},
run = run,
cron = cron,
privileged = true
privileged = true,
notyping = true
}

84
plugins/rss_old.lua Normal file
View File

@ -0,0 +1,84 @@
-- 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

36
plugins/safebrowsing.lua Normal file
View File

@ -0,0 +1,36 @@
-- 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://sb-ssl.google.com/safebrowsing/api'
local function check_malware (check_url, receiver)
local apikey = cred_data.google_apikey
local url = BASE_URL..'/lookup?client=brawlbot&key='..apikey..'&appver='..VERSION..'&pver=3.1&url='..check_url
local res,code = https.request(url)
if code > 204 then return send_msg(receiver, 'â<EFBFBD>“ Fehler '..code, ok_cb, false) end
if res == "" then
send_msg(receiver, '✅', ok_cb, false)
else
send_msg(receiver, '🚫', ok_cb, false)
end
end
local function run(msg, matches)
local check_url = URL.escape(matches[1])
local receiver = get_receiver(msg)
check_malware(check_url, receiver)
end
return {
description = "Sendet URL an Safebrowsing-Service und prüft auf Malware.",
usage = "!safe [URL]: Prüft URL mit Google Safebrowsing auf Malware",
patterns = {
"^/safe (https?://[%w-_%.%?%.:,/%+=&-@]+)$",
"^/safe ([%w-_%.%?%.:,/%+=&-@]+)$"
},
run = run
}
end

View File

@ -1,30 +1,52 @@
local _file_values = './data/values.lua'
local function save_value(msg, name, value)
if (not name or not value) then
return "Benutzung: !set Variable Wert"
end
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
local hash = get_redis_hash(msg, 'variables')
if hash then
print('Saving variable to redis hash '..hash)
redis:hset(hash, name, value)
return "Gespeichert: "..name.." = "..value
end
end
-- Save values to file
serialize_to_file(_values, _file_values)
return "Gespeichert: "..var_name.." = "..var_value
local function delete_value(msg, name, value)
if msg.to.type == 'chat' then
hash = 'chat:'..msg.to.id..':variables'
end
if msg.to.type == 'user' then
hash = 'user:'..msg.from.id..':variables'
end
if redis:hexists(hash, name) == true then
print('Deleting variable from redis hash '..hash)
redis:hdel(hash, name, value)
return 'Variable "'..name..'" erfolgreich gelöscht!'
else
return 'Du kannst keine Variable löschen, die nicht existiert .-.'
end
end
local function run(msg, matches)
local chat_id = tostring(msg.to.id)
local text = save_value(chat_id, msg.text)
return text
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 = "Setze Variable",
usage = {"/set [Variablenname] [Daten]"},
patterns = {"^/set (%a+) (.+)$"},
run = run
description = "Setzt Variablen, nutze !get zum Abrufen.",
usage = {
"/set [Variable] [Wert]: Speichert eine Variable mit einem Wert.",
"/set (Variable) nil: Löscht Variable"
},
patterns = {
"^/set ([^%s]+) (.+)$"
},
run = run
}

31
plugins/soundboard.lua Normal file
View File

@ -0,0 +1,31 @@
do
local function run(msg, matches)
local receiver = get_receiver(msg)
local url = "http://code.ponywave.de/workspace/mikubot/sounds/"..matches[1]..".mp3"
local file = download_to_file(url)
local cb_extra = {file_path=file}
if string.match(msg.text, "[Ll][Ii][Ss][Tt][Ee]") then
return 'Eine Liste aller Sounds findet ihr hier: https://ponywave.de/a/sounds'
end
if not file then
return "Nichts gefunden!"
else
print('Sende Datei')
send_document(receiver, file, rmtmp_cb, cb_extra)
end
end
return {
description = "Sound Bar",
usage = {"/sound [Name]"},
patterns = {
"^/sound (.*)$"
},
run = run
}
end

53
plugins/soundcloud.lua Normal file
View File

@ -0,0 +1,53 @@
-- 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 = 'http://api.soundcloud.com/resolve.json'
function get_soundcloud_data (sc_url)
local client_id = cred_data.soundcloud_client_id
local url = BASE_URL..'?url=http://soundcloud.com/'..sc_url..'&client_id='..client_id
local res,code = http.request(url)
if code ~= 200 then return "HTTP-FEHLER" end
local data = json:decode(res)
return data
end
function send_soundcloud_data(data, receiver)
local title = data.title
local description = data.description
local user = data.user.username
local user = 'Unbekannt'
local genre = data.genre
local playback_count = data.playback_count
milliseconds = data.duration
-- convert ms to mm:ss
totalseconds = math.floor(milliseconds / 1000)
milliseconds = milliseconds % 1000
seconds = totalseconds % 60
minutes = math.floor(totalseconds / 60)
hours = math.floor(minutes / 60)
minutes = minutes % 60
local duration = string.format("%02d:%02d", minutes, seconds)
local text = '"'..title..'" von "'..user..'"\n(Tag: '..genre..', '..duration..' Minuten; '..playback_count..' mal angehört)\n'..description
send_msg(receiver, text, ok_cb, false)
end
function run(msg, matches)
local sc_url = matches[1]
local data = get_soundcloud_data(sc_url)
local receiver = get_receiver(msg)
send_soundcloud_data(data, receiver)
end
return {
description = "Sendet Soundcloud-Info.",
usage = "Link zu SoundCloud-Track",
patterns = {"soundcloud.com/([A-Za-z0-9-/-_-.]+)"},
run = run
}
end

View File

@ -9,22 +9,29 @@ end
function run(msg, matches)
local user_name = get_name(msg)
if string.match(msg.text, "^[Rr][Ii][Cc][Hh] [Bb][Ii][Tt][Cc][Hh]$") then
if string.match(msg.text, "[Rr][Ii][Cc][Hh] [Bb][Ii][Tt][Cc][Hh]") then
return 'Akamaru ist nicht reich!'
elseif string.match(msg.text, "^#[Oo][Ll][Dd]$") then
elseif string.match(msg.text, "[Oo][Ll][Dd]") then
return 'Deine Mudda is old!'
elseif string.match(msg.text, "^[Nn][Yy][Uu]$") then
elseif string.match(msg.text, "[Nn][Yy][Uu]") then
send_photo(get_receiver(msg), "pictures/nyu.jpg", ok_cb, false)
elseif string.match(msg.text, "^[Nn][Oo][Pp][Ee].[Aa][Vv][Ii]$") then
elseif string.match(msg.text, "[Nn][Oo][Pp][Ee].[Aa][Vv][Ii]") then
send_video(get_receiver(msg), "videos/nope.avi", ok_cb, false)
return 'Video wird gesendet...'
elseif string.match(msg.text, "^[Nn][Ii][Ii][Ss][Aa][Nn]$") or string.match(msg.text, "^[Nn][Ii][Ii](-)[Ss][Aa][Nn]$") or string.match(msg.text, "^[Nn][Ii][Ss][Ss][Aa][Nn]$") then
elseif string.match(msg.text, "[Nn][Ii][Ii][Ss][Aa][Nn]") or string.match(msg.text, "[Nn][Ii][Ii](-)[Ss][Aa][Nn]") or string.match(msg.text, "[Nn][Ii][Ss][Ss][Aa][Nn]") then
send_photo(get_receiver(msg), "pictures/Nii-san.jpg", ok_cb, false)
elseif string.match(msg.text, "^/[Nn][Ee][Oo][Rr][Aa][Mm][Ee]$") then
elseif string.match(msg.text, "[Nn][Ee][Oo][Rr][Aa][Mm][Ee]") then
send_photo(get_receiver(msg), "pictures/neorame.jpg", ok_cb, false)
elseif string.match(msg.text, "^/[Nn][Aa][Uu]$") then
elseif string.match(msg.text, "[Nn][Aa][Uu]") then
send_photo(get_receiver(msg), "pictures/nau.jpg", ok_cb, false)
elseif string.match(msg.text, "^/[Ff][Tt][Tt]$") then
elseif string.match(msg.text, "[Ff][Tt][Tt]") then
return [[(°°) FLIP THAT TABLE.
(°°) FLIP THIS TABLE.
(`0`)/ FLIP ALL THE TABLES
@ -34,7 +41,8 @@ function run(msg, matches)
___ಠ Back.
(°-°)
(°°) NEVER]]
elseif string.match(msg.text, "^/[Ff][Tt][Ff]$") then
elseif string.match(msg.text, "[Ff][Tt][Ff]") then
return [[() FLIP THAT FATHER.
() FLIP THIS FATHER.
()/ FLIP ALL THE FATHERS
@ -44,29 +52,41 @@ function run(msg, matches)
Back.
()_ಠ
() NEVER]]
elseif string.match(msg.text, "^/[Nn][Bb][Cc]$") or string.match(msg.text, "^/[Ii][Dd][Cc]$") then
elseif string.match(msg.text, "[Nn][Bb][Cc]") or string.match(msg.text, "[Ii][Dd][Cc]") then
return [[¯\_(ツ)_/¯]]
elseif string.match(msg.text, "^/[Ll][Ff]$") then
elseif string.match(msg.text, "[Ll][Ff]") then
return '( ͡° ͜ʖ ͡°)'
elseif string.match(msg.text, "^/[Ll][Oo][Dd]$") then
elseif string.match(msg.text, "[Ll][Oo][Dd]") then
return 'ಠ_ಠ'
elseif string.match(msg.text, "^[Mm]ö[Pp]$") or string.match(msg.text, "^[Mm][Ee][Ee][Pp]$") then
elseif string.match(msg.text, "[Mm]ö[Pp]") or string.match(msg.text, "[Mm][Ee][Ee][Pp]") then
return 'se'
elseif string.match(msg.text, "^/[Ff][Rr][Oo][Ss][Cc][Hh]$") then
elseif string.match(msg.text, "[Ff][Rr][Oo][Ss][Cc][Hh]") then
return '🐸🐸🐸'
elseif string.match(msg.text, "^/[Bb][Aa][Rr][Uu][Ss][Aa][Mm][Ii][Kk][Oo][Ss][Uu]$") or string.match(msg.text, "^/[Bb][Aa][Ll][Ss][Aa][Mm][Ii][Kk][Oo] [Ee][Ss][Ss][Ii][Gg]$") then
elseif string.match(msg.text, "[Bb][Aa][Rr][Uu][Ss][Aa][Mm][Ii][Kk][Oo][Ss][Uu]") or string.match(msg.text, "[Bb][Aa][Ll][Ss][Aa][Mm][Ii][Kk][Oo] [Ee][Ss][Ss][Ii][Gg]") then
send_photo(get_receiver(msg), "pictures/luckystar/barusamikosu.jpg", ok_cb, false)
elseif string.match(msg.text, "^[Bb][Aa][Kk][Aa] [Bb][Oo][Tt]$") then
elseif string.match(msg.text, "[Bb][Aa][Kk][Aa] [Bb][Oo][Tt]") then
return "Gomen'nasai "..user_name.."-sempai 😣"
elseif string.match(msg.text, "^[Aa][Hh][Aa].[Pp][Nn][Gg]$") then
elseif string.match(msg.text, "[Aa][Hh][Aa].[Pp][Nn][Gg]") then
send_photo(get_receiver(msg), "pictures/aha.png", ok_cb, false)
elseif string.match(msg.text, "^~?[Pp][Oo][Ii]$") then
send_photo(get_receiver(msg), "pictures/poi.jpg", ok_cb, false)
elseif string.match(msg.text, "^/[Tt][Hh][Yy][Mm][Ee]$") then
elseif string.match(msg.text, "[Pp][Oo][Ii]") then
send_document(get_receiver(msg), "sticker/poi.webp", ok_cb, false)
elseif string.match(msg.text, "[Tt][Hh][Yy][Mm][Ee]") then
send_photo(get_receiver(msg), "pictures/thyme.jpg", ok_cb, false)
elseif string.match(msg.text, "^[Yy][Oo][Ll][Oo]$") then
elseif string.match(msg.text, "[Yy][Oo][Ll][Oo]") then
return 'Hä YOLO?'
elseif string.match(msg.text, "^/[Kk][Aa][Pp][Pp][Aa]$") then
elseif string.match(msg.text, "[Kk][Aa][Pp][Pp][Aa]") then
return [[
@ -75,12 +95,21 @@ function run(msg, matches)
]]
elseif string.match(msg.text, "[Ii] [Ww][Ii][Ss][Hh] [Ss][Qq][Uu][Ii][Dd][Ss] [Ww][Ee][Rr][Ee] [Rr][Ee][Aa][Ll]") then
send_photo(get_receiver(msg), "pictures/squid.jpg", ok_cb, false)
--sleep(2)
return 'They are'
elseif string.match(msg.text, "[Ff][Gg][Tt]") then
return --'Deine Mudda is fgt!'
--elseif string.match(msg.text, "[Ff][Gg][Tt]") then
--return 'Deine Mudda is fgt!'
elseif string.match(msg.text, "[Kk][Ii][Ll][Ll]") then
return user_name..' tötet '..matches[1]
elseif string.match(msg.text, "[Ii][Nn][Ll][Oo][Vv][Ee]") then
send_document(get_receiver(msg), "pictures/inlove.gif", ok_cb, false)
end
end
@ -114,7 +143,9 @@ return {
"^[Yy][Oo][Ll][Oo]$",
"^/[Kk][Aa][Pp][Pp][Aa]$",
"[Ii] [Ww][Ii][Ss][Hh] [Ss][Qq][Uu][Ii][Dd][Ss] [Ww][Ee][Rr][Ee] [Rr][Ee][Aa][Ll]",
"[Ff][Gg][Tt]"
--"[Ff][Gg][Tt]",
"^/[Kk][Ii][Ll][Ll] (.*)",
"^[Ii][Nn][Ll][Oo][Vv][Ee]$"
},
run = run
}

20
plugins/speedtest.lua Normal file
View File

@ -0,0 +1,20 @@
--[[Requires speedtest-cli (https://github.com/sivel/speedtest-cli)
$ wget -O speedtest-cli https://raw.github.com/sivel/speedtest-cli/master/speedtest_cli.py
$ chmod +x speedtest-cli
$ sudo mv speedtest-cli /usr/local/bin/speedtest-cli
]]
function run(msg, matches)
local receiver = get_receiver(msg)
local text = run_bash('speedtest-cli --share')
local photo = string.match(text,"Share results: (.*)")
send_photo_from_url(receiver, photo)
end
return {
description = "Führt eine Speedtest aus",
usage = {"/speedtest"},
patterns = {"^/[Ss][Pp][Ee][Ee][Dd][Tt][Ee][Ss][Tt]$"},
run = run
}
--by Akamaru [https://ponywave.de]

13
plugins/speedtest_net.lua Normal file
View File

@ -0,0 +1,13 @@
local function run(msg, matches)
local receiver = get_receiver(msg)
local url = 'http://www.speedtest.net/result/'..matches[1]..'.png'
send_photo_from_url(receiver, url)
end
return {
description = "Speedtest.net Mirror",
usage = {"Speedtest.net Result Link"},
patterns = {"speedtest.net/my%-result/([0-9]+)"},
run = run
}
--by Akamaru [https://ponywave.de]

58
plugins/spotify.lua Normal file
View File

@ -0,0 +1,58 @@
-- 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://api.spotify.com/v1'
function get_track_data (track)
local url = BASE_URL..'/tracks/'..track
local res,code = https.request(url)
if code ~= 200 then return "HTTP-FEHLER" end
local data = json:decode(res)
return data
end
function send_track_data(data, receiver)
local name = data.name
local album = data.album.name
local artist = data.artists[1].name
local preview = data.preview_url
local milliseconds = data.duration_ms
-- 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 text = '"'..name..' von '..artist..'" aus dem Album "'..album..'" ('..duration..' Minuten)'
if preview then
local file = download_to_file(preview, 'VORSCHAU: '..name..'.mp3')
send_msg(receiver, text, ok_cb, false)
send_document(receiver, file, ok_cb, false)
else
send_msg(receiver, text, ok_cb, false)
end
end
function run(msg, matches)
local track = matches[1]
local data = get_track_data(track)
local receiver = get_receiver(msg)
send_track_data(data, receiver)
end
return {
description = "Sendet Spotify-Info.",
usage = "Link zu Spotify-Track",
patterns = {
"open.spotify.com/track/([A-Za-z0-9-]+)",
"play.spotify.com/track/([A-Za-z0-9-]+)"
},
run = run
}
end

View File

@ -0,0 +1,70 @@
-- 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://api.spotify.com/v1/search'
local function get_spotify_result (track)
local limit = '4'
local url = BASE_URL..'?type=track&q='..track..'&market=DE&limit='..limit
local res,code = https.request(url)
if code ~= 200 then return "HTTP-FEHLER" end
local data = json:decode(res).tracks
if not data.items[1] then return 'Nichts gefunden!' end
return data
end
local function send_spotify_data(data, receiver)
local text = ""
for track in pairs(data.items) do
text = text..'"'..data.items[track].name..'" von '..data.items[track].artists[1].name
if data.items[track].album.name and data.items[track].album.name ~= data.items[track].name then
text = text..' aus dem Album '..data.items[track].album.name
end
-- convert ms to mm:ss
local milliseconds = data.items[track].duration_ms
local totalseconds = math.floor(milliseconds / 1000)
local milliseconds = milliseconds % 1000
local seconds = totalseconds % 60
local minutes = math.floor(totalseconds / 60)
local hours = math.floor(minutes / 60)
local minutes = minutes % 60
local duration = string.format("%02d:%02d", minutes, seconds)
text = text..'\nLänge: '..duration
if data.items[track].preview_url then
text = text..'\nVorschau: '..data.items[track].preview_url
end
text = text..'\n'..data.items[track].external_urls.spotify..'\n\n'
end
send_large_msg(receiver, text, ok_cb, false)
end
local function run(msg, matches)
local track = URL.escape(matches[1])
local data = get_spotify_result(track)
if data == "Nichts gefunden!" then
return 'Nichts gefunden!'
elseif not data then
return 'HTTP-Fehler!'
else
local receiver = get_receiver(msg)
send_spotify_data(data, receiver)
end
end
return {
description = "Sucht nach Tracks auf Spotify",
usage = "/spotify [Track]: Sucht nach einem Track auf Spotify",
patterns = {"^/spotify (.*)$"},
run = run
}
end

View File

@ -1,29 +1,34 @@
function run(msg, matches)
return
[[
Name: Gronkh
Link: https://telegram.me/addstickers/Gronkh
Name: Miku Hatsune
Link: https://telegram.me/addstickers/MikuHatsune
Name: Naira
Link: https://telegram.me/addstickers/Naira
Name: Naira2
Link: https://telegram.me/addstickers/Naira2
Name: Miku Hatsune
Link: https://telegram.me/addstickers/MikuHatsune
Name: Pinkie Pie
Link: https://telegram.me/addstickers/PinkiePie
Name: Sharks
Link: https://telegram.me/addstickers/Sharks
Name: Sinnloser Scheiß
Link: https://telegram.me/addstickers/grummipol
Name: Gronkh
Link: https://telegram.me/addstickers/Gronkh
Name: Sword Art Online
Link: https://telegram.me/addstickers/SwordArtOnlinePack
Name: Würfel
Link: https://telegram.me/addstickers/Wuerfel
Stickerpacks by @Akamaru
]]
end

46
plugins/text_get.lua Normal file
View File

@ -0,0 +1,46 @@
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)
if matches[2] then
return get_value(msg, matches[2])
else
return list_variables(msg)
end
end
return {
description = "",
usage = {},
patterns = {"^/save$"},
run = run,
privileged = true
}

45
plugins/text_set.lua Normal file
View File

@ -0,0 +1,45 @@
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
}

Some files were not shown because too many files have changed in this diff Show More