` zum Setzen von Variablen]]
-end
-
-function get:get_value(msg, var_name)
- local hash = get_redis_hash(msg, 'variables')
- if hash then
- local value = redis:hget(hash, var_name)
- if not value then
- return'Nicht gefunden; benutze /get, um alle Variablen aufzulisten.'
- else
- return var_name..' = '..value
- end
- end
-end
-
-function get:list_variables(msg)
- local hash = get_redis_hash(msg, 'variables')
- print(hash)
-
- if hash then
- print('Getting variable from redis hash '..hash)
- local names = redis:hkeys(hash)
- local text = ''
- for i=1, #names do
- variables = get: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
-
-function get:action(msg)
- local input = utilities.input(msg.text)
- if input then
- output = get:get_value(msg, input:match('(.+)'))
- else
- output = get:list_variables(msg)
- end
-
- utilities.send_message(msg.chat.id, output, true, nil, true)
-end
-
-return get
diff --git a/otouto/plugins/hackernews.lua b/otouto/plugins/hackernews.lua
deleted file mode 100644
index 87fc695..0000000
--- a/otouto/plugins/hackernews.lua
+++ /dev/null
@@ -1,40 +0,0 @@
-local hackernews = {}
-
-hackernews.triggers = {
- "news.ycombinator.com/item%?id=(%d+)"
-}
-
-local BASE_URL = 'https://hacker-news.firebaseio.com/v0'
-
-function hackernews:send_hackernews_post (hn_code)
- local url = BASE_URL..'/item/'..hn_code..'.json'
- local res,code = https.request(url)
- if code ~= 200 then return "HTTP-FEHLER" end
- local data = json.decode(res)
-
- local by = data.by
- local title = data.title
-
- if data.url then
- url = '\n[Link besuchen]('..data.url..')'
- else
- url = ''
- end
-
- if data.text then
- post = '\n'..unescape_html(data.text)
- post = string.gsub(post, '', ' ')
- else
- post = ''
- end
- local text = '*'..title..'* von _'..by..'_'..post..url
-
- return text
-end
-
-function hackernews:action(msg, config, matches)
- local hn_code = matches[1]
- utilities.send_reply(msg, hackernews:send_hackernews_post(hn_code), true)
-end
-
-return hackernews
diff --git a/otouto/plugins/hello.lua b/otouto/plugins/hello.lua
deleted file mode 100644
index 041a986..0000000
--- a/otouto/plugins/hello.lua
+++ /dev/null
@@ -1,11 +0,0 @@
-local hello = {}
-
-hello.triggers = {
- "^[Ss][Aa][Gg] [Hh][Aa][Ll][Ll][Oo] [Zz][Uu] (.*)$"
-}
-
-function hello:action(msg, config, matches)
- utilities.send_message(msg.chat.id, 'Hallo, '..matches[1]..'!')
-end
-
-return hello
diff --git a/otouto/plugins/imgur.lua b/otouto/plugins/imgur.lua
deleted file mode 100644
index 1ec1c08..0000000
--- a/otouto/plugins/imgur.lua
+++ /dev/null
@@ -1,56 +0,0 @@
-local imgur = {}
-
-function imgur:init(config)
- if not cred_data.imgur_client_id then
- print('Missing config value: imgur_client_id.')
- print('imgur.lua will not be enabled.')
- return
- end
-
- imgur.triggers = {
- "imgur.com/([A-Za-z0-9]+).gifv",
- "https?://imgur.com/([A-Za-z0-9]+)"
- }
-end
-
-local client_id = cred_data.imgur_client_id
-local BASE_URL = 'https://api.imgur.com/3'
-
-function imgur:get_imgur_data(imgur_code)
- local response_body = {}
- local request_constructor = {
- url = BASE_URL..'/image/'..imgur_code,
- method = "GET",
- sink = ltn12.sink.table(response_body),
- headers = {
- Authorization = 'Client-ID '..client_id
- }
- }
- local ok, response_code, response_headers, response_status_line = https.request(request_constructor)
- if not ok then
- return nil
- end
-
- local response_body = json.decode(table.concat(response_body))
-
- if response_body.status ~= 200 then return nil end
-
- return response_body.data.link
-end
-
-function imgur:action(msg)
- local imgur_code = matches[1]
- if imgur_code == "login" then return nil end
- utilities.send_typing(msg.chat.id, 'upload_photo')
- local link = imgur:get_imgur_data(imgur_code)
- if link then
- local file = download_to_file(link)
- if string.ends(link, ".gif") then
- utilities.send_document(msg.chat.id, file, nil, msg.message_id)
- else
- utilities.send_photo(msg.chat.id, file, nil, msg.message_id)
- end
- end
-end
-
-return imgur
diff --git a/otouto/plugins/instagram.lua b/otouto/plugins/instagram.lua
deleted file mode 100644
index 021ed04..0000000
--- a/otouto/plugins/instagram.lua
+++ /dev/null
@@ -1,75 +0,0 @@
-local instagram = {}
-
-function instagram:init(config)
- if not cred_data.instagram_access_token then
- print('Missing config value: instagram_access_token.')
- print('instagram.lua will not be enabled.')
- return
- end
-
- instagram.triggers = {
- "instagram.com/p/([A-Za-z0-9-_-]+)"
- }
-end
-
-local BASE_URL = 'https://api.instagram.com/v1'
-local access_token = cred_data.instagram_access_token
-
-function instagram: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 nil end
- local data = json.decode(res).data
- return data
-end
-
-function instagram:send_instagram_data(data)
- -- 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
-
- return header..caption..footer, image_url
-end
-
-function instagram:action(msg, config, matches)
- local insta_code = matches[1]
- local data = instagram:get_insta_data(insta_code)
- if not data then utilities.send_reply(msg, config.errors.connection) return end
-
- local text, image_url = instagram:send_instagram_data(data)
- if not image_url then utilities.send_reply(msg, config.errors.connection) return end
-
- utilities.send_typing(msg.chat.id, 'upload_photo')
- local file = download_to_file(image_url)
- utilities.send_photo(msg.chat.id, file, text, msg.message_id)
-end
-
-return instagram
diff --git a/otouto/plugins/isup.lua b/otouto/plugins/isup.lua
deleted file mode 100644
index 3bd5d6c..0000000
--- a/otouto/plugins/isup.lua
+++ /dev/null
@@ -1,79 +0,0 @@
-local isup = {}
-
-function isup:init(config)
- isup.triggers = {
- "^/isup (.*)$",
- "^/ping (.*)$"
- }
-
- isup.doc = [[*
-]]..config.cmd_pat..[[isup* __: Prüft, ob die URL up ist]]
-end
-
-function isup:is_up_socket(ip, port)
- print('Connect to', ip, port)
- local c = socket.try(socket.tcp())
- c:settimeout(3)
- local conn = c:connect(ip, port)
- if not conn then
- return false
- else
- c:close()
- return true
- end
-end
-
-function isup:is_up_http(url)
- -- Parse URL from input, default to http
- local parsed_url = URL.parse(url, { scheme = 'http', authority = '' })
- -- Fix URLs without subdomain not parsed properly
- if not parsed_url.host and parsed_url.path then
- parsed_url.host = parsed_url.path
- parsed_url.path = ""
- end
- -- Re-build URL
- local url = URL.build(parsed_url)
-
- local protocols = {
- ["https"] = https,
- ["http"] = http
- }
- local options = {
- url = url,
- redirect = false,
- method = "GET"
- }
- local response = { protocols[parsed_url.scheme].request(options) }
- local code = tonumber(response[2])
- if code == nil or code >= 400 then
- return false
- end
- return true
-end
-
-function isup:isup(url)
- local pattern = '^(%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?):?(%d?%d?%d?%d?%d?)$'
- local ip,port = string.match(url, pattern)
- local result = nil
-
- -- /isup 8.8.8.8:53
- if ip then
- port = port or '80'
- result = isup:is_up_socket(ip, port)
- else
- result = isup:is_up_http(url)
- end
- return result
-end
-
-function isup:action(msg, config)
- if isup:isup(matches[1]) then
- utilities.send_reply(msg, matches[1]..' ist UP! ✅')
- return
- else
- utilities.send_reply(msg, matches[1]..' ist DOWN! ❌')
- return
- end
-end
-
-return isup
diff --git a/otouto/plugins/lyrics.lua b/otouto/plugins/lyrics.lua
deleted file mode 100644
index b69e7ee..0000000
--- a/otouto/plugins/lyrics.lua
+++ /dev/null
@@ -1,47 +0,0 @@
-local lyrics = {}
-
-function lyrics:init(config)
- if not cred_data.lyricsnmusic_apikey then
- print('Missing config value: lyricsnmusic_apikey.')
- print('lyrics.lua will not be enabled.')
- return
- end
-
- lyrics.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('lyrics', true).table
- lyrics.doc = [[*
-]]..config.cmd_pat..[[lyrics* __: Postet Liedertext]]
-end
-
-lyrics.command = 'lyrics '
-
-function lyrics:getLyrics(text)
- local apikey = cred_data.lyricsnmusic_apikey
- local q = URL.encode(text)
- local b = http.request("http://api.lyricsnmusic.com/songs?api_key="..apikey.."&q=" .. q)
- response = json.decode(b)
- local reply = ""
- if #response > 0 then
- -- grab first match
- local result = response[1]
- reply = result.title .. " - " .. result.artist.name .. "\n" .. result.snippet .. "\n[Ganzen Liedertext ansehen](" .. result.url .. ")"
- else
- reply = nil
- end
- return reply
-end
-
-function lyrics:action(msg, config, matches)
- local input = utilities.input(msg.text)
- if not input then
- if msg.reply_to_message and msg.reply_to_message.text then
- input = msg.reply_to_message.text
- else
- utilities.send_message(msg.chat.id, lyrics.doc, true, msg.message_id, true)
- return
- end
- end
-
- utilities.send_reply(msg, lyrics:getLyrics(input), true)
-end
-
-return lyrics
diff --git a/otouto/plugins/myanimelist.lua b/otouto/plugins/myanimelist.lua
deleted file mode 100644
index b4970ab..0000000
--- a/otouto/plugins/myanimelist.lua
+++ /dev/null
@@ -1,222 +0,0 @@
-local mal = {}
-
-local xml = require("xml")
-
-mal.command = 'anime , /manga '
-
-function mal:init(config)
- if not cred_data.mal_user then
- print('Missing config value: mal_user.')
- print('myanimelist.lua will not be enabled.')
- return
- elseif not cred_data.mal_pw then
- print('Missing config value: mal_pw.')
- print('myanimelist.lua will not be enabled.')
- return
- end
-
- mal.triggers = {
- "^/(anime) (.+)$",
- "^/(manga) (.+)$"
- }
- mal.doc = [[*
-]]..config.cmd_pat..[[anime*_ _: Sendet Infos zum Anime
-*]]..config.cmd_pat..[[manga*_ _: Sendet Infos zum Manga
-]]
-end
-
-local user = cred_data.mal_user
-local password = cred_data.mal_pw
-
-local BASE_URL = 'https://'..user..':'..password..'@myanimelist.net/api'
-
-function mal:delete_tags(str)
- str = string.gsub( str, '
', '')
- str = string.gsub( str, '%[i%]', '')
- str = string.gsub( str, '%[/i%]', '')
- str = string.gsub( str, '—', ' — ')
- return str
-end
-
-local makeOurDate = function(dateString)
- local pattern = "(%d+)%-(%d+)%-(%d+)"
- local year, month, day = dateString:match(pattern)
- return day..'.'..month..'.'..year
-end
-
-function mal:get_mal_info(query, typ)
- if typ == 'anime' then
- url = BASE_URL..'/anime/search.xml?q='..query
- elseif typ == 'manga' then
- url = BASE_URL..'/manga/search.xml?q='..query
- end
- local res,code = https.request(url)
- if code ~= 200 then return "HTTP-Fehler" end
- local result = xml.load(res)
- return result
-end
-
-function mal:send_anime_data(result, receiver)
- local title = xml.find(result, 'title')[1]
- local id = xml.find(result, 'id')[1]
- local mal_url = 'https://myanimelist.net/anime/'..id
-
- if xml.find(result, 'synonyms')[1] then
- alt_name = '\noder: '..unescape(mal:delete_tags(xml.find(result, 'synonyms')[1]))
- else
- alt_name = ''
- end
-
- if xml.find(result, 'synopsis')[1] then
- desc = '\n'..unescape(mal:delete_tags(string.sub(xml.find(result, 'synopsis')[1], 1, 200))) .. '...'
- else
- desc = ''
- end
-
- 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 = '\nVeröffentlichungszeitraum: '..makeOurDate(xml.find(result, 'start_date')[1])
- else
- startdate = ''
- end
-
- if xml.find(result, 'end_date')[1] ~= "0000-00-00" then
- enddate = ' - '..makeOurDate(xml.find(result, 'end_date')[1])
- else
- enddate = ''
- end
-
- local text = '*'..title..'*'..alt_name..typ..episodes..status..score..startdate..enddate..'_'..desc..'_\n[Auf MyAnimeList ansehen]('..mal_url..')'
- if xml.find(result, 'image') then
- local image_url = xml.find(result, 'image')[1]
- return text, image_url
- else
- return text
- end
-end
-
-function mal:send_manga_data(result)
- local title = xml.find(result, 'title')[1]
- local id = xml.find(result, 'id')[1]
- local mal_url = 'https://myanimelist.net/manga/'..id
-
- if xml.find(result, 'type')[1] then
- typ = ' ('..xml.find(result, 'type')[1]..')'
- else
- typ = ''
- end
-
- if xml.find(result, 'synonyms')[1] then
- alt_name = '\noder: '..unescape(mal:delete_tags(xml.find(result, 'synonyms')[1]))
- else
- alt_name = ''
- end
-
- if xml.find(result, 'chapters')[1] then
- chapters = '\nKapitel: '..xml.find(result, 'chapters')[1]
- else
- chapters = ''
- end
-
- if xml.find(result, 'status')[1] then
- status = ' ('..xml.find(result, 'status')[1]..')'
- else
- status = ''
- end
-
- if xml.find(result, 'volumes')[1] then
- volumes = '\nBände '..xml.find(result, 'volumes')[1]
- else
- volumes = ''
- end
-
- if xml.find(result, 'score')[1] ~= "0.00" then
- score = '\nScore: '..xml.find(result, 'score')[1]
- else
- score = ''
- end
-
- if xml.find(result, 'start_date')[1] ~= "0000-00-00" then
- startdate = '\nVeröffentlichungszeitraum: '..makeOurDate(xml.find(result, 'start_date')[1])
- else
- startdate = ''
- end
-
- if xml.find(result, 'end_date')[1] ~= "0000-00-00" then
- enddate = ' - '..makeOurDate(xml.find(result, 'end_date')[1])
- else
- enddate = ''
- end
-
- if xml.find(result, 'synopsis')[1] then
- desc = '\n'..unescape(mal:delete_tags(string.sub(xml.find(result, 'synopsis')[1], 1, 200))) .. '...'
- else
- desc = ''
- end
-
- local text = '*'..title..'*'..alt_name..typ..chapters..status..volumes..score..startdate..enddate..'_'..desc..'_\n[Auf MyAnimeList ansehen]('..mal_url..')'
- if xml.find(result, 'image') then
- local image_url = xml.find(result, 'image')[1]
- return text, image_url
- else
- return text
- end
-end
-
-function mal:action(msg, config, matches)
- local query = URL.escape(matches[2])
- if matches[1] == 'anime' then
- local anime_info = mal:get_mal_info(query, 'anime')
- if anime_info == "HTTP-Fehler" then
- utilities.send_reply(msg, 'Anime nicht gefunden!')
- return
- else
- local text, image_url = mal:send_anime_data(anime_info)
- if image_url then
- utilities.send_typing(msg.chat.id, 'upload_photo')
- utilities.send_photo(msg.chat.id, image_url, nil, msg.message_id)
- end
- utilities.send_reply(msg, text, true)
- return
- end
- elseif matches[1] == 'manga' then
- local manga_info = mal:get_mal_info(query, 'manga')
- if manga_info == "HTTP-Fehler" then
- utilities.send_reply(msg, 'Manga nicht gefunden!')
- return
- else
- local text, image_url = mal:send_manga_data(manga_info)
- if image_url then
- utilities.send_typing(msg.chat.id, 'upload_photo')
- utilities.send_photo(msg.chat.id, image_url, nil, msg.message_id)
- end
- utilities.send_reply(msg, text, true)
- return
- end
- end
-end
-
-return mal
diff --git a/otouto/plugins/pagespeed_insights.lua b/otouto/plugins/pagespeed_insights.lua
deleted file mode 100644
index 6f8358e..0000000
--- a/otouto/plugins/pagespeed_insights.lua
+++ /dev/null
@@ -1,35 +0,0 @@
-local pagespeed_insights = {}
-
-function pagespeed_insights:init(config)
- if not cred_data.google_apikey then
- print('Missing config value: google_apikey.')
- print('pagespeed_insights.lua will not be enabled.')
- return
- end
-
- pagespeed_insights.triggers = {
- "^/speed (https?://[%w-_%.%?%.:/%+=&]+)"
- }
- pagespeed_insights.doc = [[*
-]]..config.cmd_pat..[[speed* __: Testet Geschwindigkeit der Seite mit PageSpeed Insights]]
-end
-
-local BASE_URL = 'https://www.googleapis.com/pagespeedonline/v2'
-
-function pagespeed_insights: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 pagespeed_insights:action(msg, config, matches)
- utilities.send_typing(msg.chat.id, 'typing')
- local text = pagespeed_insights:get_pagespeed(matches[1])
- if not text then utilities.send_reply(msg, config.errors.connection) return end
- utilities.send_reply(msg, text, true)
-end
-
-return pagespeed_insights
diff --git a/otouto/plugins/play_store.lua b/otouto/plugins/play_store.lua
deleted file mode 100644
index e290c55..0000000
--- a/otouto/plugins/play_store.lua
+++ /dev/null
@@ -1,58 +0,0 @@
-local play_store = {}
-
-function play_store:init(config)
- if not cred_data.x_mashape_key then
- print('Missing config value: x_mashape_key.')
- print('play_store.lua will not be enabled.')
- return
- end
-
- play_store.triggers = {
- "play.google.com/store/apps/details%?id=(.*)"
- }
-end
-
-local BASE_URL = 'https://apps.p.mashape.com/google/application'
-
-function play_store: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 nil end
- local data = json.decode(res).data
- return data
-end
-
-function play_store:send_playstore_data(data)
- 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
- return text
-end
-
-function play_store:action(msg, config, matches)
- local appid = matches[1]
- local data = play_store:get_playstore_data(appid)
- if data == nil then
- return
- else
- utilities.send_reply(msg, play_store:send_playstore_data(data), true)
- return
- end
-end
-
-return play_store
diff --git a/otouto/plugins/pocket.lua b/otouto/plugins/pocket.lua
deleted file mode 100644
index 6d07a16..0000000
--- a/otouto/plugins/pocket.lua
+++ /dev/null
@@ -1,144 +0,0 @@
-local pocket = {}
-
-function pocket:init(config)
- if not cred_data.pocket_consumer_key then
- print('Missing config value: pocket_consumer_key.')
- print('pocket.lua will not be enabled.')
- return
- end
-
- pocket.triggers = {
- "^/pocket(set)(.+)$",
- "^/pocket (add) (https?://.*)$",
- "^/pocket (archive) (%d+)$",
- "^/pocket (readd) (%d+)$",
- "^/pocket (unfavorite) (%d+)$",
- "^/pocket (favorite) (%d+)$",
- "^/pocket (delete) (%d+)$",
- "^/pocket (unauth)$",
- "^/pocket$"
- }
-
- pocket.doc = [[*
-]]..config.cmd_pat..[[pocket*: Postet Liste deiner Links
-*]]..config.cmd_pat..[[pocket* add _(url)_: Fügt diese URL deiner Liste hinzu
-*]]..config.cmd_pat..[[pocket* archive _[id]_: Archiviere diesen Eintrag
-*]]..config.cmd_pat..[[pocket* readd _[id]_: De-archiviere diesen Eintrag
-*]]..config.cmd_pat..[[pocket* favorite _[id]_: Favorisiere diesen Eintrag
-*]]..config.cmd_pat..[[pocket* unfavorite _[id]_: Entfavorisiere diesen Eintrag
-*]]..config.cmd_pat..[[pocket* delete _[id]_: Lösche diesen Eintrag
-*]]..config.cmd_pat..[[pocket* unauth: Löscht deinen Account aus dem Bot]]
-end
-
-pocket.command = 'pocket '
-
-local BASE_URL = 'https://getpocket.com/v3'
-local consumer_key = cred_data.pocket_consumer_key
-local headers = {
- ["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF8",
- ["X-Accept"] = "application/json"
-}
-
-function pocket:set_pocket_access_token(hash, access_token)
- if string.len(access_token) ~= 30 then return '*Inkorrekter Access-Token*' end
- print('Setting pocket in redis hash '..hash..' to users access_token')
- redis:hset(hash, 'pocket', access_token)
- return '*Authentifizierung abgeschlossen!*\nDas Plugin kann jetzt verwendet werden.'
-end
-
-function pocket:list_pocket_items(access_token)
- local items = post_petition(BASE_URL..'/get', 'consumer_key='..consumer_key..'&access_token='..access_token..'&state=unread&sort=newest&detailType=simple', headers)
-
- if items.status == 2 then return 'Keine Elemente eingespeichert.' end
- if items.status ~= 1 then return 'Ein Fehler beim Holen der Elemente ist aufgetreten.' end
-
- local text = ''
- for element in pairs(items.list) do
- title = items.list[element].given_title
- if not title or title == "" then title = items.list[element].resolved_title end
- text = text..'#'..items.list[element].item_id..': '..title..'\n— '..items.list[element].resolved_url..'\n\n'
- end
-
- return text
-end
-
-function pocket:add_pocket_item(access_token, url)
- local result = post_petition(BASE_URL..'/add', 'consumer_key='..consumer_key..'&access_token='..access_token..'&url='..url, headers)
- if result.status ~= 1 then return 'Ein Fehler beim Hinzufügen der URL ist aufgetreten :(' end
- local given_url = result.item.given_url
- if result.item.title == "" or not result.item.title then
- title = 'Seite'
- else
- title = '"'..result.item.title..'"'
- end
- local code = result.item.response_code
-
- local text = title..' ('..given_url..') hinzugefügt!'
- if not code then return text end
- if code ~= "200" and code ~= "0" then text = text..'\nAber die Seite liefert Fehler '..code..' zurück.' end
- return text
-end
-
-function pocket:modify_pocket_item(access_token, action, id)
- local result = post_petition(BASE_URL..'/send', 'consumer_key='..consumer_key..'&access_token='..access_token..'&actions=[{"action":"'..action..'","item_id":'..id..'}]', headers)
- if result.status ~= 1 then return 'Ein Fehler ist aufgetreten :(' end
-
- if action == 'readd' then
- if result.action_results[1] == false then
- return 'Dieser Eintrag existiert nicht!'
- end
- local url = result.action_results[1].normal_url
- return url..' wieder de-archiviert'
- end
- if result.action_results[1] == true then
- return 'Aktion ausgeführt.'
- else
- return 'Ein Fehler ist aufgetreten.'
- end
-end
-
-function pocket:action(msg, config, matches)
- local hash = 'user:'..msg.from.id
- local access_token = redis:hget(hash, 'pocket')
-
- if matches[1] == 'set' then
- local access_token = matches[2]
- utilities.send_reply(msg, pocket:set_pocket_access_token(hash, access_token), true)
- local message_id = redis:hget(hash, 'pocket_login_msg')
- utilities.edit_message(msg.chat.id, message_id, '*Anmeldung abgeschlossen!*', true, true)
- redis:hdel(hash, 'pocket_login_msg')
- return
- end
-
- if not access_token then
- local result = utilities.send_reply(msg, '*Bitte authentifiziere dich zuerst, indem du dich anmeldest.*', true, '{"inline_keyboard":[[{"text":"Bei Pocket anmelden","url":"https://brawlbot.tk/apis/callback/pocket/connect.php"}]]}')
- redis:hset(hash, 'pocket_login_msg', result.result.message_id)
- return
- end
-
- if matches[1] == 'unauth' then
- redis:hdel(hash, 'pocket')
- utilities.send_reply(msg, 'Erfolgreich ausgeloggt! Du kannst den Zugriff [in deinen Einstellungen](https://getpocket.com/connected_applications) endgültig entziehen.', true)
- return
- end
-
- if matches[1] == 'add' then
- utilities.send_reply(msg, pocket:add_pocket_item(access_token, matches[2]))
- return
- end
-
- if matches[1] == 'archive' or matches[1] == 'delete' or matches[1] == 'readd' or matches[1] == 'favorite' or matches[1] == 'unfavorite' then
- utilities.send_reply(msg, pocket:modify_pocket_item(access_token, matches[1], matches[2]))
- return
- end
-
- if msg.chat.type == 'chat' or msg.chat.type == 'supergroup' then
- utilities.send_reply(msg, 'Ausgeben deiner privaten Pocket-Liste in einem öffentlichen Chat wird feige verweigert. Bitte schreibe mich privat an!', true)
- return
- else
- utilities.send_reply(msg, pocket:list_pocket_items(access_token))
- return
- end
-end
-
-return pocket
\ No newline at end of file
diff --git a/otouto/plugins/reddit.lua b/otouto/plugins/reddit.lua
deleted file mode 100644
index 04706e8..0000000
--- a/otouto/plugins/reddit.lua
+++ /dev/null
@@ -1,77 +0,0 @@
-local reddit = {}
-
-reddit.command = 'reddit [r/subreddit | Suchbegriff]'
-
-function reddit:init(config)
- reddit.triggers = utilities.triggers(self.info.username, config.cmd_pat, {'^/r/'}):t('reddit', true):t('r', true):t('r/', true).table
- reddit.doc = [[*
-]]..config.cmd_pat..[[r* _[r/subreddit | Suchbegriff]_: Gibt Top-Posts oder Ergebnisse eines Subreddits aus. Wenn kein Argument gegeben ist, wird /r/all genommen.]]
-end
-
-local format_results = function(posts)
- local output = ''
- for _,v in ipairs(posts) do
- local post = v.data
- local title = post.title:gsub('%[', '('):gsub('%]', ')'):gsub('&', '&')
- if title:len() > 256 then
- title = title:sub(1, 253)
- title = utilities.trim(title) .. '...'
- end
- local short_url = 'https://redd.it/' .. post.id
- local s = '[' .. unescape(title) .. '](' .. short_url .. ')'
- if post.domain and not post.is_self and not post.over_18 then
- s = '`[`[' .. post.domain .. '](' .. post.url:gsub('%)', '\\)') .. ')`]` ' .. s
- end
- output = output .. '• ' .. s .. '\n'
- end
- return output
-end
-
-reddit.subreddit_url = 'https://www.reddit.com/%s/.json?limit='
-reddit.search_url = 'https://www.reddit.com/search.json?q=%s&limit='
-reddit.rall_url = 'https://www.reddit.com/.json?limit='
-
-function reddit:action(msg, config)
- -- Eight results in PM, four results elsewhere.
- local limit = 4
- if msg.chat.type == 'private' then
- limit = 8
- end
- local text = msg.text_lower
- if text:match('^/r/.') then
- -- Normalize input so this hack works easily.
- text = msg.text_lower:gsub('^/r/', config.cmd_pat..'r r/')
- end
- local input = utilities.input(text)
- local source, url
- if input then
- if input:match('^r/.') then
- input = utilities.get_word(input, 1)
- url = reddit.subreddit_url:format(input) .. limit
- source = '*/' .. utilities.md_escape(input) .. '*\n'
- else
- input = utilities.input(msg.text)
- source = '*Ergebnisse für* _' .. utilities.md_escape(input) .. '_ *:*\n'
- input = URL.escape(input)
- url = reddit.search_url:format(input) .. limit
- end
- else
- url = reddit.rall_url .. limit
- source = '*/r/all*\n'
- end
- local jstr, res = https.request(url)
- if res ~= 200 then
- utilities.send_reply(msg, config.errors.results)
- else
- local jdat = json.decode(jstr)
- if #jdat.data.children == 0 then
- utilities.send_reply(msg, config.errors.results)
- else
- local output = format_results(jdat.data.children)
- output = source .. output
- utilities.send_message(msg.chat.id, output, true, nil, true)
- end
- end
-end
-
-return reddit
diff --git a/otouto/plugins/set.lua b/otouto/plugins/set.lua
deleted file mode 100644
index ca1a441..0000000
--- a/otouto/plugins/set.lua
+++ /dev/null
@@ -1,52 +0,0 @@
-local set = {}
-
-set.command = 'set '
-
-function set:init(config)
- set.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('set', true).table
- set.doc = [[*
-]]..config.cmd_pat..[[set* __ __: Speichert eine Variable mit einem Wert
-*]]..config.cmd_pat..[[set* __ _nil_: Löscht Variable
-Nutze `/get ` zum Abrufen]]
-end
-
-function set:save_value(msg, name, 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
-
-function set:delete_value(msg, name)
- local hash = get_redis_hash(msg, 'variables')
- if redis:hexists(hash, name) == true then
- print('Deleting variable from redis hash '..hash)
- redis:hdel(hash, name)
- return 'Variable "'..name..'" erfolgreich gelöscht!'
- else
- return 'Du kannst keine Variable löschen, die nicht existiert .-.'
- end
-end
-
-function set:action(msg)
- local input = utilities.input(msg.text)
- if not input or not input:match('([^%s]+) (.+)') then
- utilities.send_message(msg.chat.id, set.doc, true, msg.message_id, true)
- return
- end
-
- local name = input:match('([^%s]+) ')
- local value = input:match(' (.+)')
-
- if value == "nil" then
- output = set:delete_value(msg, name)
- else
- output = set:save_value(msg, name, value)
- end
-
- utilities.send_message(msg.chat.id, output, true, nil, true)
-end
-
-return set
diff --git a/otouto/plugins/settings.lua b/otouto/plugins/settings.lua
deleted file mode 100644
index ff4c7bd..0000000
--- a/otouto/plugins/settings.lua
+++ /dev/null
@@ -1,56 +0,0 @@
-local settings = {}
-
-settings.triggers = {
- "^(⚙ [Ee]instellungen)$",
- "^(/settings)$",
- "^(💤 [Aa][Ff][Kk]%-[Kk]eyboard einschalten)",
- "^(💤 [Aa][Ff][Kk]%-[Kk]eyboard ausschalten)",
- "^(❌ [Ee]instellungen verstecken)"
-}
-
---[[
-
-[
- [ "Top Left", "Top Right" ],
- [ "Bottom Left", "Bottom Right" ]
-]
-
-]]
-
-function settings:keyboard(user_id)
- if redis:hget('user:'..user_id, 'afk_keyboard') == 'true' then
- afk_button = '{"text":"💤 AFK-Keyboard ausschalten"}'
- else
- afk_button = '{"text":"💤 AFK-Keyboard einschalten"}'
- end
- local hide_settings_button = '{"text":"❌ Einstellungen verstecken"}'
-
- local settings_keyboard = '[['..afk_button..','..hide_settings_button..']]'
- return settings_keyboard
-end
-
-function settings:action(msg, config, matches)
- if msg.chat.type ~= "private" then
- return
- end
-
- local hash = 'user:'..msg.from.id
-
- if matches[1] == '⚙ Einstellungen' or matches[1] == '/settings' then
- utilities.send_reply(msg, 'Was möchtest du einstellen?', false, '{"keyboard":'..settings:keyboard(msg.from.id)..', "one_time_keyboard":true, "selective":true, "resize_keyboard":true}')
- return
- elseif matches[1] == '💤 AFK-Keyboard einschalten' then
- redis:hset(hash, 'afk_keyboard', 'true')
- utilities.send_reply(msg, 'Das AFK-Keyboard wurde erfolgreich *eingeschaltet*.', true, '{"keyboard":'..settings:keyboard(msg.from.id)..', "one_time_keyboard":true, "selective":true, "resize_keyboard":true}')
- return
- elseif matches[1] == '💤 AFK-Keyboard ausschalten' then
- redis:hset(hash, 'afk_keyboard', 'false')
- utilities.send_reply(msg, 'Das AFK-Keyboard wurde erfolgreich *ausgeschaltet*.', true, '{"keyboard":'..settings:keyboard(msg.from.id)..', "one_time_keyboard":true, "selective":true, "resize_keyboard":true}')
- return
- elseif matches[1] == '❌ Einstellungen verstecken' then
- utilities.send_reply(msg, 'Um die Einstellungen wieder einzublenden, führe /settings aus.', true, '{"hide_keyboard":true}')
- return
- end
-end
-
-return settings
\ No newline at end of file
diff --git a/otouto/plugins/soundcloud.lua b/otouto/plugins/soundcloud.lua
deleted file mode 100644
index 8f0f6bf..0000000
--- a/otouto/plugins/soundcloud.lua
+++ /dev/null
@@ -1,37 +0,0 @@
-local soundcloud = {}
-
-soundcloud.triggers = {
- "soundcloud.com/([A-Za-z0-9-/-_-.]+)"
-}
-
-local BASE_URL = 'http://api.soundcloud.com/resolve.json'
-local client_id = cred_data.soundcloud_client_id
-
-function soundcloud:send_soundcloud_info(sc_url)
- 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 nil end
- local data = json.decode(res)
-
- 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
- local milliseconds = data.duration
- local totalseconds = math.floor(milliseconds / 1000)
- local duration = makeHumanTime(totalseconds)
-
- local text = '*'..title..'* von _'..user..'_\n_(Tag: '..genre..', '..duration..'; '..playback_count..' mal angehört)_\n'..description
- return text
-end
-
-function soundcloud:action(msg, config, matches)
- local text = soundcloud:send_soundcloud_info(matches[1])
- if not text then utilities.send_reply(msg, config.errors.connection) return end
- utilities.send_reply(msg, text, true)
-end
-
-return soundcloud
diff --git a/otouto/plugins/streamable.lua b/otouto/plugins/streamable.lua
deleted file mode 100644
index 96ea2e5..0000000
--- a/otouto/plugins/streamable.lua
+++ /dev/null
@@ -1,49 +0,0 @@
-local streamable = {}
-
-streamable.triggers = {
- "streamable.com/([A-Za-z0-9-_-]+)",
-}
-
-function streamable:send_streamable_video(shortcode, msg)
- local BASE_URL = "https://api.streamable.com"
- local url = BASE_URL..'/videos/'..shortcode
- local res,code = https.request(url)
- if code ~= 200 then return 'HTTP-Fehler' end
- local data = json.decode(res)
- if data.status ~= 2 then utilities.send_reply(msg, "Video ist (noch) nicht verfügbar.") return end
-
- if data.files.webm then
- if data.title == "" then title = shortcode..'.webm' else title = data.title..'.webm' end
- url = 'https:'..data.files.webm.url
- width = data.files.webm.width
- height = data.files.webm.height
- if data.files.webm.size > 50000000 then
- local size = math.floor(data.files.webm.size / 1000000)
- utilities.send_reply(msg, '*Video ist größer als 50 MB* ('..size..' MB)!\n[Direktlink]('..url..')', true)
- return
- end
- elseif data.files.mp4 then
- if data.title == "" then title = shortcode..'.mp4' else title = data.title..'.mp4' end
- url = 'https:'..data.files.mp4.url
- width = data.files.mp4.width
- height = data.files.mp4.height
- if data.files.mp4.size > 50000000 then
- local size = math.floor(data.files.mp4.size / 1000000)
- utilities.send_reply(msg, '*Video ist größer als 50 MB* ('..size..' MB)!\n[Direktlink]('..url..')', true)
- return
- end
- end
-
- utilities.send_typing(msg.chat.id, 'upload_video')
- local file = download_to_file(url, title)
- utilities.send_video(msg.chat.id, file, nil, msg.message_id, nil, width, height)
- return
-end
-
-function streamable:action(msg, config, matches)
- local shortcode = matches[1]
- streamable:send_streamable_video(shortcode, msg)
- return
-end
-
-return streamable
diff --git a/otouto/plugins/tex.lua b/otouto/plugins/tex.lua
deleted file mode 100644
index 4597cb1..0000000
--- a/otouto/plugins/tex.lua
+++ /dev/null
@@ -1,31 +0,0 @@
-local tex = {}
-
-tex.command = 'tex '
-
-function tex:init(config)
- tex.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('tex', true).table
- tex.doc = [[*
-]]..config.cmd_pat..[[tex* __: Konvertiert LaTeX in ein Bild]]
-end
-
-function tex:action(msg, config)
- local input = utilities.input(msg.text)
- if not input then
- if msg.reply_to_message and msg.reply_to_message.text then
- input = msg.reply_to_message.text
- else
- utilities.send_message(msg.chat.id, tex.doc, true, msg.message_id, true)
- return
- end
- end
-
- utilities.send_typing(msg.chat.id, 'upload_photo')
- local eq = URL.escape(input)
-
- local url = "http://latex.codecogs.com/png.download?"
- .."\\dpi{300}%20\\LARGE%20"..eq
- local file = download_to_file(url, 'latex.png')
- utilities.send_photo(msg.chat.id, file, nil, msg.message_id)
-end
-
-return tex
diff --git a/otouto/plugins/thetvdb.lua b/otouto/plugins/thetvdb.lua
deleted file mode 100644
index bbaef66..0000000
--- a/otouto/plugins/thetvdb.lua
+++ /dev/null
@@ -1,92 +0,0 @@
-local tv = {}
-
-local xml = require("xml")
-
-tv.command = 'tv '
-
-function tv:init(config)
- tv.triggers = {
- "^/tv (.+)$"
- }
- tv.doc = [[*
-]]..config.cmd_pat..[[tv*_ _: Sendet Infos zur TV-Serie]]
-end
-
-local BASE_URL = 'http://thetvdb.com/api'
-
-local makeOurDate = function(dateString)
- local pattern = "(%d+)%-(%d+)%-(%d+)"
- local year, month, day = dateString:match(pattern)
- return day..'.'..month..'.'..year
-end
-
-
-function tv:get_tv_info(series)
- local url = BASE_URL..'/GetSeries.php?seriesname='..series..'&language=de'
- local res,code = http.request(url)
- if code ~= 200 then return "HTTP-ERROR" end
- local result = xml.load(res)
- if not xml.find(result, 'seriesid') then return "NOTFOUND" end
- return result
-end
-
-function tv:send_tv_data(result, msg)
- local title = xml.find(result, 'SeriesName')[1]
- local id = xml.find(result, 'seriesid')[1]
-
- if xml.find(result, 'AliasNames') and xml.find(result, 'AliasNames')[1] ~= title then
- alias = '\noder: '..xml.find(result, 'AliasNames')[1]
- else
- alias = ''
- end
-
- if xml.find(result, 'Overview') then
- desc = '\n_'..string.sub(xml.find(result, 'Overview')[1], 1, 250) .. '..._'
- else
- desc = ''
- end
-
- if xml.find(result, 'FirstAired') then
- aired = '\n*Erstausstrahlung:* '..makeOurDate(xml.find(result, 'FirstAired')[1])
- else
- aired = ''
- end
-
-
- if xml.find(result, 'Network') then
- publisher = '\n*Publisher:* '..xml.find(result, 'Network')[1]
- else
- publisher = ''
- end
-
- if xml.find(result, 'IMDB_ID') then
- imdb = '\n[IMDB-Seite](http://www.imdb.com/title/'..xml.find(result, 'IMDB_ID')[1]..')'
- else
- imdb = ''
- end
-
- local text = '*'..title..'*'..alias..aired..publisher..imdb..desc..'\n[TVDB-Seite besuchen](http://thetvdb.com/?id='..id..'&tab=series)'
- if xml.find(result, 'banner') then
- local image_url = 'http://www.thetvdb.com/banners/'..xml.find(result, 'banner')[1]
- utilities.send_typing(msg.chat.id, 'upload_photo')
- utilities.send_photo(msg.chat.id, image_url, nil, msg.message_id)
- end
- utilities.send_reply(msg, text, true)
-end
-
-
-function tv:action(msg, config, matches)
- local series = URL.escape(matches[1])
- local tv_info = tv:get_tv_info(series)
- if tv_info == "NOTFOUND" then
- utilities.send_reply(msg, config.errors.results)
- return
- elseif tv_info == "HTTP-ERROR" then
- utilities.send_reply(msg, config.errors.connection)
- return
- else
- tv:send_tv_data(tv_info, msg)
- end
-end
-
-return tv
diff --git a/otouto/plugins/wiimmfi.lua b/otouto/plugins/wiimmfi.lua
deleted file mode 100644
index 0b4bec7..0000000
--- a/otouto/plugins/wiimmfi.lua
+++ /dev/null
@@ -1,54 +0,0 @@
-local wiimmfi = {}
-
-function wiimmfi:init(config)
- wiimmfi.triggers = {
- "^/(mkw)$",
- "^/wiimmfi$",
- "^/wfc$"
- }
- wiimmfi.doc = [[*
-]]..config.cmd_pat..[[wfc*: Zeigt alle Wiimmfi-Spieler an
-*]]..config.cmd_pat..[[mkw*: Zeigt alle Mario-Kart-Wii-Spieler an]]
-end
-
-wiimmfi.command = 'wfc, /mkw'
-
-function wiimmfi:getplayer(game)
- local url = 'http://wiimmfi.de/game'
- local res,code = http.request(url)
- if code ~= 200 then return "Fehler beim Abrufen von wiimmfi.de" end
- if game == 'mkw' then
- local players = string.match(res, "(.-)")
- if players == nil then players = 0 end
- text = 'Es spielen gerade '..players..' Spieler Mario Kart Wii'
- else
- local players = string.match(res, " | (.-) | .-", ": ")
- local players = string.gsub(players, " | ", "")
- local players = string.gsub(players, "Wii", "")
- local players = string.gsub(players, "WiiWare", "")
- local players = string.gsub(players, "NDS", "")
- local players = string.gsub(players, "", "")
- local players = string.gsub(players, "", "")
- local players = string.gsub(players, "", "")
- local players = string.gsub(players, "", "")
- local players = string.gsub(players, "", "")
- local players = string.gsub(players, "", "")
- local players = string.gsub(players, "", "")
- if players == nil then players = 'Momentan spielt keiner auf Wiimmfi :(' end
- text = players
- end
- return text
-end
-
-function wiimmfi:action(msg, config, matches)
- if matches[1] == "mkw" then
- utilities.send_reply(msg, wiimmfi:getplayer('mkw'))
- return
- else
- utilities.send_reply(msg, wiimmfi:getplayer())
- return
- end
-end
-
-return wiimmfi
\ No newline at end of file
diff --git a/otouto/plugins/yourls.lua b/otouto/plugins/yourls.lua
deleted file mode 100644
index 5f28266..0000000
--- a/otouto/plugins/yourls.lua
+++ /dev/null
@@ -1,53 +0,0 @@
-local yourls = {}
-
-function yourls:init(config)
- if not cred_data.yourls_site_url then
- print('Missing config value: yourls_site_url.')
- print('yourls.lua will not be enabled.')
- return
- elseif not cred_data.yourls_signature_token then
- print('Missing config value: yourls_signature_token.')
- print('yourls.lua will not be enabled.')
- return
- end
-
- yourls.triggers = {
- "^/yourls (https?://[%w-_%.%?%.:/%+=&]+)"
- }
-end
-
-local SITE_URL = cred_data.yourls_site_url
-local signature = cred_data.yourls_signature_token
-local BASE_URL = SITE_URL..'/yourls-api.php'
-
-function yourls: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
-
-function yourls:create_yourls_link(long_url, protocol)
- local url = BASE_URL..'?format=simple&signature='..signature..'&action=shorturl&url='..long_url
- if protocol == "http" then
- link,code = http.request(url)
- else
- link,code = https.request(url)
- end
- if code ~= 200 then
- link = 'Ein Fehler ist aufgetreten. '..link
- end
- return link
-end
-
-function yourls:action(msg, config, matches)
- local long_url = matches[1]
- local baseurl, protocol = yourls:prot_url(SITE_URL)
- utilities.send_reply(msg, yourls:create_yourls_link(long_url, protocol))
- return
-end
-
-return yourls