- Restrukturierung: "require" wird nun nicht mehr in jedem Plugin benötigt

- Echo: Korrekte Ausgabe in Supergruppen
This commit is contained in:
Andreas Bielawski 2016-07-31 21:29:44 +02:00
parent 01bdfab0aa
commit 2118a844d9
126 changed files with 80 additions and 619 deletions

View File

@ -1,17 +1,11 @@
local bot = {}
-- Requires are moved to init to allow for reloads.
local bindings -- Load Telegram bindings.
local utilities -- Load miscellaneous and cross-plugin functions.
local redis = (loadfile "./otouto/redis.lua")()
bindings = require('otouto.bindings')
utilities = require('otouto.utilities')
bot.version = '2.2.3.2'
function bot:init(config) -- The function run when the bot is started or reloaded.
bindings = require('otouto.bindings')
utilities = require('otouto.utilities')
redis = (loadfile "./otouto/redis.lua")()
cred_data = load_cred()
assert(

View File

@ -1,11 +1,5 @@
local ninegag = {}
local HTTP = require('socket.http')
local URL = require('socket.url')
local JSON = require('dkjson')
local utilities = require('otouto.utilities')
local bindings = require('otouto.bindings')
ninegag.command = '9gag'
function ninegag:init(config)
@ -20,9 +14,9 @@ end
local url = "http://api-9gag.herokuapp.com/"
function ninegag:get_9GAG()
local b,c = HTTP.request(url)
local b,c = http.request(url)
if c ~= 200 then return nil end
local gag = JSON.decode(b)
local gag = json.decode(b)
-- random max json table size
local i = math.random(#gag)
@ -33,9 +27,9 @@ function ninegag:get_9GAG()
end
function ninegag:inline_callback(inline_query, config)
local res, code = HTTP.request(url)
local res, code = http.request(url)
if code ~= 200 then return end
local gag = JSON.decode(res)
local gag = json.decode(res)
local results = '['
for n in pairs(gag) do

View File

@ -1,7 +1,6 @@
local about = {}
local bot = require('otouto.bot')
local utilities = require('otouto.utilities')
about.command = 'about'
about.doc = '`Sendet Informationen über den Bot.`'

View File

@ -1,9 +1,5 @@
local adfly = {}
local utilities = require('otouto.utilities')
local HTTPS = require('ssl.https')
local redis = (loadfile "./otouto/redis.lua")()
function adfly:init(config)
adfly.triggers = {
'adf.ly/([A-Za-z0-9-_-]+)'
@ -15,7 +11,7 @@ end
function adfly:expand_adfly_link(adfly_code)
local BASE_URL = 'https://andibi.tk/dl/adfly.php'
local url = BASE_URL..'/?url=http://adf.ly/'..adfly_code
local res,code = HTTPS.request(url)
local res,code = https.request(url)
if code ~= 200 then return nil end
if res == 'Fehler: Keine Adf.ly-URL gefunden!' then return 'NOTFOUND' end
cache_data('adfly', adfly_code, res, 31536000, 'key')

View File

@ -3,9 +3,6 @@
local afk = {}
local utilities = require('otouto.utilities')
local redis = (loadfile "./otouto/redis.lua")()
function afk:init(config)
afk.triggers = {
"^/([A|a][F|f][K|k])$",

View File

@ -1,10 +1,5 @@
local app_store = {}
local https = require('ssl.https')
local json = require('dkjson')
local utilities = require('otouto.utilities')
local redis = (loadfile "./otouto/redis.lua")()
app_store.triggers = {
"itunes.apple.com/(.*)/app/(.*)/id(%d+)",
"^/itunes (%d+)$",

View File

@ -1,13 +1,5 @@
local bImages = {}
local HTTPS = require('ssl.https')
HTTPS.timeout = 10
local URL = require('socket.url')
local JSON = require('dkjson')
local redis = (loadfile "./otouto/redis.lua")()
local utilities = require('otouto.utilities')
local bindings = require('otouto.bindings')
function bImages:init(config)
if not cred_data.bing_search_key then
print('Missing config value: bing_search_key.')
@ -36,9 +28,9 @@ function bImages:getImages(query)
["Ocp-Apim-Subscription-Key"] = apikey
}
}
local ok, response_code, response_headers = HTTPS.request(request_constructor)
local ok, response_code, response_headers = https.request(request_constructor)
if not ok then return end
local images = JSON.decode(table.concat(response_body)).value
local images = json.decode(table.concat(response_body)).value
if not images[1] then return end

View File

@ -1,9 +1,5 @@
local banhammer = {}
local bindings = require('otouto.bindings')
local utilities = require('otouto.utilities')
local redis = (loadfile "./otouto/redis.lua")()
banhammer.command = 'banhammer <nur für Superuser>'
function banhammer:init(config)

View File

@ -1,10 +1,5 @@
local bitly = {}
local https = require('ssl.https')
local json = require('dkjson')
local utilities = require('otouto.utilities')
local redis = (loadfile "./otouto/redis.lua")()
function bitly:init(config)
if not cred_data.bitly_access_token then
print('Missing config value: bitly_access_token.')

View File

@ -1,14 +1,5 @@
local bitly_create = {}
local http = require('socket.http')
local https = require('ssl.https')
local URL = require('socket.url')
local json = require('dkjson')
local utilities = require('otouto.utilities')
local bindings = require('otouto.bindings')
local OAuth = require "OAuth"
local redis = (loadfile "./otouto/redis.lua")()
function bitly_create:init(config)
if not cred_data.bitly_client_id then
print('Missing config value: bitly_client_id.')

View File

@ -1,11 +1,5 @@
local br = {}
local https = require('ssl.https')
local URL = require('socket.url')
local json = require('dkjson')
local utilities = require('otouto.utilities')
local bindings = require('otouto.bindings')
br.triggers = {
"br.de/nachrichten/(.*).html$"
}

View File

@ -1,11 +1,5 @@
local btc = {}
local https = require('ssl.https')
local URL = require('socket.url')
local json = require('dkjson')
local utilities = require('otouto.utilities')
local bindings = require('otouto.bindings')
function btc:init(config)
btc.triggers = {
"^/btc$"

View File

@ -1,9 +1,5 @@
local calc = {}
local URL = require('socket.url')
local http = require('socket.http')
local utilities = require('otouto.utilities')
calc.command = 'calc <Ausdruck>'
function calc:init(config)

View File

@ -1,9 +1,5 @@
local cats = {}
local https = require('ssl.https')
local json = require('dkjson')
local utilities = require('otouto.utilities')
cats.command = 'cat [gif]'
function cats:init(config)

View File

@ -1,8 +1,5 @@
local channel = {}
local bindings = require('otouto.bindings')
local utilities = require('otouto.utilities')
channel.command = 'ch <Kanal> \\n <Nachricht>'
channel.doc = [[*
/ch*_ <Kanal>_|_[Inline-Keyboard]_

View File

@ -1,9 +1,5 @@
local channels = {}
local bindings = require('otouto.bindings')
local utilities = require('otouto.utilities')
local redis = (loadfile "./otouto/redis.lua")()
channels.command = 'channel <nur für Superuser>'
function channels:init(config)

View File

@ -1,10 +1,5 @@
local cleverbot = {}
local https = require('ssl.https')
local URL = require('socket.url')
local utilities = require('otouto.utilities')
local json = require('dkjson')
function cleverbot:init(config)
cleverbot.triggers = {
"^/cbot (.*)$"

View File

@ -1,10 +1,5 @@
local clypit = {}
local http = require('socket.http')
local json = require('dkjson')
local utilities = require('otouto.utilities')
local bindings = require('otouto.bindings')
clypit.triggers = {
"clyp.it/([A-Za-z0-9-_-]+)"
}

View File

@ -1,8 +1,6 @@
local control = {}
local bot = require('otouto.bot')
local utilities = require('otouto.utilities')
local cmd_pat -- Prevents the command from being uncallable.
function control:init(config)

View File

@ -1,8 +1,5 @@
local creds_manager = {}
local utilities = require('otouto.utilities')
local redis = (loadfile "./otouto/redis.lua")()
function creds_manager:init(config)
creds_manager.triggers = {
"^(/creds)$",

View File

@ -1,8 +1,5 @@
local currency = {}
local HTTPS = require('ssl.https')
local utilities = require('otouto.utilities')
currency.command = 'cash [Menge] <von> <zu>'
function currency:init(config)
@ -42,7 +39,7 @@ function currency:action(msg, config)
end
local url = BASE_URL..'?from='..from..'&to='..to..'&a='..amount
local str, res = HTTPS.request(url)
local str, res = https.request(url)
if res ~= 200 then
utilities.send_reply(self, msg, config.errors.connection)
return

View File

@ -1,9 +1,5 @@
local dailymotion = {}
local https = require('ssl.https')
local json = require('dkjson')
local utilities = require('otouto.utilities')
dailymotion.triggers = {
"dailymotion.com/video/([A-Za-z0-9-_-]+)"
}

View File

@ -1,9 +1,5 @@
local deviantart = {}
local https = require('ssl.https')
local json = require('dkjson')
local utilities = require('otouto.utilities')
deviantart.triggers = {
"http://(.*).deviantart.com/art/(.*)"
}

View File

@ -1,9 +1,5 @@
local dhl = {}
local https = require('ssl.https')
local json = require('dkjson')
local utilities = require('otouto.utilities')
function dhl:init(config)
dhl.triggers = {
"/dhl (%d+)$"

View File

@ -2,10 +2,6 @@
local dropbox = {}
local https = require('ssl.https')
local json = require('dkjson')
local utilities = require('otouto.utilities')
dropbox.triggers = {
"dropbox.com/s/([a-z0-9]+)/(.*)"
}

View File

@ -1,7 +1,5 @@
local echo = {}
local utilities = require('otouto.utilities')
echo.command = 'echo <Text>'
function echo:init(config)
@ -35,6 +33,8 @@ function echo:action(msg)
local output
if msg.chat.type == 'supergroup' then
output = '*Echo:*\n"' .. utilities.md_escape(input) .. '"'
utilities.send_message(self, msg.chat.id, output, true, nil, true)
return
end
utilities.send_message(self, msg.chat.id, input, true, nil, true)
end

View File

@ -1,8 +1,5 @@
local entergroup = {}
local utilities = require('otouto.utilities')
local bindings = require('otouto.bindings')
entergroup.triggers = {
'/nil'
}

View File

@ -1,8 +1,5 @@
local expand = {}
local http = require('socket.http')
local utilities = require('otouto.utilities')
function expand:init(config)
expand.triggers = {
"^/expand (https?://[%w-_%.%?%.:/%+=&]+)$"

View File

@ -1,13 +1,5 @@
local facebook = {}
local http = require('socket.http')
local https = require('ssl.https')
local URL = require('socket.url')
local json = require('dkjson')
local utilities = require('otouto.utilities')
local bindings = require('otouto.bindings')
local redis = (loadfile "./otouto/redis.lua")()
function facebook:init(config)
if not cred_data.fb_access_token then
print('Missing config value: fb_access_token.')

View File

@ -1,9 +1,5 @@
local fefe = {}
local https = require('ssl.https')
local json = require('dkjson')
local utilities = require('otouto.utilities')
fefe.triggers = {
"blog.fefe.de/%?ts=%w%w%w%w%w%w%w%w"
}

View File

@ -1,10 +1,5 @@
local flickr = {}
local https = require('ssl.https')
local json = require('dkjson')
local utilities = require('otouto.utilities')
local bindings = require('otouto.bindings')
function flickr:init(config)
if not cred_data.flickr_apikey then
print('Missing config value: flickr_apikey.')

View File

@ -1,10 +1,5 @@
local flickr_search = {}
local https = require('ssl.https')
local json = require('dkjson')
local utilities = require('otouto.utilities')
local bindings = require('otouto.bindings')
function flickr_search:init(config)
if not cred_data.flickr_apikey then
print('Missing config value: flickr_apikey.')

View File

@ -1,12 +1,5 @@
local forecast = {}
local HTTPS = require('ssl.https')
local URL = require('socket.url')
local JSON = require('dkjson')
local utilities = require('otouto.utilities')
local bindings = require('otouto.bindings')
local redis = (loadfile "./otouto/redis.lua")()
function forecast:init(config)
if not cred_data.forecastio_apikey then
print('Missing config value: forecastio_apikey.')
@ -46,9 +39,9 @@ function get_city_name(lat, lng)
local city = redis:hget('telegram:cache:weather:pretty_names', lat..','..lng)
if city then return city end
local url = 'https://maps.googleapis.com/maps/api/geocode/json?latlng='..lat..','..lng..'&result_type=political&language=de&key='..google_apikey
local res, code = HTTPS.request(url)
local res, code = https.request(url)
if code ~= 200 then return 'Unbekannte Stadt' end
local data = JSON.decode(res).results[1]
local data = json.decode(res).results[1]
local city = data.formatted_address
print('Setting '..lat..','..lng..' in redis hash telegram:cache:weather:pretty_names to "'..city..'"')
redis:hset('telegram:cache:weather:pretty_names', lat..','..lng, city)
@ -107,9 +100,9 @@ function forecast:get_forecast(lat, lng)
method = "GET",
sink = ltn12.sink.table(response_body)
}
local ok, response_code, response_headers, response_status_line = HTTPS.request(request_constructor)
local ok, response_code, response_headers, response_status_line = https.request(request_constructor)
if not ok then return nil end
local data = JSON.decode(table.concat(response_body))
local data = json.decode(table.concat(response_body))
local ttl = string.sub(response_headers["cache-control"], 9)
@ -153,9 +146,9 @@ function forecast:get_forecast_hourly(lat, lng)
method = "GET",
sink = ltn12.sink.table(response_body)
}
local ok, response_code, response_headers, response_status_line = HTTPS.request(request_constructor)
local ok, response_code, response_headers, response_status_line = https.request(request_constructor)
if not ok then return nil end
local data = JSON.decode(table.concat(response_body))
local data = json.decode(table.concat(response_body))
local ttl = string.sub(response_headers["cache-control"], 9)

View File

@ -3,14 +3,6 @@
local gImages = {}
local HTTPS = require('ssl.https')
HTTPS.timeout = 10
local URL = require('socket.url')
local JSON = require('dkjson')
local redis = (loadfile "./otouto/redis.lua")()
local utilities = require('otouto.utilities')
local bindings = require('otouto.bindings')
function gImages:init(config)
if not cred_data.google_apikey then
print('Missing config value: google_apikey.')
@ -115,8 +107,8 @@ function gImages:get_image(input)
local cseid = cred_data.google_cse_id
local BASE_URL = 'https://www.googleapis.com/customsearch/v1'
local url = BASE_URL..'/?searchType=image&alt=json&num=10&key='..apikey..'&cx='..cseid..'&safe=high'..'&q=' .. input .. '&fields=items(link,mime,image(contextLink))'
local jstr, res = HTTPS.request(url)
local jdat = JSON.decode(jstr).items
local jstr, res = https.request(url)
local jdat = json.decode(jstr).items
if not jdat then
return 'NORESULTS'

View File

@ -1,8 +1,5 @@
local gMaps = {}
local URL = require('socket.url')
local utilities = require('otouto.utilities')
gMaps.command = 'loc <Ort>'
function gMaps:init(config)

View File

@ -1,10 +1,5 @@
local gSearch = {}
local HTTPS = require('ssl.https')
local URL = require('socket.url')
local JSON = require('dkjson')
local utilities = require('otouto.utilities')
gSearch.command = 'google <Suchbegriff>'
function gSearch:init(config)
@ -23,7 +18,7 @@ function gSearch:googlethat(query, config)
local api = BASE_URL.."/?key="..apikey.."&cx="..cseid.."&gl=de&num="..number.."&safe=medium&fields=searchInformation%28formattedSearchTime,formattedTotalResults%29,items%28title,link,displayLink%29&"
local parameters = "q=".. (URL.escape(query) or "")
-- Do the request
local res, code = HTTPS.request(api..parameters)
local res, code = https.request(api..parameters)
if code == 403 then
return '403'
end

View File

@ -1,10 +1,6 @@
local games = {}
local http = require('socket.http')
local URL = require('socket.url')
local xml = require("xml")
local utilities = require('otouto.utilities')
local bindings = require('otouto.bindings')
games.command = 'game <Spiel>'

View File

@ -1,11 +1,5 @@
local gdrive = {}
local utilities = require('otouto.utilities')
local https = require('ssl.https')
local ltn12 = require('ltn12')
local json = require('dkjson')
local bindings = require('otouto.bindings')
function gdrive:init(config)
if not cred_data.google_apikey then
print('Missing config value: google_apikey.')

View File

@ -1,8 +1,5 @@
local get = {}
local utilities = require('otouto.utilities')
local redis = (loadfile "./otouto/redis.lua")()
get.command = 'get <Variable>'
function get:init(config)

View File

@ -4,12 +4,6 @@
local media_download = {}
local utilities = require('otouto.utilities')
local bindings = require('otouto.bindings')
local ltn12 = require('ltn12')
local HTTPS = require('ssl.https')
local redis = (loadfile "./otouto/redis.lua")()
media_download.triggers = {
'/nil'
}
@ -22,7 +16,7 @@ function media_download:download_to_file_permanently(url, file_name)
redirect = false
}
local response = nil
response = {HTTPS.request(options)}
response = {https.request(options)}
local code = response[2]
local headers = response[3]

View File

@ -2,10 +2,6 @@
local gfycat = {}
local https = require('ssl.https')
local json = require('dkjson')
local utilities = require('otouto.utilities')
gfycat.triggers = {
"gfycat.com/([A-Za-z0-9-_-]+)"
}

View File

@ -1,10 +1,5 @@
local giphy = {}
local http = require('socket.http')
local URL = require('socket.url')
local JSON = require('dkjson')
local utilities = require('otouto.utilities')
function giphy:init(config)
giphy.triggers = {
"/nil"
@ -26,7 +21,7 @@ function giphy:get_gifs(query)
end
local res, code = http.request(url)
if code ~= 200 then return nil end
return JSON.decode(res).data
return json.decode(res).data
end
function giphy:inline_callback(inline_query, config, matches)

View File

@ -1,13 +1,5 @@
local github = {}
local http = require('socket.http')
local https = require('ssl.https')
local URL = require('socket.url')
local json = require('dkjson')
local utilities = require('otouto.utilities')
local bindings = require('otouto.bindings')
local redis = (loadfile "./otouto/redis.lua")()
function github:init(config)
github.triggers = {
"github.com/([A-Za-z0-9-_-.-._.]+)/([A-Za-z0-9-_-.-._.]+)/commit/([a-z0-9-]+)",

View File

@ -1,10 +1,5 @@
local golem = {}
local http = require('socket.http')
local json = require('dkjson')
local utilities = require('otouto.utilities')
local bindings = require('otouto.bindings')
function golem:init(config)
if not cred_data.golem_apikey then
print('Missing config value: golem_apikey.')

View File

@ -1,9 +1,5 @@
local googl = {}
local https = require('ssl.https')
local json = require('dkjson')
local utilities = require('otouto.utilities')
function googl:init(config)
if not cred_data.google_apikey then
print('Missing config value: google_apikey.')

View File

@ -1,8 +1,5 @@
local gps = {}
local utilities = require('otouto.utilities')
local bindings = require('otouto.bindings')
gps.command = 'gps <Breitengrad>,<Längengrad>'
function gps:init(config)

View File

@ -4,8 +4,6 @@
local greetings = {}
local utilities = require('otouto.utilities')
function greetings:init(config)
config.greetings = config.greetings or {
['Hello, #NAME.'] = {

View File

@ -1,10 +1,5 @@
local hackernews = {}
local https = require('ssl.https')
local json = require('dkjson')
local URL = require('socket.url')
local utilities = require('otouto.utilities')
hackernews.triggers = {
"news.ycombinator.com/item%?id=(%d+)"
}

View File

@ -1,11 +1,5 @@
local heise = {}
local https = require('ssl.https')
local URL = require('socket.url')
local json = require('dkjson')
local utilities = require('otouto.utilities')
local bindings = require('otouto.bindings')
heise.triggers = {
"heise.de/newsticker/meldung/(.*).html$"
}

View File

@ -1,7 +1,5 @@
local hello = {}
local utilities = require('otouto.utilities')
hello.triggers = {
"^[Ss][Aa][Gg] [Hh][Aa][Ll][Ll][Oo] [Zz][Uu] (.*)$"
}

View File

@ -3,8 +3,6 @@
local help = {}
local utilities = require('otouto.utilities')
local help_text
function help:init(config)

View File

@ -1,9 +1,5 @@
local id = {}
local redis = (loadfile "./otouto/redis.lua")()
local bindings = require('otouto.bindings')
local utilities = require('otouto.utilities')
id.command = 'id'
function id:init(config)

View File

@ -1,11 +1,5 @@
local ifttt = {}
local https = require('ssl.https')
local URL = require('socket.url')
local redis = (loadfile "./otouto/redis.lua")()
local utilities = require('otouto.utilities')
local bindings = require('otouto.bindings')
function ifttt:init(config)
ifttt.triggers = {
"^/ifttt (!set) (.*)$",

View File

@ -1,6 +1,5 @@
local images = {}
local utilities = require('otouto.utilities')
images.triggers = {
"(https?://[%w-_%%%.%?%.:,/%+=~&%[%]]+%.[Pp][Nn][Gg])$",
"(https?://[%w-_%%%.%?%.:,/%+=~&%[%]]+%.[Jj][Pp][Ee]?[Gg])$"

View File

@ -1,11 +1,5 @@
local imdb = {}
local HTTP = require('socket.http')
local URL = require('socket.url')
local JSON = require('dkjson')
local utilities = require('otouto.utilities')
local bindings = require('otouto.bindings')
imdb.command = 'imdb <query>'
function imdb:init(config)
@ -29,13 +23,13 @@ function imdb:action(msg, config)
local url = 'http://www.omdbapi.com/?t=' .. URL.escape(input)
local jstr, res = HTTP.request(url)
local jstr, res = http.request(url)
if res ~= 200 then
utilities.send_reply(self, msg, config.errors.connection)
return
end
local jdat = JSON.decode(jstr)
local jdat = json.decode(jstr)
if jdat.Response ~= 'True' then
utilities.send_reply(self, msg, config.errors.results)

View File

@ -1,8 +1,5 @@
local imgblacklist = {}
local utilities = require('otouto.utilities')
local redis = (loadfile "./otouto/redis.lua")()
imgblacklist.command = 'imgblacklist'
function imgblacklist:init(config)

View File

@ -1,9 +1,5 @@
local imgur = {}
local https = require('ssl.https')
local json = require('dkjson')
local utilities = require('otouto.utilities')
function imgur:init(config)
if not cred_data.imgur_client_id then
print('Missing config value: imgur_client_id.')

View File

@ -1,10 +1,5 @@
local instagram = {}
local https = require('ssl.https')
local json = require('dkjson')
local URL = require('socket.url')
local utilities = require('otouto.utilities')
function instagram:init(config)
if not cred_data.instagram_access_token then
print('Missing config value: instagram_access_token.')

View File

@ -1,10 +1,5 @@
local ip_info = {}
local http = require('socket.http')
local json = require('dkjson')
local URL = require('socket.url')
local utilities = require('otouto.utilities')
function ip_info:init(config)
ip_info.triggers = {
"^/ip (.*)$",

View File

@ -1,10 +1,6 @@
local isup = {}
local http = require('socket.http')
local https = require('ssl.https')
local socket = require('socket')
local URL = require('socket.url')
local utilities = require('otouto.utilities')
function isup:init(config)
isup.triggers = {

View File

@ -1,8 +1,5 @@
local leave_group = {}
local utilities = require('otouto.utilities')
local bindings = require('otouto.bindings')
leave_group.triggers = {
'/nil'
}

View File

@ -1,8 +1,5 @@
local loc_manager = {}
local utilities = require('otouto.utilities')
local redis = (loadfile "./otouto/redis.lua")()
function loc_manager:init(config)
loc_manager.triggers = {
"^/location (set) (.*)$",

View File

@ -1,9 +1,5 @@
local luarun = {}
local utilities = require('otouto.utilities')
local URL = require('socket.url')
local JSON = require('dkjson')
function luarun:init(config)
luarun.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('lua', true):t('return', true).table
end
@ -28,17 +24,17 @@ function luarun:action(msg, config)
local bot = require('otouto.bot')
local bindings = require('otouto.bindings')
local utilities = require('otouto.utilities')
local JSON = require('dkjson')
local json = require('dkjson')
local URL = require('socket.url')
local HTTP = require('socket.http')
local HTTPS = require('ssl.https')
local http = require('socket.http')
local https = require('ssl.https')
return function (self, msg, config) ]] .. input .. [[ end
]] )()(self, msg, config)
if output == nil then
output = 'Done!'
else
if type(output) == 'table' then
local s = JSON.encode(output, {indent=true})
local s = json.encode(output, {indent=true})
if URL.escape(s):len() < 4000 then
output = s
end

View File

@ -1,9 +1,5 @@
local lyrics = {}
local http = require('socket.http')
local json = require('dkjson')
local utilities = require('otouto.utilities')
function lyrics:init(config)
if not cred_data.lyricsnmusic_apikey then
print('Missing config value: lyricsnmusic_apikey.')

View File

@ -1,7 +1,5 @@
local muschel = {}
local utilities = require('otouto.utilities')
muschel.triggers = {
"^[Mm][Aa][Gg][Ii][Ss][Cc][Hh][Ee] [Mm][Ii][Ee][Ss][Mm][Uu][Ss][Cc][Hh][Ee][Ll], (.*)$"
}

View File

@ -1,11 +1,5 @@
local media = {}
local HTTP = require('socket.http')
local HTTPS = require('ssl.https')
local redis = (loadfile "./otouto/redis.lua")()
local utilities = require('otouto.utilities')
local mimetype = (loadfile "./otouto/mimetype.lua")()
media.triggers = {
"(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(gif))$",
"^(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(mp4))$",

View File

@ -1,11 +1,5 @@
local mc_server = {}
local http = require('socket.http')
local ltn12 = require('ltn12')
local URL = require('socket.url')
local json = require('dkjson')
local utilities = require('otouto.utilities')
function mc_server:init(config)
mc_server.triggers = {
"^/mine (.*)$"

View File

@ -1,7 +1,5 @@
local mc_skin = {}
local utilities = require('otouto.utilities')
function mc_skin:init(config)
mc_skin.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('skin', true).table
mc_skin.doc = [[*

View File

@ -1,10 +1,6 @@
local mal = {}
local http = require('socket.http')
local URL = require('socket.url')
local xml = require("xml")
local utilities = require('otouto.utilities')
local bindings = require('otouto.bindings')
mal.command = 'anime <Anime>, /manga <Manga>'

View File

@ -3,9 +3,6 @@
local notify = {}
local redis = (loadfile "./otouto/redis.lua")()
local utilities = require('otouto.utilities')
function notify:init(config)
notify.triggers = {
"^/notify (del)$",

View File

@ -1,9 +1,5 @@
local pagespeed_insights = {}
local https = require('ssl.https')
local json = require('dkjson')
local utilities = require('otouto.utilities')
function pagespeed_insights:init(config)
if not cred_data.google_apikey then
print('Missing config value: google_apikey.')

View File

@ -1,8 +1,5 @@
local pasteee = {}
local bot = require('otouto.bot')
local utilities = require('otouto.utilities')
function pasteee:init(config)
if not cred_data.pasteee_key then
print('Missing config value: pasteee_key.')

View File

@ -1,7 +1,5 @@
local patterns = {}
local utilities = require('otouto.utilities')
patterns.triggers = {
'^/?s/.-/.-$'
}

View File

@ -1,10 +1,5 @@
local pixabay = {}
local https = require('ssl.https')
local json = require('dkjson')
local utilities = require('otouto.utilities')
local redis = (loadfile "./otouto/redis.lua")()
function pixabay:init(config)
if not cred_data.pixabay_apikey then
print('Missing config value: pixabay_apikey.')

View File

@ -1,9 +1,5 @@
local play_store = {}
local https = require('ssl.https')
local json = require('dkjson')
local utilities = require('otouto.utilities')
function play_store:init(config)
if not cred_data.x_mashape_key then
print('Missing config value: x_mashape_key.')

View File

@ -1,9 +1,6 @@
local plugin_manager = {}
local bot = require('otouto.bot')
local bindings = require('otouto.bindings')
local utilities = require('otouto.utilities')
local redis = (loadfile "./otouto/redis.lua")()
function plugin_manager:init(config)
plugin_manager.triggers = {

View File

@ -1,11 +1,5 @@
local pocket = {}
local https = require('ssl.https')
local URL = require('socket.url')
local redis = (loadfile "./otouto/redis.lua")()
local utilities = require('otouto.utilities')
local bindings = require('otouto.bindings')
function pocket:init(config)
if not cred_data.pocket_consumer_key then
print('Missing config value: pocket_consumer_key.')

View File

@ -1,10 +1,5 @@
local pokedex = {}
local HTTP = require('socket.http')
local JSON = require('dkjson')
local bindings = require('otouto.bindings')
local utilities = require('otouto.utilities')
pokedex.command = 'pokedex <query>'
function pokedex:init(config)
@ -33,22 +28,22 @@ function pokedex:action(msg, config)
local url = 'http://pokeapi.co'
local dex_url = url .. '/api/v1/pokemon/' .. input
local dex_jstr, res = HTTP.request(dex_url)
local dex_jstr, res = http.request(dex_url)
if res ~= 200 then
utilities.send_reply(self, msg, config.errors.connection)
return
end
local dex_jdat = JSON.decode(dex_jstr)
local dex_jdat = json.decode(dex_jstr)
local desc_url = url .. dex_jdat.descriptions[math.random(#dex_jdat.descriptions)].resource_uri
local desc_jstr, _ = HTTP.request(desc_url)
local desc_jstr, _ = http.request(desc_url)
if res ~= 200 then
utilities.send_reply(self, msg, config.errors.connection)
return
end
local desc_jdat = JSON.decode(desc_jstr)
local desc_jdat = json.decode(desc_jstr)
local poke_type
for _,v in ipairs(dex_jdat.types) do

View File

@ -1,8 +1,5 @@
local preview = {}
local HTTP = require('socket.http')
local utilities = require('otouto.utilities')
preview.command = 'preview <link>'
function preview:init(config)
@ -27,7 +24,7 @@ function preview:action(msg)
input = 'http://' .. input
end
local res = HTTP.request(input)
local res = http.request(input)
if not res then
utilities.send_reply(self, msg, 'Please provide a valid link.')
return

View File

@ -1,9 +1,5 @@
local qr = {}
local http = require('socket.http')
local URL = require('socket.url')
local utilities = require('otouto.utilities')
function qr:init(config)
qr.triggers = {
'^/qr "(%w+)" "(%w+)" (.+)$',

View File

@ -1,8 +1,5 @@
local quotes = {}
local bot = require('otouto.bot')
local utilities = require('otouto.utilities')
local redis = (loadfile "./otouto/redis.lua")()
require("./otouto/plugins/pasteee")
function quotes:init(config)

View File

@ -1,7 +1,5 @@
local fun = {}
local utilities = require('otouto.utilities')
function fun:init(config)
fun.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('random', true).table
fun.doc = [[*

View File

@ -1,10 +1,5 @@
local reddit = {}
local https = require('ssl.https')
local URL = require('socket.url')
local JSON = require('dkjson')
local utilities = require('otouto.utilities')
reddit.command = 'reddit [r/subreddit | Suchbegriff]'
function reddit:init(config)
@ -68,7 +63,7 @@ function reddit:action(msg, config)
if res ~= 200 then
utilities.send_reply(self, msg, config.errors.results)
else
local jdat = JSON.decode(jstr)
local jdat = json.decode(jstr)
if #jdat.data.children == 0 then
utilities.send_reply(self, msg, config.errors.results)
else

View File

@ -1,10 +1,5 @@
local reddit_post = {}
local https = require('ssl.https')
local URL = require('socket.url')
local json = require('dkjson')
local utilities = require('otouto.utilities')
reddit_post.triggers = {
"reddit.com/r/([A-Za-z0-9-/-_-.]+)/comments/([A-Za-z0-9-/-_-.]+)"
}

View File

@ -1,7 +1,5 @@
local remind = {}
local utilities = require('otouto.utilities')
remind.command = 'remind <Länge> <Nachricht>'
function remind:init(config)

View File

@ -1,9 +1,5 @@
local respond = {}
local https = require('ssl.https')
local utilities = require('otouto.utilities')
local bindings = require('otouto.bindings')
function respond:init(config)
respond.triggers = {
"([Ff][Gg][Tt].? [Ss][Ww][Ii][Ff][Tt])",

View File

@ -1,7 +1,5 @@
local roll = {}
local utilities = require('otouto.utilities')
roll.command = 'roll'
function roll:init(config)

View File

@ -1,11 +1,5 @@
local rss = {}
local http = require('socket.http')
local https = require('ssl.https')
local url = require('socket.url')
local bindings = require('otouto.bindings')
local utilities = require('otouto.utilities')
local redis = (loadfile "./otouto/redis.lua")()
local feedparser = require("feedparser")
rss.command = 'rss <sub/del>'

View File

@ -1,8 +1,5 @@
local set = {}
local utilities = require('otouto.utilities')
local redis = (loadfile "./otouto/redis.lua")()
set.command = 'set <Variable> <Wert>'
function set:init(config)

View File

@ -1,7 +1,5 @@
local shell = {}
local utilities = require('otouto.utilities')
function shell:init(config)
shell.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('sh', true).table
end

View File

@ -1,7 +1,5 @@
local site_header = {}
local utilities = require('otouto.utilities')
function site_header:init(config)
site_header.triggers = {
"^/(head) ([%w-_%.%?%.:,/%+=&#!]+)$",

View File

@ -1,9 +1,5 @@
local soundcloud = {}
local http = require('socket.http')
local json = require('dkjson')
local utilities = require('otouto.utilities')
soundcloud.triggers = {
"soundcloud.com/([A-Za-z0-9-/-_-.]+)"
}

View File

@ -1,7 +1,5 @@
local speedtest = {}
local utilities = require('otouto.utilities')
speedtest.triggers = {
"speedtest.net/my%-result/(%d+)",
"speedtest.net/my%-result/i/(%d+)"

View File

@ -1,9 +1,5 @@
local spotify = {}
local https = require('ssl.https')
local json = require('dkjson')
local utilities = require('otouto.utilities')
spotify.triggers = {
"open.spotify.com/track/([A-Za-z0-9-]+)",
"play.spotify.com/track/([A-Za-z0-9-]+)"

View File

@ -1,8 +1,5 @@
local stats = {}
local utilities = require('otouto.utilities')
local redis = (loadfile "./otouto/redis.lua")()
function stats:init(config)
stats.triggers = {
"^/([Ss]tats)$",

View File

@ -1,10 +1,5 @@
local steam = {}
local utilities = require('otouto.utilities')
local http = require('socket.http')
local json = require('dkjson')
local bindings = require('otouto.bindings')
steam.triggers = {
"store.steampowered.com/app/([0-9]+)",
"steamcommunity.com/app/([0-9]+)"

View File

@ -1,9 +1,5 @@
local streamable = {}
local https = require('ssl.https')
local json = require('dkjson')
local utilities = require('otouto.utilities')
streamable.triggers = {
"streamable.com/([A-Za-z0-9-_-]+)",
}

View File

@ -1,7 +1,5 @@
local surrogate = {}
local utilities = require('otouto.utilities')
surrogate.triggers = {
"^/s (%-%d+) +(.+)$",
"^/s (%d+) +(.+)$"

View File

@ -1,11 +1,5 @@
local tagesschau = {}
local https = require('ssl.https')
local URL = require('socket.url')
local json = require('dkjson')
local utilities = require('otouto.utilities')
local bindings = require('otouto.bindings')
tagesschau.triggers = {
"tagesschau.de/([A-Za-z0-9-_-_-/]+).html"
}

View File

@ -1,12 +1,5 @@
local tagesschau_eil = {}
local http = require('socket.http')
local https = require('ssl.https')
local url = require('socket.url')
local json = require('dkjson')
local utilities = require('otouto.utilities')
local redis = (loadfile "./otouto/redis.lua")()
tagesschau_eil.command = 'eil <sub/del>'
function tagesschau_eil:init(config)

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