Seeeeehr großes Update
Meiste Änderungen von Brawl345/Brawlbot-v2 Einige Pattern angepasst Einiges übersetzt Und noch einiges mehr Stabilitätsverbesserungen
This commit is contained in:
parent
d99c805c3d
commit
5856804891
@ -25,10 +25,6 @@ Sende /hilfe, um zu starten
|
|||||||
-- NOTE that it doesn't matter, if the chat is whitelisted! The USER must be whitelisted!
|
-- NOTE that it doesn't matter, if the chat is whitelisted! The USER must be whitelisted!
|
||||||
enable_inline_for_everyone = true,
|
enable_inline_for_everyone = true,
|
||||||
|
|
||||||
-- Botan.io statistics
|
|
||||||
enable_statistics = false,
|
|
||||||
botan_token = '',
|
|
||||||
|
|
||||||
errors = { -- Generic error messages used in various plugins.
|
errors = { -- Generic error messages used in various plugins.
|
||||||
generic = 'An unexpected error occurred.',
|
generic = 'An unexpected error occurred.',
|
||||||
connection = 'Verbindungsfehler.',
|
connection = 'Verbindungsfehler.',
|
||||||
|
22
miku/bot.lua
22
miku/bot.lua
@ -1,17 +1,11 @@
|
|||||||
local bot = {}
|
local bot = {}
|
||||||
|
|
||||||
-- Requires are moved to init to allow for reloads.
|
bindings = require('miku.bindings')
|
||||||
local bindings -- Load Telegram bindings.
|
utilities = require('miku.utilities')
|
||||||
local utilities -- Load miscellaneous and cross-plugin functions.
|
|
||||||
local redis = (loadfile "./miku/redis.lua")()
|
|
||||||
|
|
||||||
bot.version = '160726'
|
bot.version = '160801'
|
||||||
|
|
||||||
function bot:init(config) -- The function run when the bot is started or reloaded.
|
function bot:init(config) -- The function run when the bot is started or reloaded.
|
||||||
|
|
||||||
bindings = require('miku.bindings')
|
|
||||||
utilities = require('miku.utilities')
|
|
||||||
redis = (loadfile "./miku/redis.lua")()
|
|
||||||
cred_data = load_cred()
|
cred_data = load_cred()
|
||||||
|
|
||||||
assert(
|
assert(
|
||||||
@ -239,7 +233,6 @@ function match_plugins(self, msg, config, plugin)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
print(plugin.name..' ausgelöst')
|
print(plugin.name..' ausgelöst')
|
||||||
plugin_name = plugin.name
|
|
||||||
return plugin.action(self, msg, config, matches)
|
return plugin.action(self, msg, config, matches)
|
||||||
end)
|
end)
|
||||||
if not success then
|
if not success then
|
||||||
@ -255,15 +248,6 @@ function match_plugins(self, msg, config, plugin)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Analytics
|
|
||||||
if config.enable_analytics and config.botan_token ~= '' then
|
|
||||||
for _,plugin in ipairs(self.plugins) do
|
|
||||||
if plugin.name == 'botan' then
|
|
||||||
plugin.action(self, msg, config, nil, plugin_name)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- If the action returns a table, make that table the new msg.
|
-- If the action returns a table, make that table the new msg.
|
||||||
if type(result) == 'table' then
|
if type(result) == 'table' then
|
||||||
msg = result
|
msg = result
|
||||||
|
@ -1,11 +1,5 @@
|
|||||||
local ninegag = {}
|
local ninegag = {}
|
||||||
|
|
||||||
local HTTP = require('socket.http')
|
|
||||||
local URL = require('socket.url')
|
|
||||||
local JSON = require('dkjson')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local bindings = require('miku.bindings')
|
|
||||||
|
|
||||||
ninegag.command = '9gag'
|
ninegag.command = '9gag'
|
||||||
|
|
||||||
function ninegag:init(config)
|
function ninegag:init(config)
|
||||||
@ -23,9 +17,9 @@ end
|
|||||||
local url = "http://api-9gag.herokuapp.com/"
|
local url = "http://api-9gag.herokuapp.com/"
|
||||||
|
|
||||||
function ninegag:get_9GAG()
|
function ninegag:get_9GAG()
|
||||||
local b,c = HTTP.request(url)
|
local b,c = http.request(url)
|
||||||
if c ~= 200 then return nil end
|
if c ~= 200 then return nil end
|
||||||
local gag = JSON.decode(b)
|
local gag = json.decode(b)
|
||||||
-- random max json table size
|
-- random max json table size
|
||||||
local i = math.random(#gag)
|
local i = math.random(#gag)
|
||||||
|
|
||||||
@ -36,9 +30,9 @@ function ninegag:get_9GAG()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function ninegag:inline_callback(inline_query, config)
|
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
|
if code ~= 200 then return end
|
||||||
local gag = JSON.decode(res)
|
local gag = json.decode(res)
|
||||||
|
|
||||||
local results = '['
|
local results = '['
|
||||||
for n in pairs(gag) do
|
for n in pairs(gag) do
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
local about = {}
|
local about = {}
|
||||||
|
|
||||||
local bot = require('miku.bot')
|
local bot = require('miku.bot')
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
about.command = 'about'
|
about.command = 'about'
|
||||||
about.doc = '`Sendet Informationen über den Bot.`'
|
about.doc = '`Sendet Informationen über den Bot.`'
|
||||||
@ -18,7 +17,7 @@ function about:action(msg, config)
|
|||||||
-- disabled to restore old behaviour
|
-- disabled to restore old behaviour
|
||||||
-- if msg.forward_from then return end
|
-- if msg.forward_from then return end
|
||||||
|
|
||||||
local output = config.about_text .. '\n[Mikudayobot](https://github.com/Akamaru/Mikubot-V2) v'..bot.version..' von @Akamaru, basierend auf [Otouto](https://github.com/topkecleon/otouto) von topkecleon.'
|
local output = config.about_text .. '\n[Mikudayobot](https://github.com/Akamaru/Mikubot-V2) v'..bot.version..' von @Akamaru, basierend auf [miku](https://github.com/topkecleon/miku) von topkecleon.'
|
||||||
|
|
||||||
if
|
if
|
||||||
(msg.new_chat_member and msg.new_chat_member.id == self.info.id)
|
(msg.new_chat_member and msg.new_chat_member.id == self.info.id)
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
local adfly = {}
|
local adfly = {}
|
||||||
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local HTTPS = require('ssl.https')
|
|
||||||
local redis = (loadfile "./miku/redis.lua")()
|
|
||||||
|
|
||||||
function adfly:init(config)
|
function adfly:init(config)
|
||||||
adfly.triggers = {
|
adfly.triggers = {
|
||||||
'adf.ly/([A-Za-z0-9-_-]+)'
|
'adf.ly/([A-Za-z0-9-_-]+)'
|
||||||
@ -15,7 +11,7 @@ end
|
|||||||
function adfly:expand_adfly_link(adfly_code)
|
function adfly:expand_adfly_link(adfly_code)
|
||||||
local BASE_URL = 'https://andibi.tk/dl/adfly.php'
|
local BASE_URL = 'https://andibi.tk/dl/adfly.php'
|
||||||
local url = BASE_URL..'/?url=http://adf.ly/'..adfly_code
|
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 code ~= 200 then return nil end
|
||||||
if res == 'Fehler: Keine Adf.ly-URL gefunden!' then return 'NOTFOUND' end
|
if res == 'Fehler: Keine Adf.ly-URL gefunden!' then return 'NOTFOUND' end
|
||||||
cache_data('adfly', adfly_code, res, 31536000, 'key')
|
cache_data('adfly', adfly_code, res, 31536000, 'key')
|
||||||
|
@ -3,9 +3,6 @@
|
|||||||
|
|
||||||
local afk = {}
|
local afk = {}
|
||||||
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local redis = (loadfile "./miku/redis.lua")()
|
|
||||||
|
|
||||||
function afk:init(config)
|
function afk:init(config)
|
||||||
afk.triggers = {
|
afk.triggers = {
|
||||||
"^/([Aa][Ff][Kk])$",
|
"^/([Aa][Ff][Kk])$",
|
||||||
@ -80,17 +77,7 @@ function afk:pre_process(msg, self)
|
|||||||
local timestamp = redis:hget(hash, 'time')
|
local timestamp = redis:hget(hash, 'time')
|
||||||
local current_timestamp = msg.date
|
local current_timestamp = msg.date
|
||||||
local afk_time = current_timestamp - timestamp
|
local afk_time = current_timestamp - timestamp
|
||||||
local seconds = afk_time % 60
|
local duration = makeHumanTime(afk_time)
|
||||||
local minutes = math.floor(afk_time / 60)
|
|
||||||
local minutes = minutes % 60
|
|
||||||
local hours = math.floor(afk_time / 3600)
|
|
||||||
if minutes == 00 and hours == 00 then
|
|
||||||
duration = seconds..' Sekunden'
|
|
||||||
elseif hours == 00 and minutes ~= 00 then
|
|
||||||
duration = string.format("%02d:%02d", minutes, seconds)..' Minuten'
|
|
||||||
elseif hours ~= 00 then
|
|
||||||
duration = string.format("%02d:%02d:%02d", hours, minutes, seconds)..' Stunden'
|
|
||||||
end
|
|
||||||
|
|
||||||
redis:hset(hash, 'afk', false)
|
redis:hset(hash, 'afk', false)
|
||||||
if afk_text then
|
if afk_text then
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
local app_store = {}
|
local app_store = {}
|
||||||
|
|
||||||
local https = require('ssl.https')
|
|
||||||
local json = require('dkjson')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local redis = (loadfile "./miku/redis.lua")()
|
|
||||||
|
|
||||||
app_store.triggers = {
|
app_store.triggers = {
|
||||||
"itunes.apple.com/(.*)/app/(.*)/id(%d+)",
|
"itunes.apple.com/(.*)/app/(.*)/id(%d+)",
|
||||||
"^/[Ii][Tt][Uu][Nn][Ee][Ss] (%d+)$",
|
"^/[Ii][Tt][Uu][Nn][Ee][Ss] (%d+)$",
|
||||||
|
@ -1,17 +1,9 @@
|
|||||||
local bImages = {}
|
local bImages = {}
|
||||||
|
|
||||||
local HTTPS = require('ssl.https')
|
|
||||||
HTTPS.timeout = 10
|
|
||||||
local URL = require('socket.url')
|
|
||||||
local JSON = require('dkjson')
|
|
||||||
local redis = (loadfile "./miku/redis.lua")()
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local bindings = require('miku.bindings')
|
|
||||||
|
|
||||||
function bImages:init(config)
|
function bImages:init(config)
|
||||||
if not cred_data.bing_search_key then
|
if not cred_data.bing_search_key then
|
||||||
print('Missing config value: bing_search_key.')
|
print('Fehlender Key: bing_search_key.')
|
||||||
print('bImages.lua will not be enabled.')
|
print('bImages.lua wird nicht aktiviert.')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -36,9 +28,9 @@ function bImages:getImages(query)
|
|||||||
["Ocp-Apim-Subscription-Key"] = apikey
|
["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
|
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
|
if not images[1] then return end
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
local banhammer = {}
|
local banhammer = {}
|
||||||
|
|
||||||
local bindings = require('miku.bindings')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local redis = (loadfile "./miku/redis.lua")()
|
|
||||||
|
|
||||||
banhammer.command = 'banhammer <nur für Superuser>'
|
banhammer.command = 'banhammer <nur für Superuser>'
|
||||||
|
|
||||||
function banhammer:init(config)
|
function banhammer:init(config)
|
||||||
|
@ -1,14 +1,9 @@
|
|||||||
local bitly = {}
|
local bitly = {}
|
||||||
|
|
||||||
local https = require('ssl.https')
|
|
||||||
local json = require('dkjson')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local redis = (loadfile "./miku/redis.lua")()
|
|
||||||
|
|
||||||
function bitly:init(config)
|
function bitly:init(config)
|
||||||
if not cred_data.bitly_access_token then
|
if not cred_data.bitly_access_token then
|
||||||
print('Missing config value: bitly_access_token.')
|
print('Fehlender Key: bitly_access_token.')
|
||||||
print('bitly.lua will not be enabled.')
|
print('bitly.lua wird nicht aktiviert.')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,26 +1,17 @@
|
|||||||
local bitly_create = {}
|
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('miku.utilities')
|
|
||||||
local bindings = require('miku.bindings')
|
|
||||||
local OAuth = require "OAuth"
|
|
||||||
local redis = (loadfile "./miku/redis.lua")()
|
|
||||||
|
|
||||||
function bitly_create:init(config)
|
function bitly_create:init(config)
|
||||||
if not cred_data.bitly_client_id then
|
if not cred_data.bitly_client_id then
|
||||||
print('Missing config value: bitly_client_id.')
|
print('Fehlender Key: bitly_client_id.')
|
||||||
print('bitly_create.lua will not be enabled.')
|
print('bitly_create.lua wird nicht aktiviert.')
|
||||||
return
|
return
|
||||||
elseif not cred_data.bitly_client_secret then
|
elseif not cred_data.bitly_client_secret then
|
||||||
print('Missing config value: bitly_client_secret.')
|
print('Fehlender Key: bitly_client_secret.')
|
||||||
print('bitly_create.lua will not be enabled.')
|
print('bitly_create.lua wird nicht aktiviert.')
|
||||||
return
|
return
|
||||||
elseif not cred_data.bitly_redirect_uri then
|
elseif not cred_data.bitly_redirect_uri then
|
||||||
print('Missing config value: bitly_redirect_uri.')
|
print('Fehlender Key: bitly_redirect_uri.')
|
||||||
print('bitly_create.lua will not be enabled.')
|
print('bitly_create.lua wird nicht aktiviert.')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
local botan = {}
|
|
||||||
|
|
||||||
local https = require('ssl.https')
|
|
||||||
local URL = require('socket.url')
|
|
||||||
local redis = (loadfile "./miku/redis.lua")()
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local bindings = require('miku.bindings')
|
|
||||||
|
|
||||||
function botan:init(config)
|
|
||||||
if not config.botan_token then
|
|
||||||
print('Fehlender Key: botan_token.')
|
|
||||||
print('botan.lua wird nicht aktiviert.')
|
|
||||||
return
|
|
||||||
end
|
|
||||||
botan.triggers = {
|
|
||||||
"^/nil$"
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
local BASE_URL = 'https://api.botan.io/track'
|
|
||||||
|
|
||||||
function botan:appmetrica(text, token, plugin_name)
|
|
||||||
https.request(BASE_URL..'/?token='..token..'&uid=1&name='..plugin_name)
|
|
||||||
end
|
|
||||||
|
|
||||||
function botan:action(msg, config, matches, plugin_name)
|
|
||||||
if not plugin_name then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
botan:appmetrica(msg.text, config.botan_token, plugin_name)
|
|
||||||
end
|
|
||||||
|
|
||||||
return botan
|
|
@ -1,11 +1,5 @@
|
|||||||
local br = {}
|
local br = {}
|
||||||
|
|
||||||
local https = require('ssl.https')
|
|
||||||
local URL = require('socket.url')
|
|
||||||
local json = require('dkjson')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local bindings = require('miku.bindings')
|
|
||||||
|
|
||||||
br.triggers = {
|
br.triggers = {
|
||||||
"br.de/nachrichten/(.*).html$"
|
"br.de/nachrichten/(.*).html$"
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,5 @@
|
|||||||
local btc = {}
|
local btc = {}
|
||||||
|
|
||||||
local https = require('ssl.https')
|
|
||||||
local URL = require('socket.url')
|
|
||||||
local json = require('dkjson')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local bindings = require('miku.bindings')
|
|
||||||
|
|
||||||
function btc:init(config)
|
function btc:init(config)
|
||||||
btc.triggers = {
|
btc.triggers = {
|
||||||
"^/[Bb][Tt][Cc]$"
|
"^/[Bb][Tt][Cc]$"
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
local calc = {}
|
local calc = {}
|
||||||
|
|
||||||
local URL = require('socket.url')
|
|
||||||
local http = require('socket.http')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
calc.command = 'calc <Ausdruck>'
|
calc.command = 'calc <Ausdruck>'
|
||||||
|
|
||||||
function calc:init(config)
|
function calc:init(config)
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
local cats = {}
|
local cats = {}
|
||||||
|
|
||||||
local HTTP = require('socket.http')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
cats.command = 'kitty [gif]'
|
cats.command = 'kitty [gif]'
|
||||||
|
|
||||||
function cats:init(config)
|
function cats:init(config)
|
||||||
if not cred_data.cat_apikey then
|
if not cred_data.cat_apikey then
|
||||||
print('Missing config value: cat_apikey.')
|
print('Fehlender Key: cat_apikey.')
|
||||||
print('cats.lua will be enabled, but there are more features with a key.')
|
print('cats.lua will be enabled, but there are more features with a key.')
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -16,6 +13,11 @@ function cats:init(config)
|
|||||||
"^/[Kk][Ii][Tt][Tt][Yy] (gif)$"
|
"^/[Kk][Ii][Tt][Tt][Yy] (gif)$"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cats.inline_triggers = {
|
||||||
|
"^[Kk][Ii][Tt][Tt][Yy] (gif)$",
|
||||||
|
"^[Kk][Ii][Tt][Tt][Yy]$"
|
||||||
|
}
|
||||||
|
|
||||||
cats.doc = [[*
|
cats.doc = [[*
|
||||||
]]..config.cmd_pat..[[kitty*: Postet eine zufällige Katze
|
]]..config.cmd_pat..[[kitty*: Postet eine zufällige Katze
|
||||||
*]]..config.cmd_pat..[[kitty* _gif_: Postet eine zufällige, animierte Katze]]
|
*]]..config.cmd_pat..[[kitty* _gif_: Postet eine zufällige, animierte Katze]]
|
||||||
@ -24,6 +26,35 @@ end
|
|||||||
|
|
||||||
local apikey = cred_data.cat_apikey or "" -- apply for one here: http://thecatapi.com/api-key-registration.html
|
local apikey = cred_data.cat_apikey or "" -- apply for one here: http://thecatapi.com/api-key-registration.html
|
||||||
|
|
||||||
|
function cats:inline_callback(inline_query, config, matches)
|
||||||
|
if matches[1] == 'gif' then
|
||||||
|
img_type = 'gif'
|
||||||
|
else
|
||||||
|
img_type = 'jpg'
|
||||||
|
end
|
||||||
|
local url = 'https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3D%27http%3A%2F%2Fthecatapi.com%2Fapi%2Fimages%2Fget%3Fformat%3Dxml%26results_per_page%3D50%26type%3D'..img_type..'%26apikey%3D'..apikey..'%27&format=json' -- no way I'm using XML, plz die
|
||||||
|
local res, code = https.request(url)
|
||||||
|
if code ~= 200 then return end
|
||||||
|
local data = json.decode(res).query.results.response.data.images.image
|
||||||
|
if not data then return end
|
||||||
|
if not data[1] then return end
|
||||||
|
|
||||||
|
local results = '['
|
||||||
|
|
||||||
|
for n in pairs(data) do
|
||||||
|
if img_type == 'gif' then
|
||||||
|
results = results..'{"type":"gif","id":"'..math.random(100000000000000000)..'","gif_url":"'..data[n].url..'","thumb_url":"'..data[n].url..'"}'
|
||||||
|
else
|
||||||
|
results = results..'{"type":"photo","id":"'..math.random(100000000000000000)..'","photo_url":"'..data[n].url..'","thumb_url":"'..data[n].url..'"}'
|
||||||
|
end
|
||||||
|
if n < #data then
|
||||||
|
results = results..','
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local results = results..']'
|
||||||
|
utilities.answer_inline_query(self, inline_query, results, 120)
|
||||||
|
end
|
||||||
|
|
||||||
function cats:action(msg, config)
|
function cats:action(msg, config)
|
||||||
if matches[1] == 'gif' then
|
if matches[1] == 'gif' then
|
||||||
local url = 'http://thecatapi.com/api/images/get?type=gif&apikey='..apikey
|
local url = 'http://thecatapi.com/api/images/get?type=gif&apikey='..apikey
|
||||||
|
@ -1,34 +1,28 @@
|
|||||||
local channel = {}
|
local channel = {}
|
||||||
|
|
||||||
local bindings = require('miku.bindings')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
channel.command = 'ch <Kanal> \\n <Nachricht>'
|
channel.command = 'ch <Kanal> \\n <Nachricht>'
|
||||||
channel.doc = [[*
|
channel.doc = [[*
|
||||||
/ch*_ <Kanal>_
|
/ch*_ <Kanal>_|_[Inline-Keyboard]_
|
||||||
_<Nachricht>_
|
_<Nachricht>_
|
||||||
|
|
||||||
Sendet eine Nachricht in den Kanal. Der Kanal kann per Username oder ID bestimmt werden, Markdown wird unterstützt. Du musst Administrator oder Besitzer des Kanals sein.
|
Sendet eine Nachricht in den Kanal. Der Kanal kann per Username oder ID bestimmt werden, Markdown wird unterstützt. Du musst Administrator oder Besitzer des Kanals sein.
|
||||||
|
|
||||||
Markdown-Syntax:
|
Inline-Keyboards sind OPTIONAL, in dem Falle einfach den Strich weglassen. Es werden NUR URL-Buttons unterstützt! Eine Beispielsyntax für einen Button findest du [auf GitHub](https://gist.githubusercontent.com/Brawl345/e671b60e24243da81934/raw/Inline-Keyboard.json).
|
||||||
*Fetter Text*
|
|
||||||
_Kursiver Text_
|
|
||||||
[Text](URL)
|
|
||||||
`Inline-Codeblock`
|
|
||||||
```Größere Code-Block über mehrere Zeilen```
|
|
||||||
|
|
||||||
*Der Kanalname muss mit einem @ beginnen!*]]
|
*Der Kanalname muss mit einem @ beginnen!*]]
|
||||||
|
|
||||||
function channel:init(config)
|
function channel:init(config)
|
||||||
channel.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('ch', true).table
|
channel.triggers = {
|
||||||
|
"^/ch @([A-Za-z0-9-_-]+)|(.+)\n(.*)",
|
||||||
|
"^/ch @([A-Za-z0-9-_-]+)\n(.*)"
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
function channel:action(msg, config)
|
function channel:action(msg, config)
|
||||||
local input = utilities.input(msg.text)
|
local input = utilities.input(msg.text)
|
||||||
local output
|
local output
|
||||||
if input then
|
local chat_id = '@'..matches[1]
|
||||||
local chat_id = utilities.get_word(input, 1)
|
local admin_list, gca_results = utilities.get_chat_administrators(self, chat_id)
|
||||||
local admin_list, t = bindings.getChatAdministrators(self, { chat_id = chat_id } )
|
|
||||||
if admin_list then
|
if admin_list then
|
||||||
local is_admin = false
|
local is_admin = false
|
||||||
for _, admin in ipairs(admin_list.result) do
|
for _, admin in ipairs(admin_list.result) do
|
||||||
@ -37,25 +31,34 @@ function channel:action(msg, config)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if is_admin then
|
if is_admin then
|
||||||
local text = input:match('\n(.+)')
|
if matches[3] then
|
||||||
if text then
|
text = matches[3]
|
||||||
local success, result = utilities.send_message(self, chat_id, text, true, nil, true)
|
reply_markup = matches[2]
|
||||||
|
-- Yeah, channels don't allow this buttons currently, but when they're ready
|
||||||
|
-- this plugin will also be ready :P
|
||||||
|
-- Also, URL buttons work!? Maybe beta?
|
||||||
|
if reply_markup:match('"callback_data":"') then
|
||||||
|
utilities.send_reply(self, msg, 'callback_data ist in Buttons nicht erlaubt.')
|
||||||
|
return
|
||||||
|
elseif reply_markup:match('"switch_inline_query":"') then
|
||||||
|
utilities.send_reply(self, msg, 'switch_inline_query ist in Buttons nicht erlaubt.')
|
||||||
|
return
|
||||||
|
end
|
||||||
|
else
|
||||||
|
text = matches[2]
|
||||||
|
reply_markup = nil
|
||||||
|
end
|
||||||
|
local success, result = utilities.send_message(self, chat_id, text, true, nil, true, reply_markup)
|
||||||
if success then
|
if success then
|
||||||
output = 'Deine Nachricht wurde versendet!'
|
output = 'Deine Nachricht wurde versendet!'
|
||||||
else
|
else
|
||||||
output = 'Sorry, ich konnte deine Nachricht nicht senden.\n`' .. result.description .. '`'
|
output = 'Sorry, ich konnte deine Nachricht nicht senden.\n`' .. result.description .. '`'
|
||||||
end
|
end
|
||||||
else
|
|
||||||
output = 'Bitte gebe deine Nachricht ein. Markdown wird unterstützt.'
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
output = 'Es sieht nicht so aus, als wärst du der Administrator dieses Kanals.'
|
output = 'Es sieht nicht so aus, als wärst du der Administrator dieses Kanals.'
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
output = 'Sorry, ich konnte die Administratorenliste nicht abrufen. Falls du den Kanalnamen benutzt: Beginnt er mit einem @?\n`' .. t.description .. '`'
|
output = 'Sorry, ich konnte die Administratorenliste nicht abrufen!\n`'..gca_results.description..'`'
|
||||||
end
|
|
||||||
else
|
|
||||||
output = channel.doc
|
|
||||||
end
|
end
|
||||||
utilities.send_reply(self, msg, output, true)
|
utilities.send_reply(self, msg, output, true)
|
||||||
end
|
end
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
local channels = {}
|
local channels = {}
|
||||||
|
|
||||||
local bindings = require('miku.bindings')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local redis = (loadfile "./miku/redis.lua")()
|
|
||||||
|
|
||||||
channels.command = 'channel <nur für Superuser>'
|
channels.command = 'channel <nur für Superuser>'
|
||||||
|
|
||||||
function channels:init(config)
|
function channels:init(config)
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
local cleverbot = {}
|
local cleverbot = {}
|
||||||
|
|
||||||
local https = require('ssl.https')
|
|
||||||
local URL = require('socket.url')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local json = require('dkjson')
|
|
||||||
|
|
||||||
function cleverbot:init(config)
|
function cleverbot:init(config)
|
||||||
cleverbot.triggers = {
|
cleverbot.triggers = {
|
||||||
"^/[Cc][Bb][Oo][Tt] (.*)$"
|
"^/[Cc][Bb][Oo][Tt] (.*)$"
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
local clypit = {}
|
local clypit = {}
|
||||||
|
|
||||||
local http = require('socket.http')
|
|
||||||
local json = require('dkjson')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local bindings = require('miku.bindings')
|
|
||||||
|
|
||||||
clypit.triggers = {
|
clypit.triggers = {
|
||||||
"clyp.it/([A-Za-z0-9-_-]+)"
|
"clyp.it/([A-Za-z0-9-_-]+)"
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
local control = {}
|
local control = {}
|
||||||
|
|
||||||
local bot = require('miku.bot')
|
local bot = require('miku.bot')
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
local cmd_pat -- Prevents the command from being uncallable.
|
local cmd_pat -- Prevents the command from being uncallable.
|
||||||
|
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
local creds_manager = {}
|
local creds_manager = {}
|
||||||
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local redis = (loadfile "./miku/redis.lua")()
|
|
||||||
|
|
||||||
function creds_manager:init(config)
|
function creds_manager:init(config)
|
||||||
creds_manager.triggers = {
|
creds_manager.triggers = {
|
||||||
"^(/creds)$",
|
"^(/creds)$",
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
local currency = {}
|
local currency = {}
|
||||||
|
|
||||||
local HTTPS = require('ssl.https')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
currency.command = 'cash [Menge] <von> <zu>'
|
currency.command = 'cash [Menge] <von> <zu>'
|
||||||
|
|
||||||
function currency:init(config)
|
function currency:init(config)
|
||||||
@ -42,7 +39,7 @@ function currency:action(msg, config)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local url = BASE_URL..'?from='..from..'&to='..to..'&a='..amount
|
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
|
if res ~= 200 then
|
||||||
utilities.send_reply(self, msg, config.errors.connection)
|
utilities.send_reply(self, msg, config.errors.connection)
|
||||||
return
|
return
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
local dailymotion = {}
|
local dailymotion = {}
|
||||||
|
|
||||||
local https = require('ssl.https')
|
|
||||||
local json = require('dkjson')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
dailymotion.triggers = {
|
dailymotion.triggers = {
|
||||||
"dailymotion.com/video/([A-Za-z0-9-_-]+)"
|
"dailymotion.com/video/([A-Za-z0-9-_-]+)"
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
local deviantart = {}
|
local deviantart = {}
|
||||||
|
|
||||||
local https = require('ssl.https')
|
|
||||||
local json = require('dkjson')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
deviantart.triggers = {
|
deviantart.triggers = {
|
||||||
"http://(.*).deviantart.com/art/(.*)"
|
"http://(.*).deviantart.com/art/(.*)"
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,8 @@
|
|||||||
local dhl = {}
|
local dhl = {}
|
||||||
|
|
||||||
local https = require('ssl.https')
|
|
||||||
local json = require('dkjson')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
function dhl:init(config)
|
function dhl:init(config)
|
||||||
dhl.triggers = {
|
dhl.triggers = {
|
||||||
"/[Dd][Hh][Ll] (%d+)$"
|
'/[Dd][Hh][Ll] (%d+)$'
|
||||||
}
|
}
|
||||||
dhl.doc = [[*
|
dhl.doc = [[*
|
||||||
]]..config.cmd_pat..[[dhl* _<Sendungsnummer>_: Aktueller Status der Sendung]]
|
]]..config.cmd_pat..[[dhl* _<Sendungsnummer>_: Aktueller Status der Sendung]]
|
||||||
@ -18,10 +14,10 @@ local BASE_URL = 'https://mobil.dhl.de'
|
|||||||
function dhl:sendungsstatus(id)
|
function dhl:sendungsstatus(id)
|
||||||
local url = BASE_URL..'/shipmentdetails.html?shipmentId='..id
|
local url = BASE_URL..'/shipmentdetails.html?shipmentId='..id
|
||||||
local res,code = https.request(url)
|
local res,code = https.request(url)
|
||||||
if code ~= 200 then return "Fehler beim Abrufen von mobil.dhl.de" end
|
if code ~= 200 then return 'Fehler beim Abrufen von mobil.dhl.de' end
|
||||||
local status = string.match(res, "<div id%=\"detailShortStatus\">(.-)</div>")
|
local status = string.match(res, '<div id%=\"detailShortStatus\">(.-)</div>')
|
||||||
local status = all_trim(status)
|
local status = all_trim(status)
|
||||||
local zeit = string.match(res, "<div id%=\"detailStatusDateTime\">(.-)</div>")
|
local zeit = string.match(res, '<div id%=\"detailStatusDateTime\">(.-)</div>')
|
||||||
local zeit = all_trim(zeit)
|
local zeit = all_trim(zeit)
|
||||||
if not zeit or zeit == '<br />' then
|
if not zeit or zeit == '<br />' then
|
||||||
return status
|
return status
|
||||||
|
@ -2,27 +2,23 @@
|
|||||||
|
|
||||||
local dropbox = {}
|
local dropbox = {}
|
||||||
|
|
||||||
local https = require('ssl.https')
|
|
||||||
local json = require('dkjson')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
dropbox.triggers = {
|
dropbox.triggers = {
|
||||||
"dropbox.com/s/([a-z0-9]+)/(.*)"
|
'dropbox.com/s/([a-z0-9]+)/(.*)'
|
||||||
}
|
}
|
||||||
|
|
||||||
function dropbox:action(msg, config, matches)
|
function dropbox:action(msg, config, matches)
|
||||||
local folder = matches[1]
|
local folder = matches[1]
|
||||||
local file = string.gsub(matches[2], "?dl=0", "")
|
local file = string.gsub(matches[2], '?dl=0', '')
|
||||||
local link = 'https://dl.dropboxusercontent.com/s/'..folder..'/'..file
|
local link = 'https://dl.dropboxusercontent.com/s/'..folder..'/'..file
|
||||||
|
|
||||||
local v,code = https.request(link)
|
local v,code = https.request(link)
|
||||||
if code == 200 then
|
if code == 200 then
|
||||||
if string.ends(link, ".png") or string.ends(link, ".jpe?g")then
|
if string.ends(link, '.png') or string.ends(link, '.jpe?g')then
|
||||||
utilities.send_typing(self, msg.chat.id, 'upload_photo')
|
utilities.send_typing(self, msg.chat.id, 'upload_photo')
|
||||||
local file = download_to_file(link)
|
local file = download_to_file(link)
|
||||||
utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id)
|
utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id)
|
||||||
return
|
return
|
||||||
elseif string.ends(link, ".webp") or string.ends(link, ".gif") then
|
elseif string.ends(link, '.webp') or string.ends(link, '.gif') then
|
||||||
utilities.send_typing(self, msg.chat.id, 'upload_photo')
|
utilities.send_typing(self, msg.chat.id, 'upload_photo')
|
||||||
local file = download_to_file(link)
|
local file = download_to_file(link)
|
||||||
utilities.send_document(self, msg.chat.id, file, nil, msg.message_id)
|
utilities.send_document(self, msg.chat.id, file, nil, msg.message_id)
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
local echo = {}
|
local echo = {}
|
||||||
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
echo.command = 'echo <Text>'
|
echo.command = 'echo <Text>'
|
||||||
|
|
||||||
function echo:init(config)
|
function echo:init(config)
|
||||||
echo.triggers = {"/[Ee][Cc][Hh][Oo] (.*)$"}
|
echo.triggers = {'/[Ee][Cc][Hh][Oo] (.*)$'}
|
||||||
echo.inline_triggers = {
|
echo.inline_triggers = {
|
||||||
"^echo (.*)",
|
'^echo (.*)',
|
||||||
"^bold (.*)"
|
'^bold (.*)'
|
||||||
}
|
}
|
||||||
echo.doc = [[*
|
echo.doc = [[*
|
||||||
]]..config.cmd_pat..[[echo* _<Text>_: Gibt den Text aus]]
|
]]..config.cmd_pat..[[echo* _<Text>_: Gibt den Text aus]]
|
||||||
@ -35,6 +33,8 @@ function echo:action(msg)
|
|||||||
local output
|
local output
|
||||||
if msg.chat.type == 'supergroup' then
|
if msg.chat.type == 'supergroup' then
|
||||||
output = '*Echo:*\n"' .. utilities.md_escape(input) .. '"'
|
output = '*Echo:*\n"' .. utilities.md_escape(input) .. '"'
|
||||||
|
utilities.send_message(self, msg.chat.id, output, true, nil, true)
|
||||||
|
return
|
||||||
end
|
end
|
||||||
utilities.send_message(self, msg.chat.id, input, true, nil, true)
|
utilities.send_message(self, msg.chat.id, input, true, nil, true)
|
||||||
end
|
end
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
local entergroup = {}
|
local entergroup = {}
|
||||||
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local bindings = require('miku.bindings')
|
|
||||||
|
|
||||||
entergroup.triggers = {
|
entergroup.triggers = {
|
||||||
'/nil'
|
'/nil'
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
local expand = {}
|
local expand = {}
|
||||||
|
|
||||||
local http = require('socket.http')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
function expand:init(config)
|
function expand:init(config)
|
||||||
expand.triggers = {
|
expand.triggers = {
|
||||||
"^/[Ee][Xx][Pp][Aa][Nn][Dd] (https?://[%w-_%.%?%.:/%+=&]+)$"
|
'^/[Ee][Xx][Pp][Aa][Nn][Dd] (https?://[%w-_%.%?%.:/%+=&]+)$'
|
||||||
}
|
}
|
||||||
expand.inline_triggers = {
|
expand.inline_triggers = {
|
||||||
"^ex (https?://[%w-_%.%?%.:/%+=&]+)$"
|
'^ex (https?://[%w-_%.%?%.:/%+=&]+)$'
|
||||||
}
|
}
|
||||||
|
|
||||||
expand.doc = [[*
|
expand.doc = [[*
|
||||||
@ -53,7 +50,7 @@ function expand:action(msg, config, matches)
|
|||||||
utilities.send_reply(self, msg, response_headers.location)
|
utilities.send_reply(self, msg, response_headers.location)
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
utilities.send_reply(self, msg, "Fehler beim Erweitern der URL.")
|
utilities.send_reply(self, msg, 'Fehler beim Erweitern der URL.')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,28 +1,20 @@
|
|||||||
local facebook = {}
|
local facebook = {}
|
||||||
|
|
||||||
local http = require('socket.http')
|
|
||||||
local https = require('ssl.https')
|
|
||||||
local URL = require('socket.url')
|
|
||||||
local json = require('dkjson')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local bindings = require('miku.bindings')
|
|
||||||
local redis = (loadfile "./miku/redis.lua")()
|
|
||||||
|
|
||||||
function facebook:init(config)
|
function facebook:init(config)
|
||||||
if not cred_data.fb_access_token then
|
if not cred_data.fb_access_token then
|
||||||
print('Missing config value: fb_access_token.')
|
print('Fehlender Key: fb_access_token.')
|
||||||
print('facebook.lua will not be enabled.')
|
print('facebook.lua wird nicht aktiviert.')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
facebook.triggers = {
|
facebook.triggers = {
|
||||||
"facebook.com/([A-Za-z0-9-._-]+)/(posts)/(%d+)",
|
'facebook.com/([A-Za-z0-9-._-]+)/(posts)/(%d+)',
|
||||||
"facebook.com/(permalink).php%?(story_fbid)=(%d+)&id=(%d+)",
|
'facebook.com/(permalink).php%?(story_fbid)=(%d+)&id=(%d+)',
|
||||||
"facebook.com/(photo).php%?fbid=(%d+)",
|
'facebook.com/(photo).php%?fbid=(%d+)',
|
||||||
"facebook.com/([A-Za-z0-9-._-]+)/(photos)/a.(%d+[%d%.]*)/(%d+)",
|
'facebook.com/([A-Za-z0-9-._-]+)/(photos)/a.(%d+[%d%.]*)/(%d+)',
|
||||||
"facebook.com/(video).php%?v=(%d+)",
|
'facebook.com/(video).php%?v=(%d+)',
|
||||||
"facebook.com/([A-Za-z0-9-._-]+)/(videos)/(%d+[%d%.]*)",
|
'facebook.com/([A-Za-z0-9-._-]+)/(videos)/(%d+[%d%.]*)',
|
||||||
"facebook.com/([A-Za-z0-9-._-]+)"
|
'facebook.com/([A-Za-z0-9-._-]+)'
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -30,7 +22,7 @@ local BASE_URL = 'https://graph.facebook.com/v2.5'
|
|||||||
local fb_access_token = cred_data.fb_access_token
|
local fb_access_token = cred_data.fb_access_token
|
||||||
|
|
||||||
local makeOurDate = function(dateString)
|
local makeOurDate = function(dateString)
|
||||||
local pattern = "(%d+)%/(%d+)%/(%d+)"
|
local pattern = '(%d+)%/(%d+)%/(%d+)'
|
||||||
local month, day, year = dateString:match(pattern)
|
local month, day, year = dateString:match(pattern)
|
||||||
return day..'.'..month..'.'..year
|
return day..'.'..month..'.'..year
|
||||||
end
|
end
|
||||||
@ -55,13 +47,13 @@ function facebook:fb_post (id, story_id)
|
|||||||
if data.link then
|
if data.link then
|
||||||
link = '\n'..data.name..':\n'..utilities.md_escape(data.link)
|
link = '\n'..data.name..':\n'..utilities.md_escape(data.link)
|
||||||
else
|
else
|
||||||
link = ""
|
link = ''
|
||||||
end
|
end
|
||||||
|
|
||||||
if data.story then
|
if data.story then
|
||||||
story = ' ('..data.story..')'
|
story = ' ('..data.story..')'
|
||||||
else
|
else
|
||||||
story = ""
|
story = ''
|
||||||
end
|
end
|
||||||
|
|
||||||
local text = '*'..from..'*'..story..':\n'..message..'\n'..link
|
local text = '*'..from..'*'..story..':\n'..message..'\n'..link
|
||||||
@ -112,13 +104,13 @@ function facebook:facebook_info(name)
|
|||||||
if data.about then
|
if data.about then
|
||||||
about = '\n'..data.about
|
about = '\n'..data.about
|
||||||
else
|
else
|
||||||
about = ""
|
about = ''
|
||||||
end
|
end
|
||||||
|
|
||||||
if data.general_info then
|
if data.general_info then
|
||||||
general_info = '\n'..data.general_info
|
general_info = '\n'..data.general_info
|
||||||
else
|
else
|
||||||
general_info = ""
|
general_info = ''
|
||||||
end
|
end
|
||||||
|
|
||||||
if data.birthday and data.founded then
|
if data.birthday and data.founded then
|
||||||
@ -128,7 +120,7 @@ function facebook:facebook_info(name)
|
|||||||
elseif data.founded and not data.birthday then
|
elseif data.founded and not data.birthday then
|
||||||
birth = '\nGegründet: '..data.founded
|
birth = '\nGegründet: '..data.founded
|
||||||
else
|
else
|
||||||
birth = ""
|
birth = ''
|
||||||
end
|
end
|
||||||
|
|
||||||
local text = '*'..name..'* ('..category..')_'..about..'_'..general_info..birth
|
local text = '*'..name..'* ('..category..')_'..about..'_'..general_info..birth
|
||||||
|
@ -1,26 +1,21 @@
|
|||||||
local flickr = {}
|
local flickr = {}
|
||||||
|
|
||||||
local https = require('ssl.https')
|
|
||||||
local json = require('dkjson')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local bindings = require('miku.bindings')
|
|
||||||
|
|
||||||
function flickr:init(config)
|
function flickr:init(config)
|
||||||
if not cred_data.flickr_apikey then
|
if not cred_data.flickr_apikey then
|
||||||
print('Missing config value: flickr_apikey.')
|
print('Fehlender Key: flickr_apikey.')
|
||||||
print('flickr.lua will not be enabled.')
|
print('flickr.lua wird nicht aktiviert.')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
flickr.triggers = {
|
flickr.triggers = {
|
||||||
"flickr.com/photos/([A-Za-z0-9-_-]+)/([0-9]+)"
|
'flickr.com/photos/([A-Za-z0-9-_-]+)/([0-9]+)'
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
local BASE_URL = 'https://api.flickr.com/services/rest'
|
local BASE_URL = 'https://api.flickr.com/services/rest'
|
||||||
|
|
||||||
local makeOurDate = function(dateString)
|
local makeOurDate = function(dateString)
|
||||||
local pattern = "(%d+)%-(%d+)%-(%d+) (%d+)%:(%d+)%:(%d+)"
|
local pattern = '(%d+)%-(%d+)%-(%d+) (%d+)%:(%d+)%:(%d+)'
|
||||||
local year, month, day, hours, minutes, seconds = dateString:match(pattern)
|
local year, month, day, hours, minutes, seconds = dateString:match(pattern)
|
||||||
return day..'.'..month..'.'..year..' um '..hours..':'..minutes..':'..seconds..' Uhr'
|
return day..'.'..month..'.'..year..' um '..hours..':'..minutes..':'..seconds..' Uhr'
|
||||||
end
|
end
|
||||||
|
@ -1,19 +1,14 @@
|
|||||||
local flickr_search = {}
|
local flickr_search = {}
|
||||||
|
|
||||||
local https = require('ssl.https')
|
|
||||||
local json = require('dkjson')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local bindings = require('miku.bindings')
|
|
||||||
|
|
||||||
function flickr_search:init(config)
|
function flickr_search:init(config)
|
||||||
if not cred_data.flickr_apikey then
|
if not cred_data.flickr_apikey then
|
||||||
print('Missing config value: flickr_apikey.')
|
print('Fehlender Key: flickr_apikey.')
|
||||||
print('flickr_search.lua will not be enabled.')
|
print('flickr_search.lua wird nicht aktiviert.')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
flickr_search.triggers = {
|
flickr_search.triggers = {
|
||||||
"^/flickr (.*)$"
|
'^/[Ff][Ll][Ii][Cc][Kk][Rr] (.*)'
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -41,7 +36,7 @@ function flickr_search:action(msg, config, matches)
|
|||||||
|
|
||||||
local file = download_to_file(url)
|
local file = download_to_file(url)
|
||||||
|
|
||||||
if string.ends(url, ".gif") then
|
if string.ends(url, '.gif') then
|
||||||
utilities.send_document(self, msg.chat.id, file, url)
|
utilities.send_document(self, msg.chat.id, file, url)
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
|
@ -1,20 +1,13 @@
|
|||||||
local forecast = {}
|
local forecast = {}
|
||||||
|
|
||||||
local HTTPS = require('ssl.https')
|
|
||||||
local URL = require('socket.url')
|
|
||||||
local JSON = require('dkjson')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local bindings = require('miku.bindings')
|
|
||||||
local redis = (loadfile "./miku/redis.lua")()
|
|
||||||
|
|
||||||
function forecast:init(config)
|
function forecast:init(config)
|
||||||
if not cred_data.forecastio_apikey then
|
if not cred_data.forecastio_apikey then
|
||||||
print('Missing config value: forecastio_apikey.')
|
print('Fehlender Key: forecastio_apikey.')
|
||||||
print('weather.lua will not be enabled.')
|
print('weather.lua wird nicht aktiviert.')
|
||||||
return
|
return
|
||||||
elseif not cred_data.google_apikey then
|
elseif not cred_data.google_apikey then
|
||||||
print('Missing config value: google_apikey.')
|
print('Fehlender Key: google_apikey.')
|
||||||
print('weather.lua will not be enabled.')
|
print('weather.lua wird nicht aktiviert.')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -46,9 +39,9 @@ function get_city_name(lat, lng)
|
|||||||
local city = redis:hget('telegram:cache:weather:pretty_names', lat..','..lng)
|
local city = redis:hget('telegram:cache:weather:pretty_names', lat..','..lng)
|
||||||
if city then return city end
|
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 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
|
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
|
local city = data.formatted_address
|
||||||
print('Setting '..lat..','..lng..' in redis hash telegram:cache:weather:pretty_names to "'..city..'"')
|
print('Setting '..lat..','..lng..' in redis hash telegram:cache:weather:pretty_names to "'..city..'"')
|
||||||
redis:hset('telegram:cache:weather:pretty_names', lat..','..lng, city)
|
redis:hset('telegram:cache:weather:pretty_names', lat..','..lng, city)
|
||||||
@ -107,9 +100,9 @@ function forecast:get_forecast(lat, lng)
|
|||||||
method = "GET",
|
method = "GET",
|
||||||
sink = ltn12.sink.table(response_body)
|
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
|
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)
|
local ttl = string.sub(response_headers["cache-control"], 9)
|
||||||
|
|
||||||
|
|
||||||
@ -153,9 +146,9 @@ function forecast:get_forecast_hourly(lat, lng)
|
|||||||
method = "GET",
|
method = "GET",
|
||||||
sink = ltn12.sink.table(response_body)
|
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
|
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)
|
local ttl = string.sub(response_headers["cache-control"], 9)
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,22 +3,14 @@
|
|||||||
|
|
||||||
local gImages = {}
|
local gImages = {}
|
||||||
|
|
||||||
local HTTPS = require('ssl.https')
|
|
||||||
HTTPS.timeout = 10
|
|
||||||
local URL = require('socket.url')
|
|
||||||
local JSON = require('dkjson')
|
|
||||||
local redis = (loadfile "./miku/redis.lua")()
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local bindings = require('miku.bindings')
|
|
||||||
|
|
||||||
function gImages:init(config)
|
function gImages:init(config)
|
||||||
if not cred_data.google_apikey then
|
if not cred_data.google_apikey then
|
||||||
print('Missing config value: google_apikey.')
|
print('Fehlender Key: google_apikey.')
|
||||||
print('gImages.lua will not be enabled.')
|
print('gImages.lua wird nicht aktiviert.')
|
||||||
return
|
return
|
||||||
elseif not cred_data.google_cse_id then
|
elseif not cred_data.google_cse_id then
|
||||||
print('Missing config value: google_cse_id.')
|
print('Fehlender Key: google_cse_id.')
|
||||||
print('gImages.lua will not be enabled.')
|
print('gImages.lua wird nicht aktiviert.')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -97,7 +89,7 @@ function gImages:callback(callback, msg, self, config, input)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if failed then
|
if failed then
|
||||||
utilities.send_reply(self, msg, 'Fehler beim Herunterladen eines Bildes.', true, '{"inline_keyboard":[[{"text":"Nochmal versuchen","callback_data":"@'..self.info.username..' gImages:'..input..'"}]]}')
|
utilities.send_reply(self, msg, 'Fehler beim Herunterladen eines Bildes.', true)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -114,12 +106,12 @@ function gImages:callback(callback, msg, self, config, input)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function gImages:get_image(input)
|
function gImages:get_image(input)
|
||||||
local apikey = cred_data.google_apikey -- 100 requests is RIDICULOUS, Google!
|
local apikey = cred_data.google_apikey
|
||||||
local cseid = cred_data.google_cse_id
|
local cseid = cred_data.google_cse_id
|
||||||
local BASE_URL = 'https://www.googleapis.com/customsearch/v1'
|
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 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 jstr, res = https.request(url)
|
||||||
local jdat = JSON.decode(jstr).items
|
local jdat = json.decode(jstr).items
|
||||||
|
|
||||||
if not jdat then
|
if not jdat then
|
||||||
return 'NORESULTS'
|
return 'NORESULTS'
|
||||||
@ -160,9 +152,9 @@ function gImages:action(msg, config, matches)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
print ('Checking if search contains blacklisted word: '..input)
|
print ('Überprüfe, ob das Wort auf der Blackliste steht: '..input)
|
||||||
if is_blacklisted(input) then
|
if is_blacklisted(input) then
|
||||||
utilities.send_reply(self, msg, 'Vergiss es! ._.')
|
utilities.send_reply(self, msg, 'Vergiss es!')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -204,11 +196,11 @@ function gImages:action(msg, config, matches)
|
|||||||
|
|
||||||
-- It's important to save the image with the right ending!
|
-- It's important to save the image with the right ending!
|
||||||
if mimetype == 'image/gif' then
|
if mimetype == 'image/gif' then
|
||||||
file = download_to_file(img_url, 'img.gif')
|
file = download_to_file(img_url)
|
||||||
elseif mimetype == 'image/png' then
|
elseif mimetype == 'image/png' then
|
||||||
file = download_to_file(img_url, 'img.png')
|
file = download_to_file(img_url)
|
||||||
elseif mimetype == 'image/jpeg' then
|
elseif mimetype == 'image/jpeg' then
|
||||||
file = download_to_file(img_url, 'img.jpg')
|
file = download_to_file(img_url)
|
||||||
else
|
else
|
||||||
file = nil
|
file = nil
|
||||||
end
|
end
|
||||||
@ -226,7 +218,7 @@ function gImages:action(msg, config, matches)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if failed then
|
if failed then
|
||||||
utilities.send_reply(self, msg, 'Fehler beim Herunterladen eines Bildes.', true, '{"inline_keyboard":[[{"text":"Nochmal versuchen","callback_data":"@'..self.info.username..' gImages:'..URL.escape(input)..'"}]]}')
|
utilities.send_reply(self, msg, 'Fehler beim Herunterladen eines Bildes.', true)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -3,22 +3,14 @@
|
|||||||
|
|
||||||
local gImages_nsfw = {}
|
local gImages_nsfw = {}
|
||||||
|
|
||||||
local HTTPS = require('ssl.https')
|
|
||||||
HTTPS.timeout = 10
|
|
||||||
local URL = require('socket.url')
|
|
||||||
local JSON = require('dkjson')
|
|
||||||
local redis = (loadfile "./miku/redis.lua")()
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local bindings = require('miku.bindings')
|
|
||||||
|
|
||||||
function gImages_nsfw:init(config)
|
function gImages_nsfw:init(config)
|
||||||
if not cred_data.google_apikey then
|
if not cred_data.google_apikey then
|
||||||
print('Missing config value: google_apikey.')
|
print('Fehlender Key: google_apikey.')
|
||||||
print('gImages_nsfw.lua will not be enabled.')
|
print('gImages_nsfw.lua wird nicht aktiviert.')
|
||||||
return
|
return
|
||||||
elseif not cred_data.google_cse_id then
|
elseif not cred_data.google_cse_id then
|
||||||
print('Missing config value: google_cse_id.')
|
print('Fehlender Key: google_cse_id.')
|
||||||
print('gImages_nsfw.lua will not be enabled.')
|
print('gImages_nsfw.lua wird nicht aktiviert.')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -97,7 +89,7 @@ function gImages_nsfw:callback(callback, msg, self, config, input)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if failed then
|
if failed then
|
||||||
utilities.send_reply(self, msg, 'Fehler beim Herunterladen eines Bildes.', true, '{"inline_keyboard":[[{"text":"Nochmal versuchen","callback_data":"@'..self.info.username..' gImages_nsfw:'..input..'"}]]}')
|
utilities.send_reply(self, msg, 'Fehler beim Herunterladen eines Bildes.', true)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -114,12 +106,12 @@ function gImages_nsfw:callback(callback, msg, self, config, input)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function gImages_nsfw:get_image(input)
|
function gImages_nsfw:get_image(input)
|
||||||
local apikey = cred_data.google_apikey -- 100 requests is RIDICULOUS, Google!
|
local apikey = cred_data.google_apikey
|
||||||
local cseid = cred_data.google_cse_id
|
local cseid = cred_data.google_cse_id
|
||||||
local BASE_URL = 'https://www.googleapis.com/customsearch/v1'
|
local BASE_URL = 'https://www.googleapis.com/customsearch/v1'
|
||||||
local url = BASE_URL..'/?searchType=image&alt=json&num=10&key='..apikey..'&cx='..cseid..'&q=' .. input .. '&fields=items(link,mime,image(contextLink))'
|
local url = BASE_URL..'/?searchType=image&alt=json&num=10&key='..apikey..'&cx='..cseid..'&q=' .. input .. '&fields=items(link,mime,image(contextLink))'
|
||||||
local jstr, res = HTTPS.request(url)
|
local jstr, res = https.request(url)
|
||||||
local jdat = JSON.decode(jstr).items
|
local jdat = json.decode(jstr).items
|
||||||
|
|
||||||
if not jdat then
|
if not jdat then
|
||||||
return 'NORESULTS'
|
return 'NORESULTS'
|
||||||
@ -160,9 +152,9 @@ function gImages_nsfw:action(msg, config, matches)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
print ('Checking if search contains blacklisted word: '..input)
|
print ('Überprüfe, ob das Wort auf der Blackliste steht: '..input)
|
||||||
if is_blacklisted(input) then
|
if is_blacklisted(input) then
|
||||||
utilities.send_reply(self, msg, 'Vergiss es! ._.')
|
utilities.send_reply(self, msg, 'Vergiss es!')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -204,11 +196,11 @@ function gImages_nsfw:action(msg, config, matches)
|
|||||||
|
|
||||||
-- It's important to save the image with the right ending!
|
-- It's important to save the image with the right ending!
|
||||||
if mimetype == 'image/gif' then
|
if mimetype == 'image/gif' then
|
||||||
file = download_to_file(img_url, 'img.gif')
|
file = download_to_file(img_url)
|
||||||
elseif mimetype == 'image/png' then
|
elseif mimetype == 'image/png' then
|
||||||
file = download_to_file(img_url, 'img.png')
|
file = download_to_file(img_url)
|
||||||
elseif mimetype == 'image/jpeg' then
|
elseif mimetype == 'image/jpeg' then
|
||||||
file = download_to_file(img_url, 'img.jpg')
|
file = download_to_file(img_url)
|
||||||
else
|
else
|
||||||
file = nil
|
file = nil
|
||||||
end
|
end
|
||||||
@ -226,7 +218,7 @@ function gImages_nsfw:action(msg, config, matches)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if failed then
|
if failed then
|
||||||
utilities.send_reply(self, msg, 'Fehler beim Herunterladen eines Bildes.', true, '{"inline_keyboard":[[{"text":"Nochmal versuchen","callback_data":"@'..self.info.username..' gImages_nsfw:'..URL.escape(input)..'"}]]}')
|
utilities.send_reply(self, msg, 'Fehler beim Herunterladen eines Bildes.', true)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
local gMaps = {}
|
local gMaps = {}
|
||||||
|
|
||||||
local URL = require('socket.url')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
gMaps.command = 'loc <Ort>'
|
gMaps.command = 'loc <Ort>'
|
||||||
|
|
||||||
function gMaps:init(config)
|
function gMaps:init(config)
|
||||||
gMaps.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('loc', true).table
|
gMaps.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('[Ll][Oo][Cc]', true).table
|
||||||
gMaps.doc = [[*
|
gMaps.doc = [[*
|
||||||
]]..config.cmd_pat..[[loc* _<Ort>_: Sendet Ort via Google Maps]]
|
]]..config.cmd_pat..[[loc* _<Ort>_: Sendet Ort via Google Maps]]
|
||||||
end
|
end
|
||||||
|
@ -1,14 +1,9 @@
|
|||||||
local gSearch = {}
|
local gSearch = {}
|
||||||
|
|
||||||
local HTTPS = require('ssl.https')
|
|
||||||
local URL = require('socket.url')
|
|
||||||
local JSON = require('dkjson')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
gSearch.command = 'google <Suchbegriff>'
|
gSearch.command = 'google <Suchbegriff>'
|
||||||
|
|
||||||
function gSearch:init(config)
|
function gSearch:init(config)
|
||||||
gSearch.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('g', true):t('google', true).table
|
gSearch.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('[Gg]', true):t('[Gg][Oo][Oo][Gg][Ll][Ee]', true).table
|
||||||
gSearch.doc = [[*
|
gSearch.doc = [[*
|
||||||
]]..config.cmd_pat..[[google* _<Suchbegriff>_: Sendet Suchergebnisse von Google
|
]]..config.cmd_pat..[[google* _<Suchbegriff>_: Sendet Suchergebnisse von Google
|
||||||
Alias: _]]..config.cmd_pat..[[g_]]
|
Alias: _]]..config.cmd_pat..[[g_]]
|
||||||
@ -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 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 "")
|
local parameters = "q=".. (URL.escape(query) or "")
|
||||||
-- Do the request
|
-- Do the request
|
||||||
local res, code = HTTPS.request(api..parameters)
|
local res, code = https.request(api..parameters)
|
||||||
if code == 403 then
|
if code == 403 then
|
||||||
return '403'
|
return '403'
|
||||||
end
|
end
|
||||||
@ -31,7 +26,7 @@ function gSearch:googlethat(query, config)
|
|||||||
utilities.send_reply(self, msg, config.errors.connection)
|
utilities.send_reply(self, msg, config.errors.connection)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local data = JSON.decode(res)
|
local data = json.decode(res)
|
||||||
if data.searchInformation.formattedTotalResults == "0" then return nil end
|
if data.searchInformation.formattedTotalResults == "0" then return nil end
|
||||||
|
|
||||||
local results={}
|
local results={}
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
local games = {}
|
local games = {}
|
||||||
|
|
||||||
local http = require('socket.http')
|
|
||||||
local URL = require('socket.url')
|
|
||||||
local xml = require("xml")
|
local xml = require("xml")
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local bindings = require('miku.bindings')
|
|
||||||
|
|
||||||
games.command = 'game <Spiel>'
|
games.command = 'game <Spiel>'
|
||||||
|
|
||||||
|
@ -1,15 +1,9 @@
|
|||||||
local gdrive = {}
|
local gdrive = {}
|
||||||
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local https = require('ssl.https')
|
|
||||||
local ltn12 = require('ltn12')
|
|
||||||
local json = require('dkjson')
|
|
||||||
local bindings = require('miku.bindings')
|
|
||||||
|
|
||||||
function gdrive:init(config)
|
function gdrive:init(config)
|
||||||
if not cred_data.google_apikey then
|
if not cred_data.google_apikey then
|
||||||
print('Missing config value: google_apikey.')
|
print('Fehlender Key: google_apikey.')
|
||||||
print('gdrive.lua will not be enabled.')
|
print('gdrive.lua wird nicht aktiviert.')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
local get = {}
|
local get = {}
|
||||||
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local redis = (loadfile "./miku/redis.lua")()
|
|
||||||
|
|
||||||
get.command = 'get <Variable>'
|
get.command = 'get <Variable>'
|
||||||
|
|
||||||
function get:init(config)
|
function get:init(config)
|
||||||
get.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('get', true).table
|
get.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('[Gg][Ee][Tt]', true).table
|
||||||
get.doc = [[*
|
get.doc = [[*
|
||||||
]]..config.cmd_pat..[[get*: Gibt alle Variablen aus
|
]]..config.cmd_pat..[[get*: Gibt alle Variablen aus
|
||||||
*]]..config.cmd_pat..[[get* _<Variable>_: Gibt _Variable_ aus
|
*]]..config.cmd_pat..[[get* _<Variable>_: Gibt _Variable_ aus
|
||||||
@ -30,7 +27,7 @@ function get:list_variables(msg)
|
|||||||
print(hash)
|
print(hash)
|
||||||
|
|
||||||
if hash then
|
if hash then
|
||||||
print('Getting variable from redis hash '..hash)
|
print('Hole Variable von Redis Hash '..hash)
|
||||||
local names = redis:hkeys(hash)
|
local names = redis:hkeys(hash)
|
||||||
local text = ''
|
local text = ''
|
||||||
for i=1, #names do
|
for i=1, #names do
|
||||||
|
@ -4,12 +4,6 @@
|
|||||||
|
|
||||||
local media_download = {}
|
local media_download = {}
|
||||||
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local bindings = require('miku.bindings')
|
|
||||||
local ltn12 = require('ltn12')
|
|
||||||
local HTTPS = require('ssl.https')
|
|
||||||
local redis = (loadfile "./miku/redis.lua")()
|
|
||||||
|
|
||||||
media_download.triggers = {
|
media_download.triggers = {
|
||||||
'/nil'
|
'/nil'
|
||||||
}
|
}
|
||||||
@ -22,7 +16,7 @@ function media_download:download_to_file_permanently(url, file_name)
|
|||||||
redirect = false
|
redirect = false
|
||||||
}
|
}
|
||||||
local response = nil
|
local response = nil
|
||||||
response = {HTTPS.request(options)}
|
response = {https.request(options)}
|
||||||
|
|
||||||
local code = response[2]
|
local code = response[2]
|
||||||
local headers = response[3]
|
local headers = response[3]
|
||||||
@ -65,14 +59,14 @@ function media_download:pre_process(msg, self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if file_size > 19922944 then
|
if file_size > 19922944 then
|
||||||
print('File is over 20 MB - can\'t download :(')
|
print('Datei ist größer als 20 MB - Nicht downloadbar!')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check if file has already been downloaded
|
-- Check if file has already been downloaded
|
||||||
local already_downloaded = redis:sismember('telegram:file_id', file_id)
|
local already_downloaded = redis:sismember('telegram:file_id', file_id)
|
||||||
if already_downloaded == true then
|
if already_downloaded == true then
|
||||||
print('File has already been downloaded in the past, skipping...')
|
print('Datei wurde bereits gedownloadet')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -83,7 +77,7 @@ function media_download:pre_process(msg, self)
|
|||||||
|
|
||||||
-- Getting file from the Telegram Cloud
|
-- Getting file from the Telegram Cloud
|
||||||
if not request then
|
if not request then
|
||||||
print('Download failed!')
|
print('Download fehlgeschlagen!')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -98,7 +92,7 @@ function media_download:pre_process(msg, self)
|
|||||||
local download_url = 'https://api.telegram.org/file/bot'..cred_data.bot_api_key..'/'..request.result.file_path
|
local download_url = 'https://api.telegram.org/file/bot'..cred_data.bot_api_key..'/'..request.result.file_path
|
||||||
local ok = media_download:download_to_file_permanently(download_url, file_path)
|
local ok = media_download:download_to_file_permanently(download_url, file_path)
|
||||||
if not ok then
|
if not ok then
|
||||||
print('Download failed!')
|
print('Download fehlgeschlagen!')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2,10 +2,6 @@
|
|||||||
|
|
||||||
local gfycat = {}
|
local gfycat = {}
|
||||||
|
|
||||||
local https = require('ssl.https')
|
|
||||||
local json = require('dkjson')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
gfycat.triggers = {
|
gfycat.triggers = {
|
||||||
"gfycat.com/([A-Za-z0-9-_-]+)"
|
"gfycat.com/([A-Za-z0-9-_-]+)"
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
local giphy = {}
|
local giphy = {}
|
||||||
|
|
||||||
local http = require('socket.http')
|
|
||||||
local URL = require('socket.url')
|
|
||||||
local JSON = require('dkjson')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
function giphy:init(config)
|
function giphy:init(config)
|
||||||
giphy.triggers = {
|
giphy.triggers = {
|
||||||
"/nil"
|
"/nil"
|
||||||
@ -26,7 +21,7 @@ function giphy:get_gifs(query)
|
|||||||
end
|
end
|
||||||
local res, code = http.request(url)
|
local res, code = http.request(url)
|
||||||
if code ~= 200 then return nil end
|
if code ~= 200 then return nil end
|
||||||
return JSON.decode(res).data
|
return json.decode(res).data
|
||||||
end
|
end
|
||||||
|
|
||||||
function giphy:inline_callback(inline_query, config, matches)
|
function giphy:inline_callback(inline_query, config, matches)
|
||||||
|
@ -1,13 +1,5 @@
|
|||||||
local github = {}
|
local github = {}
|
||||||
|
|
||||||
local http = require('socket.http')
|
|
||||||
local https = require('ssl.https')
|
|
||||||
local URL = require('socket.url')
|
|
||||||
local json = require('dkjson')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local bindings = require('miku.bindings')
|
|
||||||
local redis = (loadfile "./miku/redis.lua")()
|
|
||||||
|
|
||||||
function github:init(config)
|
function github:init(config)
|
||||||
github.triggers = {
|
github.triggers = {
|
||||||
"github.com/([A-Za-z0-9-_-.-._.]+)/([A-Za-z0-9-_-.-._.]+)/commit/([a-z0-9-]+)",
|
"github.com/([A-Za-z0-9-_-.-._.]+)/([A-Za-z0-9-_-.-._.]+)/commit/([a-z0-9-]+)",
|
||||||
|
302
miku/plugins/github_feed.lua
Normal file
302
miku/plugins/github_feed.lua
Normal file
@ -0,0 +1,302 @@
|
|||||||
|
local gh_feed = {}
|
||||||
|
|
||||||
|
gh_feed.command = 'gh <sub/del>'
|
||||||
|
|
||||||
|
function gh_feed:init(config)
|
||||||
|
if not cred_data.github_token then
|
||||||
|
print('Fehlender Key: github_token.')
|
||||||
|
print('github_feed.lua wird nicht aktiviert.')
|
||||||
|
return
|
||||||
|
elseif not cred_data.github_username then
|
||||||
|
print('Fehlender Key: github_username.')
|
||||||
|
print('github_feed.lua wird nicht aktiviert.')
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
gh_feed.triggers = {
|
||||||
|
"^/(gh) @(.*)$",
|
||||||
|
"^/gh$",
|
||||||
|
"^/gh (sub) ([A-Za-z0-9-_-.-._.]+/[A-Za-z0-9-_-.-._.]+) @(.*)$",
|
||||||
|
"^/gh (sub) ([A-Za-z0-9-_-.-._.]+/[A-Za-z0-9-_-.-._.]+)$",
|
||||||
|
"^/gh (del) (%d+) @(.*)$",
|
||||||
|
"^/gh (del) (%d+)$",
|
||||||
|
"^/gh (del)",
|
||||||
|
"^/gh (sync)$"
|
||||||
|
}
|
||||||
|
gh_feed.doc = [[*
|
||||||
|
]]..config.cmd_pat..[[gh* _@[Kanalname]_: GitHub-Abonnements anzeigen
|
||||||
|
*]]..config.cmd_pat..[[gh* _sub_ _<URL>_ _@[Kanalname]_: Diese Repo abonnieren
|
||||||
|
*]]..config.cmd_pat..[[gh* _del_ _<#>_ _@[Kanalname]_: Diese Repo deabonnieren
|
||||||
|
*]]..config.cmd_pat..[[gh* _sync_: Repos syncen (nur Superuser)
|
||||||
|
Der Kanalname ist optional]]
|
||||||
|
end
|
||||||
|
|
||||||
|
local token = cred_data.github_token -- get a token here: https://github.com/settings/tokens/new (you don't need any scopes)
|
||||||
|
local BASE_URL = 'https://api.github.com/repos'
|
||||||
|
|
||||||
|
function gh_feed_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 'github:' .. id .. ex
|
||||||
|
end
|
||||||
|
|
||||||
|
function gh_feed_check_modified(repo, cur_etag, last_date)
|
||||||
|
local url = BASE_URL..'/'..repo
|
||||||
|
local response_body = {}
|
||||||
|
local request_constructor = {
|
||||||
|
url = url,
|
||||||
|
method = "HEAD",
|
||||||
|
redirect = false,
|
||||||
|
headers = {
|
||||||
|
Authorization = 'token '..token,
|
||||||
|
["If-None-Match"] = cur_etag
|
||||||
|
}
|
||||||
|
}
|
||||||
|
local ok, response_code = https.request(request_constructor)
|
||||||
|
if not ok then return nil end
|
||||||
|
if response_code == 304 then return true end
|
||||||
|
|
||||||
|
local url = BASE_URL..'/'..repo..'/commits?since='..last_date
|
||||||
|
local response_body = {}
|
||||||
|
local request_constructor = {
|
||||||
|
url = url,
|
||||||
|
method = "GET",
|
||||||
|
sink = ltn12.sink.table(response_body),
|
||||||
|
headers = {
|
||||||
|
Authorization = 'token '..token
|
||||||
|
}
|
||||||
|
}
|
||||||
|
local ok, response_code, response_headers = https.request(request_constructor)
|
||||||
|
if not response_headers then return nil end
|
||||||
|
local data = json.decode(table.concat(response_body))
|
||||||
|
return false, data, response_headers.etag
|
||||||
|
end
|
||||||
|
|
||||||
|
function gh_feed:check_repo(repo)
|
||||||
|
local url = BASE_URL..'/'..repo
|
||||||
|
local response_body = {}
|
||||||
|
local request_constructor = {
|
||||||
|
url = url,
|
||||||
|
method = "GET",
|
||||||
|
sink = ltn12.sink.table(response_body),
|
||||||
|
headers = {
|
||||||
|
Authorization = 'token '..token
|
||||||
|
}
|
||||||
|
}
|
||||||
|
local ok, response_code, response_headers = https.request(request_constructor)
|
||||||
|
if not ok then return nil end
|
||||||
|
return json.decode(table.concat(response_body)), response_headers.etag
|
||||||
|
end
|
||||||
|
|
||||||
|
function gh_feed:subscribe(id, repo)
|
||||||
|
local lasthash = gh_feed_get_base_redis(repo, "last_commit")
|
||||||
|
local lastetag = gh_feed_get_base_redis(repo, "etag")
|
||||||
|
local lastdate = gh_feed_get_base_redis(repo, "date")
|
||||||
|
local lhash = gh_feed_get_base_redis(repo, "subs")
|
||||||
|
local uhash = gh_feed_get_base_redis(id)
|
||||||
|
|
||||||
|
if redis:sismember(uhash, repo) then
|
||||||
|
return "Du hast `"..repo.."` bereits abonniert."
|
||||||
|
end
|
||||||
|
|
||||||
|
local data, etag = gh_feed:check_repo(repo)
|
||||||
|
if not data or not data.full_name then return 'Diese Repo gibt es nicht!' end
|
||||||
|
if not etag then return 'Ein Fehler ist aufgetreten.' end
|
||||||
|
|
||||||
|
local last_commit = ""
|
||||||
|
local pushed_at = data.pushed_at
|
||||||
|
local name = data.full_name
|
||||||
|
|
||||||
|
redis:set(lasthash, last_commit)
|
||||||
|
redis:set(lastdate, pushed_at)
|
||||||
|
redis:set(lastetag, etag)
|
||||||
|
redis:sadd(lhash, id)
|
||||||
|
redis:sadd(uhash, repo)
|
||||||
|
|
||||||
|
return "_"..utilities.md_escape(name) .."_ abonniert!"
|
||||||
|
end
|
||||||
|
|
||||||
|
function gh_feed:unsubscribe(id, n)
|
||||||
|
if #n > 3 then
|
||||||
|
return "Du kannst nicht mehr als drei Repos abonnieren!"
|
||||||
|
end
|
||||||
|
n = tonumber(n)
|
||||||
|
|
||||||
|
local uhash = gh_feed_get_base_redis(id)
|
||||||
|
local subs = redis:smembers(uhash)
|
||||||
|
if n < 1 or n > #subs then
|
||||||
|
return "Abonnement-ID zu hoch!"
|
||||||
|
end
|
||||||
|
local sub = subs[n]
|
||||||
|
local lhash = gh_feed_get_base_redis(sub, "subs")
|
||||||
|
|
||||||
|
redis:srem(uhash, sub)
|
||||||
|
redis:srem(lhash, id)
|
||||||
|
|
||||||
|
local left = redis:smembers(lhash)
|
||||||
|
if #left < 1 then -- no one subscribed, remove it
|
||||||
|
local lastetag = gh_feed_get_base_redis(sub, "etag")
|
||||||
|
local lastdate = gh_feed_get_base_redis(sub, "date")
|
||||||
|
local lasthash = gh_feed_get_base_redis(sub, "last_commit")
|
||||||
|
redis:del(lastetag)
|
||||||
|
redis:del(lasthash)
|
||||||
|
redis:del(lastdate)
|
||||||
|
end
|
||||||
|
|
||||||
|
return "Du hast `"..utilities.md_escape(sub).."` deabonniert."
|
||||||
|
end
|
||||||
|
|
||||||
|
function gh_feed:print_subs(id, chat_name)
|
||||||
|
local uhash = gh_feed_get_base_redis(id)
|
||||||
|
local subs = redis:smembers(uhash)
|
||||||
|
if not subs[1] then
|
||||||
|
return 'Keine GitHub-Repos abonniert!'
|
||||||
|
end
|
||||||
|
local keyboard = '{"keyboard":[['
|
||||||
|
local keyboard_buttons = ''
|
||||||
|
local text = '*'..chat_name..'* hat abonniert:\n---------\n'
|
||||||
|
for k,v in pairs(subs) do
|
||||||
|
text = text .. k .. ") ["..v.."](https://github.com/"..v..')\n'
|
||||||
|
if k == #subs then
|
||||||
|
keyboard_buttons = keyboard_buttons..'{"text":"/gh del '..k..'"}'
|
||||||
|
break;
|
||||||
|
end
|
||||||
|
keyboard_buttons = keyboard_buttons..'{"text":"/gh del '..k..'"},'
|
||||||
|
end
|
||||||
|
local keyboard = keyboard..keyboard_buttons..']], "one_time_keyboard":true, "selective":true, "resize_keyboard":true}'
|
||||||
|
return text, keyboard
|
||||||
|
end
|
||||||
|
|
||||||
|
function gh_feed:action(msg, config, matches)
|
||||||
|
local id = msg.from.id
|
||||||
|
if msg.chat.type == 'group' or msg.chat.type == 'supergroup' then
|
||||||
|
id = msg.chat.id
|
||||||
|
end
|
||||||
|
|
||||||
|
-- For channels
|
||||||
|
if matches[1] == 'sub' and matches[2] and matches[3] then
|
||||||
|
if msg.from.id ~= config.admin then
|
||||||
|
utilities.send_reply(self, msg, config.errors.sudo)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local id = '@'..matches[3]
|
||||||
|
local result = utilities.get_chat_info(self, id)
|
||||||
|
if not result then
|
||||||
|
utilities.send_reply(self, msg, 'Diesen Kanal gibt es nicht!')
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local output = gh_feed:subscribe(id, matches[2])
|
||||||
|
utilities.send_reply(self, msg, output, true)
|
||||||
|
return
|
||||||
|
elseif matches[1] == 'del' and matches[2] and matches[3] then
|
||||||
|
if msg.from.id ~= config.admin then
|
||||||
|
utilities.send_reply(self, msg, config.errors.sudo)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local id = '@'..matches[3]
|
||||||
|
local result = utilities.get_chat_info(self, id)
|
||||||
|
if not result then
|
||||||
|
utilities.send_reply(self, msg, 'Diesen Kanal gibt es nicht!')
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local output = gh_feed:unsubscribe(id, matches[2])
|
||||||
|
utilities.send_reply(self, msg, output, true)
|
||||||
|
return
|
||||||
|
elseif matches[1] == 'gh' and matches[2] then
|
||||||
|
local id = '@'..matches[2]
|
||||||
|
local result = utilities.get_chat_info(self, id)
|
||||||
|
if not result then
|
||||||
|
utilities.send_reply(self, msg, 'Diesen Kanal gibt es nicht!')
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local chat_name = result.result.title
|
||||||
|
local output = gh_feed:print_subs(id, chat_name)
|
||||||
|
utilities.send_reply(self, msg, output, true)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if msg.chat.type == 'group' or msg.chat.type == 'supergroup' then
|
||||||
|
chat_name = msg.chat.title
|
||||||
|
else
|
||||||
|
chat_name = msg.chat.first_name
|
||||||
|
end
|
||||||
|
|
||||||
|
if matches[1] == 'sub' and matches[2] then
|
||||||
|
if msg.from.id ~= config.admin then
|
||||||
|
utilities.send_reply(self, msg, config.errors.sudo)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local output = gh_feed:subscribe(id, matches[2])
|
||||||
|
utilities.send_reply(self, msg, output, true)
|
||||||
|
return
|
||||||
|
elseif matches[1] == 'del' and matches[2] then
|
||||||
|
if msg.from.id ~= config.admin then
|
||||||
|
utilities.send_reply(self, msg, config.errors.sudo)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local output = gh_feed:unsubscribe(id, matches[2])
|
||||||
|
utilities.send_reply(self, msg, output, true, '{"hide_keyboard":true}')
|
||||||
|
return
|
||||||
|
elseif matches[1] == 'del' and not matches[2] then
|
||||||
|
local list_subs, keyboard = gh_feed:print_subs(id, chat_name)
|
||||||
|
utilities.send_reply(self, msg, list_subs, true, keyboard)
|
||||||
|
return
|
||||||
|
elseif matches[1] == 'sync' then
|
||||||
|
if msg.from.id ~= config.admin then
|
||||||
|
utilities.send_reply(self, msg, config.errors.sudo)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
gh_feed:cron(self)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local output = gh_feed:print_subs(id, chat_name)
|
||||||
|
utilities.send_reply(self, msg, output, true)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
function gh_feed:cron(self_plz)
|
||||||
|
if not self.BASE_URL then
|
||||||
|
self = self_plz
|
||||||
|
end
|
||||||
|
local keys = redis:keys(gh_feed_get_base_redis("*", "subs"))
|
||||||
|
for k,v in pairs(keys) do
|
||||||
|
local repo = string.match(v, "github:(.+):subs")
|
||||||
|
print('GitHub: '..repo)
|
||||||
|
local cur_etag = redis:get(gh_feed_get_base_redis(repo, "etag"))
|
||||||
|
local last_date = redis:get(gh_feed_get_base_redis(repo, "date"))
|
||||||
|
local was_not_modified, data, last_etag = gh_feed_check_modified(repo, cur_etag, last_date)
|
||||||
|
if not was_not_modified then
|
||||||
|
if not data or not last_etag then return end
|
||||||
|
-- When there are new commits
|
||||||
|
local last_commit = redis:get(gh_feed_get_base_redis(repo, "last_commit"))
|
||||||
|
text = ''
|
||||||
|
for n in ipairs(data) do
|
||||||
|
if data[n].sha ~= last_commit then
|
||||||
|
local sha = data[n].sha
|
||||||
|
local author = data[n].commit.author.name
|
||||||
|
local message = utilities.md_escape(data[n].commit.message)
|
||||||
|
local link = data[n].html_url
|
||||||
|
text = text..'\n#GitHub: `'..repo..'@'..sha..'` von *'..author..'*:\n'..message..'\n[GitHub aufrufen]('..link..')\n'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if text ~= '' then
|
||||||
|
local last_commit = data[1].sha
|
||||||
|
local last_date = data[1].commit.author.date
|
||||||
|
redis:set(gh_feed_get_base_redis(repo, "last_commit"), last_commit)
|
||||||
|
redis:set(gh_feed_get_base_redis(repo, "etag"), last_etag)
|
||||||
|
redis:set(gh_feed_get_base_redis(repo, "date"), last_date)
|
||||||
|
for k2, receiver in pairs(redis:smembers(v)) do
|
||||||
|
utilities.send_message(self, receiver, text, true, nil, true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return gh_feed
|
@ -1,19 +1,17 @@
|
|||||||
local googl = {}
|
local googl = {}
|
||||||
|
|
||||||
local https = require('ssl.https')
|
|
||||||
local json = require('dkjson')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
function googl:init(config)
|
function googl:init(config)
|
||||||
if not cred_data.google_apikey then
|
if not cred_data.google_apikey then
|
||||||
print('Missing config value: google_apikey.')
|
print('Fehlender Key: google_apikey.')
|
||||||
print('googl.lua will not be enabled.')
|
print('googl.lua wird nicht aktiviert.')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
googl.triggers = {
|
googl.triggers = {
|
||||||
"goo.gl/([A-Za-z0-9-_-/-/]+)"
|
"goo.gl/([A-Za-z0-9-_-/-/]+)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
googl.inline_triggers = googl.triggers
|
||||||
end
|
end
|
||||||
|
|
||||||
local BASE_URL = 'https://www.googleapis.com/urlshortener/v1'
|
local BASE_URL = 'https://www.googleapis.com/urlshortener/v1'
|
||||||
@ -24,11 +22,20 @@ local makeOurDate = function(dateString)
|
|||||||
return day..'.'..month..'.'..year
|
return day..'.'..month..'.'..year
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function googl:inline_callback(inline_query, config, matches)
|
||||||
|
local shorturl = matches[1]
|
||||||
|
local text, longUrl = googl:send_googl_info(shorturl)
|
||||||
|
if not longUrl then return end
|
||||||
|
|
||||||
|
local results = '[{"type":"article","id":"'..math.random(100000000000000000)..'","title":"Verlängerte URL","description":"'..longUrl..'","url":"'..longUrl..'","thumb_url":"https://anditest.perseus.uberspace.de/inlineQuerys/generic/internet.jpg","thumb_width":165,"thumb_height":150,"hide_url":true,"input_message_content":{"message_text":"'..text..'"}}]'
|
||||||
|
utilities.answer_inline_query(self, inline_query, results, 1)
|
||||||
|
end
|
||||||
|
|
||||||
function googl:send_googl_info (shorturl)
|
function googl:send_googl_info (shorturl)
|
||||||
local apikey = cred_data.google_apikey
|
local apikey = cred_data.google_apikey
|
||||||
local url = BASE_URL..'/url?key='..apikey..'&shortUrl=http://goo.gl/'..shorturl..'&projection=FULL&fields=longUrl,created,analytics(allTime(shortUrlClicks))'
|
local url = BASE_URL..'/url?key='..apikey..'&shortUrl=http://goo.gl/'..shorturl..'&projection=FULL&fields=longUrl,created,analytics(allTime(shortUrlClicks))'
|
||||||
local res,code = https.request(url)
|
local res,code = https.request(url)
|
||||||
if code ~= 200 then return "HTTP-FEHLER" end
|
if code ~= 200 then return nil end
|
||||||
local data = json.decode(res)
|
local data = json.decode(res)
|
||||||
|
|
||||||
local longUrl = data.longUrl
|
local longUrl = data.longUrl
|
||||||
@ -36,12 +43,14 @@ function googl:send_googl_info (shorturl)
|
|||||||
local created = makeOurDate(data.created)
|
local created = makeOurDate(data.created)
|
||||||
local text = longUrl..'\n'..shortUrlClicks..' mal geklickt (erstellt am '..created..')'
|
local text = longUrl..'\n'..shortUrlClicks..' mal geklickt (erstellt am '..created..')'
|
||||||
|
|
||||||
return text
|
return text, longUrl
|
||||||
end
|
end
|
||||||
|
|
||||||
function googl:action(msg, config, matches)
|
function googl:action(msg, config, matches)
|
||||||
local shorturl = matches[1]
|
local shorturl = matches[1]
|
||||||
utilities.send_reply(self, msg, googl:send_googl_info(shorturl))
|
local text = googl:send_googl_info(shorturl)
|
||||||
|
if not text then utilities.send_reply(self, msg, config.errors.connection) return end
|
||||||
|
utilities.send_reply(self, msg, text)
|
||||||
end
|
end
|
||||||
|
|
||||||
return googl
|
return googl
|
@ -1,8 +1,5 @@
|
|||||||
local gps = {}
|
local gps = {}
|
||||||
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local bindings = require('miku.bindings')
|
|
||||||
|
|
||||||
gps.command = 'gps <Breitengrad>,<Längengrad>'
|
gps.command = 'gps <Breitengrad>,<Längengrad>'
|
||||||
|
|
||||||
function gps:init(config)
|
function gps:init(config)
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
local help = {}
|
local help = {}
|
||||||
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
local help_text
|
local help_text
|
||||||
|
|
||||||
function help:init(config)
|
function help:init(config)
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
local id = {}
|
local id = {}
|
||||||
|
|
||||||
local redis = (loadfile "./miku/redis.lua")()
|
|
||||||
local bindings = require('miku.bindings')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
id.command = 'id'
|
id.command = 'id'
|
||||||
|
|
||||||
function id:init(config)
|
function id:init(config)
|
||||||
@ -104,7 +100,7 @@ function id:action(msg)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
local result = id:get_member_count(self, msg, chat_id)
|
local result = id:get_member_count(self, msg, chat_id)
|
||||||
local member_count = result.result - 1 -- minus the bot
|
local member_count = result.result
|
||||||
if member_count == 1 then
|
if member_count == 1 then
|
||||||
member_count = 'ist *1 Mitglied'
|
member_count = 'ist *1 Mitglied'
|
||||||
else
|
else
|
||||||
@ -115,12 +111,12 @@ function id:action(msg)
|
|||||||
if table.contains(admins, tostring(user.id)) then
|
if table.contains(admins, tostring(user.id)) then
|
||||||
text = text..'*'..user.name..'* `['..user.id..']` _Administrator_\n'
|
text = text..'*'..user.name..'* `['..user.id..']` _Administrator_\n'
|
||||||
elseif tostring(creator_id) == user.id then
|
elseif tostring(creator_id) == user.id then
|
||||||
text = text..'*'..user.name..'* `['..user.id..']` _Gruppenersteller_\n'
|
text = text..'*'..user.name..'* `['..user.id..']` _Gründer_\n'
|
||||||
else
|
else
|
||||||
text = text..'*'..user.name..'* `['..user.id..']`\n'
|
text = text..'*'..user.name..'* `['..user.id..']`\n'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
utilities.send_reply(self, msg, text, true)
|
utilities.send_reply(self, msg, text..'_(Bots sind nicht gelistet)_', true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
local images = {}
|
local images = {}
|
||||||
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
images.triggers = {
|
images.triggers = {
|
||||||
"(https?://[%w-_%%%.%?%.:,/%+=~&%[%]]+%.[Pp][Nn][Gg])$",
|
"(https?://[%w-_%%%.%?%.:,/%+=~&%[%]]+%.[Pp][Nn][Gg])$",
|
||||||
"(https?://[%w-_%%%.%?%.:,/%+=~&%[%]]+%.[Jj][Pp][Ee]?[Gg])$"
|
"(https?://[%w-_%%%.%?%.:,/%+=~&%[%]]+%.[Jj][Pp][Ee]?[Gg])$"
|
||||||
|
@ -1,18 +1,12 @@
|
|||||||
local imdb = {}
|
local imdb = {}
|
||||||
|
|
||||||
local HTTP = require('socket.http')
|
|
||||||
local URL = require('socket.url')
|
|
||||||
local JSON = require('dkjson')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local bindings = require('miku.bindings')
|
|
||||||
|
|
||||||
imdb.command = 'imdb <query>'
|
imdb.command = 'imdb <query>'
|
||||||
|
|
||||||
function imdb:init(config)
|
function imdb:init(config)
|
||||||
imdb.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('imdb', true).table
|
imdb.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('[Ii][Mm][Dd][Bb]', true).table
|
||||||
imdb.doc = [[*
|
imdb.doc = [[*
|
||||||
]]..config.cmd_pat..[[imdb* _<Film>_
|
]]..config.cmd_pat..[[imdb* _<Film>_
|
||||||
Sucht _Film_ bei IMDB]]
|
Sucht einen _Film_ bei IMDB]]
|
||||||
end
|
end
|
||||||
|
|
||||||
function imdb:action(msg, config)
|
function imdb:action(msg, config)
|
||||||
@ -29,13 +23,13 @@ function imdb:action(msg, config)
|
|||||||
|
|
||||||
local url = 'http://www.omdbapi.com/?t=' .. URL.escape(input)
|
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
|
if res ~= 200 then
|
||||||
utilities.send_reply(self, msg, config.errors.connection)
|
utilities.send_reply(self, msg, config.errors.connection)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local jdat = JSON.decode(jstr)
|
local jdat = json.decode(jstr)
|
||||||
|
|
||||||
if jdat.Response ~= 'True' then
|
if jdat.Response ~= 'True' then
|
||||||
utilities.send_reply(self, msg, config.errors.results)
|
utilities.send_reply(self, msg, config.errors.results)
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
local imgblacklist = {}
|
local imgblacklist = {}
|
||||||
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local redis = (loadfile "./miku/redis.lua")()
|
|
||||||
|
|
||||||
imgblacklist.command = 'imgblacklist'
|
imgblacklist.command = 'imgblacklist'
|
||||||
|
|
||||||
function imgblacklist:init(config)
|
function imgblacklist:init(config)
|
||||||
imgblacklist.triggers = {
|
imgblacklist.triggers = {
|
||||||
"^/imgblacklist show$",
|
"^/[Ii][Mm][Gg][Bb][Ll][Aa][Cc][Kk][Ll][Ii][Ss][Tt] show$",
|
||||||
"^/imgblacklist (add) (.*)$",
|
"^/[Ii][Mm][Gg][Bb][Ll][Aa][Cc][Kk][Ll][Ii][Ss][Tt] (add) (.*)$",
|
||||||
"^/imgblacklist (remove) (.*)$"
|
"^/[Ii][Mm][Gg][Bb][Ll][Aa][Cc][Kk][Ll][Ii][Ss][Tt] (remove) (.*)$"
|
||||||
}
|
}
|
||||||
imgblacklist.doc = [[*
|
imgblacklist.doc = [[*
|
||||||
]]..config.cmd_pat..[[imgblacklist* _show_: Zeige Blacklist
|
]]..config.cmd_pat..[[imgblacklist* _show_: Zeige Blacklist
|
||||||
@ -32,7 +29,7 @@ function imgblacklist:show_blacklist()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function imgblacklist:add_blacklist(word)
|
function imgblacklist:add_blacklist(word)
|
||||||
print('Blacklisting '..word..' - saving to redis set telegram:img_blacklist')
|
print('Blackliste '..word..' - Speicher in Redis Hash telegram:img_blacklist')
|
||||||
if redis:sismember("telegram:img_blacklist", word) == true then
|
if redis:sismember("telegram:img_blacklist", word) == true then
|
||||||
return '"'..word..'" steht schon auf der Blacklist.'
|
return '"'..word..'" steht schon auf der Blacklist.'
|
||||||
else
|
else
|
||||||
@ -42,7 +39,7 @@ function imgblacklist:add_blacklist(word)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function imgblacklist:remove_blacklist(word)
|
function imgblacklist:remove_blacklist(word)
|
||||||
print('De-blacklisting '..word..' - removing from redis set telegram:img_blacklist')
|
print('Deblackliste '..word..' - Lösche aus Redis Hash telegram:img_blacklist')
|
||||||
if redis:sismember("telegram:img_blacklist", word) == true then
|
if redis:sismember("telegram:img_blacklist", word) == true then
|
||||||
redis:srem("telegram:img_blacklist", word)
|
redis:srem("telegram:img_blacklist", word)
|
||||||
return '"'..word..'" erfolgreich von der Blacklist gelöscht!'
|
return '"'..word..'" erfolgreich von der Blacklist gelöscht!'
|
||||||
|
@ -1,19 +1,14 @@
|
|||||||
local imgur = {}
|
local imgur = {}
|
||||||
|
|
||||||
local https = require('ssl.https')
|
|
||||||
local json = require('dkjson')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
function imgur:init(config)
|
function imgur:init(config)
|
||||||
if not cred_data.imgur_client_id then
|
if not cred_data.imgur_client_id then
|
||||||
print('Missing config value: imgur_client_id.')
|
print('Fehlender Key: imgur_client_id.')
|
||||||
print('imgur.lua will not be enabled.')
|
print('imgur.lua wird nicht aktiviert.')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
imgur.triggers = {
|
imgur.triggers = {
|
||||||
"imgur.com/([A-Za-z0-9]+).gifv",
|
"imgur.com/([A-Za-z0-9]+)"
|
||||||
"https?://imgur.com/([A-Za-z0-9]+)"
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,14 +1,9 @@
|
|||||||
local ip_info = {}
|
local ip_info = {}
|
||||||
|
|
||||||
local http = require('socket.http')
|
|
||||||
local json = require('dkjson')
|
|
||||||
local URL = require('socket.url')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
function ip_info:init(config)
|
function ip_info:init(config)
|
||||||
ip_info.triggers = {
|
ip_info.triggers = {
|
||||||
"^/ip (.*)$",
|
"^/[Ii][Pp] (.*)$",
|
||||||
"^/dns (.*)$"
|
"^/[Dd][Nn][Ss] (.*)$"
|
||||||
}
|
}
|
||||||
|
|
||||||
ip_info.doc = [[*
|
ip_info.doc = [[*
|
||||||
|
@ -1,11 +1,5 @@
|
|||||||
local isup = {}
|
local isup = {}
|
||||||
|
|
||||||
local http = require('socket.http')
|
|
||||||
local https = require('ssl.https')
|
|
||||||
local socket = require('socket')
|
|
||||||
local URL = require('socket.url')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
function isup:init(config)
|
function isup:init(config)
|
||||||
isup.triggers = {
|
isup.triggers = {
|
||||||
"^/[Ii][Ss][Uu][Pp] (.*)$",
|
"^/[Ii][Ss][Uu][Pp] (.*)$",
|
||||||
@ -17,7 +11,7 @@ function isup:init(config)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function isup:is_up_socket(ip, port)
|
function isup:is_up_socket(ip, port)
|
||||||
print('Connect to', ip, port)
|
print('Verbinde zu ', ip, port)
|
||||||
local c = socket.try(socket.tcp())
|
local c = socket.try(socket.tcp())
|
||||||
c:settimeout(3)
|
c:settimeout(3)
|
||||||
local conn = c:connect(ip, port)
|
local conn = c:connect(ip, port)
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
local leave_group = {}
|
local leave_group = {}
|
||||||
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local bindings = require('miku.bindings')
|
|
||||||
|
|
||||||
leave_group.triggers = {
|
leave_group.triggers = {
|
||||||
'/nil'
|
'/nil'
|
||||||
}
|
}
|
||||||
@ -15,7 +12,7 @@ function leave_group:check_for_admin(msg, self, config)
|
|||||||
user_id = config.admin
|
user_id = config.admin
|
||||||
} )
|
} )
|
||||||
if not result.ok then
|
if not result.ok then
|
||||||
print('Konnte nicht prüfen, ob Admin in Gruppe ist! Verlasse sie sicherheitshalber...')
|
print('Konnte nicht prüfen, ob Admin in Gruppe ist. Verlasse Gruppe.')
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
if result.result.status ~= "member" and result.result.status ~= "administrator" and result.result.status ~= "creator" then
|
if result.result.status ~= "member" and result.result.status ~= "administrator" and result.result.status ~= "creator" then
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
local loc_manager = {}
|
local loc_manager = {}
|
||||||
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local redis = (loadfile "./miku/redis.lua")()
|
|
||||||
|
|
||||||
function loc_manager:init(config)
|
function loc_manager:init(config)
|
||||||
loc_manager.triggers = {
|
loc_manager.triggers = {
|
||||||
"^/[Ll][Oo][Cc][Aa][Tt][Ii][Oo][Nn] (set) (.*)$",
|
"^/[Ll][Oo][Cc][Aa][Tt][Ii][Oo][Nn] (set) (.*)$",
|
||||||
@ -24,7 +21,7 @@ function loc_manager:set_location(user_id, location)
|
|||||||
if set_location == location then
|
if set_location == location then
|
||||||
return 'Dieser Ort wurde bereits gesetzt.'
|
return 'Dieser Ort wurde bereits gesetzt.'
|
||||||
else
|
else
|
||||||
print('Setting location in redis hash '..hash..' to location')
|
print('Setze location in redis hash '..hash..' zu '..location)
|
||||||
redis:hset(hash, 'location', location)
|
redis:hset(hash, 'location', location)
|
||||||
return 'Dein Wohnort wurde auf *'..location..'* festgelegt.'
|
return 'Dein Wohnort wurde auf *'..location..'* festgelegt.'
|
||||||
end
|
end
|
||||||
@ -36,7 +33,7 @@ function loc_manager:del_location(user_id)
|
|||||||
if not set_location then
|
if not set_location then
|
||||||
return 'Du hast keinen Ort gesetzt'
|
return 'Du hast keinen Ort gesetzt'
|
||||||
else
|
else
|
||||||
print('Setting location in redis hash '..hash..' to false')
|
print('Setze location in redis hash '..hash..' auf false')
|
||||||
-- We set the location to false, because deleting the value blocks redis for a few milliseconds
|
-- We set the location to false, because deleting the value blocks redis for a few milliseconds
|
||||||
redis:hset(hash, 'location', false)
|
redis:hset(hash, 'location', false)
|
||||||
return 'Dein Wohnort *'..set_location..'* wurde gelöscht!'
|
return 'Dein Wohnort *'..set_location..'* wurde gelöscht!'
|
||||||
|
@ -1,17 +1,13 @@
|
|||||||
local lyrics = {}
|
local lyrics = {}
|
||||||
|
|
||||||
local http = require('socket.http')
|
|
||||||
local json = require('dkjson')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
function lyrics:init(config)
|
function lyrics:init(config)
|
||||||
if not cred_data.lyricsnmusic_apikey then
|
if not cred_data.lyricsnmusic_apikey then
|
||||||
print('Missing config value: lyricsnmusic_apikey.')
|
print('Fehlender Key: lyricsnmusic_apikey.')
|
||||||
print('lyrics.lua will not be enabled.')
|
print('lyrics.lua wird nicht aktiviert.')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
lyrics.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('lyrics', true).table
|
lyrics.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('[Ll][Yy][Rr][Ii][Cc][Ss]', true).table
|
||||||
lyrics.doc = [[*
|
lyrics.doc = [[*
|
||||||
]]..config.cmd_pat..[[lyrics* _<Lied>_: Postet Liedertext]]
|
]]..config.cmd_pat..[[lyrics* _<Lied>_: Postet Liedertext]]
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
local muschel = {}
|
local muschel = {}
|
||||||
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
muschel.triggers = {
|
muschel.triggers = {
|
||||||
"^[Mm][Aa][Gg][Ii][Ss][Cc][Hh][Ee] [Mm][Ii][Ee][Ss][Mm][Uu][Ss][Cc][Hh][Ee][Ll] (.*)$"
|
"^[Mm][Aa][Gg][Ii][Ss][Cc][Hh][Ee] [Mm][Ii][Ee][Ss][Mm][Uu][Ss][Cc][Hh][Ee][Ll] (.*)$"
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
local media = {}
|
local media = {}
|
||||||
|
|
||||||
local HTTP = require('socket.http')
|
mimetype = (loadfile "./miku/mimetype.lua")()
|
||||||
local HTTPS = require('ssl.https')
|
|
||||||
local redis = (loadfile "./miku/redis.lua")()
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local mimetype = (loadfile "./miku/mimetype.lua")()
|
|
||||||
|
|
||||||
media.triggers = {
|
media.triggers = {
|
||||||
"(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(gif))$",
|
"(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(gif))$",
|
||||||
"^(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(mp4))$",
|
"(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(mp4))$",
|
||||||
"(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(pdf))$",
|
"(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(pdf))$",
|
||||||
"(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(ogg))$",
|
"(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(ogg))$",
|
||||||
"(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(zip))$",
|
"(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(zip))$",
|
||||||
@ -18,12 +14,12 @@ media.triggers = {
|
|||||||
"(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(rar))$",
|
"(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(rar))$",
|
||||||
"(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(wmv))$",
|
"(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(wmv))$",
|
||||||
"(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(doc))$",
|
"(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(doc))$",
|
||||||
"^(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(avi))$",
|
"(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(avi))$",
|
||||||
"(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(wav))$",
|
"(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(wav))$",
|
||||||
"(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(apk))$",
|
"(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(apk))$",
|
||||||
"(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(ipa))$",
|
"(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(ipa))$",
|
||||||
"(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(webm))$",
|
"(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(webm))$",
|
||||||
"^(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(ogv))$",
|
"(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(ogv))$",
|
||||||
"(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(webp))$"
|
"(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(webp))$"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,16 +41,19 @@ function media:action(msg)
|
|||||||
if not file then return end
|
if not file then return end
|
||||||
|
|
||||||
if ext == 'gif' then
|
if ext == 'gif' then
|
||||||
print('send gif')
|
print('Sende GIF')
|
||||||
result = utilities.send_document(self, receiver, file, nil, msg.message_id)
|
result = utilities.send_document(self, receiver, file, nil, msg.message_id)
|
||||||
|
elseif ext == 'ogg' then
|
||||||
|
print('Sende OGG')
|
||||||
|
result = utilities.send_voice(self, receiver, file, nil, msg.message_id)
|
||||||
elseif mime_type == 'audio' then
|
elseif mime_type == 'audio' then
|
||||||
print('send_audio')
|
print('Sende Audio')
|
||||||
result = utilities.send_audio(self, receiver, file, nil, msg.message_id)
|
result = utilities.send_audio(self, receiver, file, nil, msg.message_id)
|
||||||
elseif mime_type == 'video' then
|
elseif mime_type == 'video' then
|
||||||
print('send_video')
|
print('Sende Video')
|
||||||
result = utilities.send_video(self, receiver, file, nil, msg.message_id)
|
result = utilities.send_video(self, receiver, file, nil, msg.message_id)
|
||||||
else
|
else
|
||||||
print('send_file')
|
print('Sende Datei')
|
||||||
result = utilities.send_document(self, receiver, file, nil, msg.message_id)
|
result = utilities.send_document(self, receiver, file, nil, msg.message_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,11 +1,5 @@
|
|||||||
local mc_server = {}
|
local mc_server = {}
|
||||||
|
|
||||||
local http = require('socket.http')
|
|
||||||
local ltn12 = require('ltn12')
|
|
||||||
local URL = require('socket.url')
|
|
||||||
local json = require('dkjson')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
function mc_server:init(config)
|
function mc_server:init(config)
|
||||||
mc_server.triggers = {
|
mc_server.triggers = {
|
||||||
"^/mine (.*)$"
|
"^/mine (.*)$"
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
local mc_skin = {}
|
local mc_skin = {}
|
||||||
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
function mc_skin:init(config)
|
function mc_skin:init(config)
|
||||||
mc_skin.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('skin', true).table
|
mc_skin.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('[Ss][Kk][Ii][Nn]', true).table
|
||||||
mc_skin.doc = [[*
|
mc_skin.doc = [[*
|
||||||
]]..config.cmd_pat..[[skin* _<Username>_: Sendet Minecraft-Skin dieses Nutzers]]
|
]]..config.cmd_pat..[[skin* _<Username>_: Sendet Minecraft-Skin dieses Nutzers]]
|
||||||
end
|
end
|
||||||
@ -24,7 +22,7 @@ function mc_skin:action(msg, config, matches)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local url = 'http://www.minecraft-skin-viewer.net/3d.php?layers=true&aa=true&a=0&w=330&wt=10&abg=330&abd=40&ajg=340&ajd=20&ratio=13&format=png&login='..input..'&headOnly=false&displayHairs=true&randomness=341.png'
|
local url = 'http://www.minecraft-skin-viewer.net/3d.php?layers=true&aa=true&a=0&w=330&wt=10&abg=330&abd=40&ajg=340&ajd=20&ratio=13&format=png&login='..input..'&headOnly=false&displayHairs=true&randomness=341.png'
|
||||||
local file = download_to_file(url)
|
local file = download_to_file(url, input..'.png')
|
||||||
utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id)
|
utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,21 +1,17 @@
|
|||||||
local mal = {}
|
local mal = {}
|
||||||
|
|
||||||
local http = require('socket.http')
|
|
||||||
local URL = require('socket.url')
|
|
||||||
local xml = require("xml")
|
local xml = require("xml")
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local bindings = require('miku.bindings')
|
|
||||||
|
|
||||||
mal.command = 'anime <Anime>, /manga <Manga>'
|
mal.command = 'anime <Anime>, /manga <Manga>'
|
||||||
|
|
||||||
function mal:init(config)
|
function mal:init(config)
|
||||||
if not cred_data.mal_username then
|
if not cred_data.mal_username then
|
||||||
print('Missing config value: mal_username.')
|
print('Fehlender Key: mal_username.')
|
||||||
print('myanimelist.lua will not be enabled.')
|
print('myanimelist.lua wird nicht aktiviert.')
|
||||||
return
|
return
|
||||||
elseif not cred_data.mal_pw then
|
elseif not cred_data.mal_pw then
|
||||||
print('Missing config value: mal_pw.')
|
print('Fehlender Key: mal_pw.')
|
||||||
print('myanimelist.lua will not be enabled.')
|
print('myanimelist.lua wird nicht aktiviert.')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -3,13 +3,10 @@
|
|||||||
|
|
||||||
local notify = {}
|
local notify = {}
|
||||||
|
|
||||||
local redis = (loadfile "./miku/redis.lua")()
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
function notify:init(config)
|
function notify:init(config)
|
||||||
notify.triggers = {
|
notify.triggers = {
|
||||||
"^/notify (del)$",
|
"^/[Nn][Oo][Tt][Ii][Ff][Yy] (del)$",
|
||||||
"^/notify$"
|
"^/[Nn][Oo][Tt][Ii][Ff][Yy]$"
|
||||||
}
|
}
|
||||||
|
|
||||||
notify.doc = [[*
|
notify.doc = [[*
|
||||||
@ -49,7 +46,7 @@ function notify:pre_process(msg, self)
|
|||||||
local from = string.gsub(msg.from.name, "%_", " ")
|
local from = string.gsub(msg.from.name, "%_", " ")
|
||||||
local chat_name = string.gsub(msg.chat.title, "%_", " ")
|
local chat_name = string.gsub(msg.chat.title, "%_", " ")
|
||||||
local text = from..' am '..send_date..' in "'..chat_name..'":\n\n'..msg.text
|
local text = from..' am '..send_date..' in "'..chat_name..'":\n\n'..msg.text
|
||||||
utilities.send_message(self, id, text)
|
utilities.send_message(self, id, text, true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -74,9 +71,9 @@ function notify:action(msg, config, matches)
|
|||||||
utilities.send_reply(self, msg, 'Du wirst noch gar nicht benachrichtigt!')
|
utilities.send_reply(self, msg, 'Du wirst noch gar nicht benachrichtigt!')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
print('Setting notify in redis hash '..hash..' to false')
|
print('Setze notify redis hash '..hash..' auf false')
|
||||||
redis:hset(hash, 'notify', false)
|
redis:hset(hash, 'notify', false)
|
||||||
print('Removing '..username..' from redis set notify:ls')
|
print('Lösche '..username..' von redis set notify:ls')
|
||||||
redis:srem('notify:ls', username)
|
redis:srem('notify:ls', username)
|
||||||
utilities.send_reply(self, msg, 'Du erhälst jetzt keine Benachrichtigungen mehr, wenn du angesprochen wirst.')
|
utilities.send_reply(self, msg, 'Du erhälst jetzt keine Benachrichtigungen mehr, wenn du angesprochen wirst.')
|
||||||
return
|
return
|
||||||
@ -85,11 +82,11 @@ function notify:action(msg, config, matches)
|
|||||||
utilities.send_reply(self, msg, 'Du wirst schon benachrichtigt!')
|
utilities.send_reply(self, msg, 'Du wirst schon benachrichtigt!')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
print('Setting notify in redis hash '..hash..' to true')
|
print('Setze notify in redis hash '..hash..' auf true')
|
||||||
redis:hset(hash, 'notify', true)
|
redis:hset(hash, 'notify', true)
|
||||||
print('Setting id in redis hash '..hash..' to '..msg.from.id)
|
print('Setze id in redis hash '..hash..' auf '..msg.from.id)
|
||||||
redis:hset(hash, 'id', msg.from.id)
|
redis:hset(hash, 'id', msg.from.id)
|
||||||
print('Adding '..username..' to redis set notify:ls')
|
print('Adde '..username..' zu redis set notify:ls')
|
||||||
redis:sadd('notify:ls', username)
|
redis:sadd('notify:ls', username)
|
||||||
local res = utilities.send_message(self, msg.from.id, 'Du erhälst jetzt Benachrichtigungen, wenn du angesprochen wirst, nutze `/notify del` zum Deaktivieren.', true, nil, true)
|
local res = utilities.send_message(self, msg.from.id, 'Du erhälst jetzt Benachrichtigungen, wenn du angesprochen wirst, nutze `/notify del` zum Deaktivieren.', true, nil, true)
|
||||||
if not res then
|
if not res then
|
||||||
|
@ -1,18 +1,14 @@
|
|||||||
local pagespeed_insights = {}
|
local pagespeed_insights = {}
|
||||||
|
|
||||||
local https = require('ssl.https')
|
|
||||||
local json = require('dkjson')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
function pagespeed_insights:init(config)
|
function pagespeed_insights:init(config)
|
||||||
if not cred_data.google_apikey then
|
if not cred_data.google_apikey then
|
||||||
print('Missing config value: google_apikey.')
|
print('Fehlender Key: google_apikey.')
|
||||||
print('pagespeed_insights.lua will not be enabled.')
|
print('pagespeed_insights.lua wird nicht aktiviert.')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
pagespeed_insights.triggers = {
|
pagespeed_insights.triggers = {
|
||||||
"^/speed (https?://[%w-_%.%?%.:/%+=&]+)"
|
"^/[Ss][Pp][Ee][Ee][Dd] (https?://[%w-_%.%?%.:/%+=&]+)"
|
||||||
}
|
}
|
||||||
pagespeed_insights.doc = [[*
|
pagespeed_insights.doc = [[*
|
||||||
]]..config.cmd_pat..[[speed* _<Seiten-URL>_: Testet Geschwindigkeit der Seite mit PageSpeed Insights]]
|
]]..config.cmd_pat..[[speed* _<Seiten-URL>_: Testet Geschwindigkeit der Seite mit PageSpeed Insights]]
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
local pasteee = {}
|
local pasteee = {}
|
||||||
|
|
||||||
local bot = require('miku.bot')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
function pasteee:init(config)
|
function pasteee:init(config)
|
||||||
if not cred_data.pasteee_key then
|
if not cred_data.pasteee_key then
|
||||||
print('Missing config value: pasteee_key.')
|
print('Fehlender Key: pasteee_key.')
|
||||||
print('pasteee.lua will not be enabled, listquotes won\'t be available.')
|
print('pasteee.lua wird nicht aktiviert, listquotes won\'t be available.')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
local patterns = {}
|
local patterns = {}
|
||||||
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
patterns.triggers = {
|
patterns.triggers = {
|
||||||
'^/?s/.-/.-$'
|
'^/?s/.-/.-$'
|
||||||
}
|
}
|
||||||
@ -25,8 +23,8 @@ function patterns:action(msg)
|
|||||||
utilities.send_reply(self, msg, 'Falsches Pattern!')
|
utilities.send_reply(self, msg, 'Falsches Pattern!')
|
||||||
else
|
else
|
||||||
output = output:sub(1, 4000)
|
output = output:sub(1, 4000)
|
||||||
output = 'Du meintest wohl:\n"' .. output .. '"'
|
output = '*Du meintest wohl*:\n"'..utilities.md_escape(utilities.trim(output))..'"'
|
||||||
utilities.send_reply(self, msg.reply_to_message, output)
|
utilities.send_reply(self, msg.reply_to_message, output, true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,14 +1,9 @@
|
|||||||
local pixabay = {}
|
local pixabay = {}
|
||||||
|
|
||||||
local https = require('ssl.https')
|
|
||||||
local json = require('dkjson')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local redis = (loadfile "./miku/redis.lua")()
|
|
||||||
|
|
||||||
function pixabay:init(config)
|
function pixabay:init(config)
|
||||||
if not cred_data.pixabay_apikey then
|
if not cred_data.pixabay_apikey then
|
||||||
print('Missing config value: pixabay_apikey.')
|
print('Fehlender Key: pixabay_apikey.')
|
||||||
print('pixabay.lua will not be enabled.')
|
print('pixabay.lua wird nicht aktiviert.')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
local play_store = {}
|
local play_store = {}
|
||||||
|
|
||||||
local https = require('ssl.https')
|
|
||||||
local json = require('dkjson')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
function play_store:init(config)
|
function play_store:init(config)
|
||||||
if not cred_data.x_mashape_key then
|
if not cred_data.x_mashape_key then
|
||||||
print('Missing config value: x_mashape_key.')
|
print('Fehlender Key: x_mashape_key.')
|
||||||
print('play_store.lua will not be enabled.')
|
print('play_store.lua wird nicht aktiviert.')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
local plugin_manager = {}
|
local plugin_manager = {}
|
||||||
|
|
||||||
local bot = require('miku.bot')
|
local bot = require('miku.bot')
|
||||||
local bindings = require('miku.bindings')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local redis = (loadfile "./miku/redis.lua")()
|
|
||||||
|
|
||||||
function plugin_manager:init(config)
|
function plugin_manager:init(config)
|
||||||
plugin_manager.triggers = {
|
plugin_manager.triggers = {
|
||||||
|
@ -1,15 +1,9 @@
|
|||||||
local pocket = {}
|
local pocket = {}
|
||||||
|
|
||||||
local https = require('ssl.https')
|
|
||||||
local URL = require('socket.url')
|
|
||||||
local redis = (loadfile "./miku/redis.lua")()
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local bindings = require('miku.bindings')
|
|
||||||
|
|
||||||
function pocket:init(config)
|
function pocket:init(config)
|
||||||
if not cred_data.pocket_consumer_key then
|
if not cred_data.pocket_consumer_key then
|
||||||
print('Missing config value: pocket_consumer_key.')
|
print('Fehlender Key: pocket_consumer_key.')
|
||||||
print('pocket.lua will not be enabled.')
|
print('pocket.lua wird nicht aktiviert.')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
local pokedex = {}
|
local pokedex = {}
|
||||||
|
|
||||||
local HTTP = require('socket.http')
|
|
||||||
local JSON = require('dkjson')
|
|
||||||
local bindings = require('miku.bindings')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
pokedex.command = 'pokedex <query>'
|
pokedex.command = 'pokedex <query>'
|
||||||
|
|
||||||
function pokedex:init(config)
|
function pokedex:init(config)
|
||||||
@ -33,22 +28,22 @@ function pokedex:action(msg, config)
|
|||||||
local url = 'http://pokeapi.co'
|
local url = 'http://pokeapi.co'
|
||||||
|
|
||||||
local dex_url = url .. '/api/v1/pokemon/' .. input
|
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
|
if res ~= 200 then
|
||||||
utilities.send_reply(self, msg, config.errors.connection)
|
utilities.send_reply(self, msg, config.errors.connection)
|
||||||
return
|
return
|
||||||
end
|
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_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
|
if res ~= 200 then
|
||||||
utilities.send_reply(self, msg, config.errors.connection)
|
utilities.send_reply(self, msg, config.errors.connection)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local desc_jdat = JSON.decode(desc_jstr)
|
local desc_jdat = json.decode(desc_jstr)
|
||||||
|
|
||||||
local poke_type
|
local poke_type
|
||||||
for _,v in ipairs(dex_jdat.types) do
|
for _,v in ipairs(dex_jdat.types) do
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
local preview = {}
|
local preview = {}
|
||||||
|
|
||||||
local HTTP = require('socket.http')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
preview.command = 'preview <link>'
|
preview.command = 'preview <link>'
|
||||||
|
|
||||||
function preview:init(config)
|
function preview:init(config)
|
||||||
@ -27,7 +24,7 @@ function preview:action(msg)
|
|||||||
input = 'http://' .. input
|
input = 'http://' .. input
|
||||||
end
|
end
|
||||||
|
|
||||||
local res = HTTP.request(input)
|
local res = http.request(input)
|
||||||
if not res then
|
if not res then
|
||||||
utilities.send_reply(self, msg, 'Please provide a valid link.')
|
utilities.send_reply(self, msg, 'Please provide a valid link.')
|
||||||
return
|
return
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
local qr = {}
|
local qr = {}
|
||||||
|
|
||||||
local http = require('socket.http')
|
|
||||||
local URL = require('socket.url')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
function qr:init(config)
|
function qr:init(config)
|
||||||
qr.triggers = {
|
qr.triggers = {
|
||||||
'^/qr "(%w+)" "(%w+)" (.+)$',
|
'^/qr "(%w+)" "(%w+)" (.+)$',
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
local quotes = {}
|
local quotes = {}
|
||||||
|
|
||||||
local bot = require('miku.bot')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local redis = (loadfile "./miku/redis.lua")()
|
|
||||||
require("./miku/plugins/pasteee")
|
require("./miku/plugins/pasteee")
|
||||||
|
|
||||||
function quotes:init(config)
|
function quotes:init(config)
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
local fun = {}
|
local fun = {}
|
||||||
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
function fun:init(config)
|
function fun:init(config)
|
||||||
fun.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('random', true).table
|
fun.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('random', true).table
|
||||||
fun.doc = [[*
|
fun.doc = [[*
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
local reddit = {}
|
local reddit = {}
|
||||||
|
|
||||||
local https = require('ssl.https')
|
|
||||||
local URL = require('socket.url')
|
|
||||||
local JSON = require('dkjson')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
reddit.command = 'reddit [r/subreddit | Suchbegriff]'
|
reddit.command = 'reddit [r/subreddit | Suchbegriff]'
|
||||||
|
|
||||||
function reddit:init(config)
|
function reddit:init(config)
|
||||||
@ -68,7 +63,7 @@ function reddit:action(msg, config)
|
|||||||
if res ~= 200 then
|
if res ~= 200 then
|
||||||
utilities.send_reply(self, msg, config.errors.results)
|
utilities.send_reply(self, msg, config.errors.results)
|
||||||
else
|
else
|
||||||
local jdat = JSON.decode(jstr)
|
local jdat = json.decode(jstr)
|
||||||
if #jdat.data.children == 0 then
|
if #jdat.data.children == 0 then
|
||||||
utilities.send_reply(self, msg, config.errors.results)
|
utilities.send_reply(self, msg, config.errors.results)
|
||||||
else
|
else
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
local reddit_post = {}
|
local reddit_post = {}
|
||||||
|
|
||||||
local https = require('ssl.https')
|
|
||||||
local URL = require('socket.url')
|
|
||||||
local json = require('dkjson')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
reddit_post.triggers = {
|
reddit_post.triggers = {
|
||||||
"reddit.com/r/([A-Za-z0-9-/-_-.]+)/comments/([A-Za-z0-9-/-_-.]+)"
|
"reddit.com/r/([A-Za-z0-9-/-_-.]+)/comments/([A-Za-z0-9-/-_-.]+)"
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
local remind = {}
|
local remind = {}
|
||||||
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
remind.command = 'remind <Länge> <Nachricht>'
|
remind.command = 'remind <Länge> <Nachricht>'
|
||||||
|
|
||||||
function remind:init(config)
|
function remind:init(config)
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
local respond = {}
|
local respond = {}
|
||||||
|
|
||||||
local https = require('ssl.https')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local bindings = require('miku.bindings')
|
|
||||||
|
|
||||||
function respond:init(config)
|
function respond:init(config)
|
||||||
respond.triggers = {
|
respond.triggers = {
|
||||||
"([Ff][Gg][Tt].? [Ss][Ww][Ii][Ff][Tt])",
|
"([Ff][Gg][Tt].? [Ss][Ww][Ii][Ff][Tt])",
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
local roll = {}
|
local roll = {}
|
||||||
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
roll.command = 'roll'
|
roll.command = 'roll'
|
||||||
|
|
||||||
function roll:init(config)
|
function roll:init(config)
|
||||||
|
@ -1,11 +1,5 @@
|
|||||||
local rss = {}
|
local rss = {}
|
||||||
|
|
||||||
local http = require('socket.http')
|
|
||||||
local https = require('ssl.https')
|
|
||||||
local url = require('socket.url')
|
|
||||||
local bindings = require('miku.bindings')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local redis = (loadfile "./miku/redis.lua")()
|
|
||||||
local feedparser = require("feedparser")
|
local feedparser = require("feedparser")
|
||||||
|
|
||||||
rss.command = 'rss <sub/del>'
|
rss.command = 'rss <sub/del>'
|
||||||
@ -60,24 +54,6 @@ function to_utf8(a)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function unescape_for_rss(str)
|
|
||||||
str = string.gsub( str, '<', '<' )
|
|
||||||
str = string.gsub( str, '>', '>' )
|
|
||||||
str = string.gsub( str, '"', '"' )
|
|
||||||
str = string.gsub( str, ''', "'" )
|
|
||||||
str = string.gsub( str, "Ä", "Ä")
|
|
||||||
str = string.gsub( str, "ä", "ä")
|
|
||||||
str = string.gsub( str, "Ö", "Ö")
|
|
||||||
str = string.gsub( str, "ö", "ö")
|
|
||||||
str = string.gsub( str, "Uuml;", "Ü")
|
|
||||||
str = string.gsub( str, "ü", "ü")
|
|
||||||
str = string.gsub( str, "ß", "ß")
|
|
||||||
str = string.gsub(str, '&#(%d+);', to_utf8)
|
|
||||||
str = string.gsub( str, '&#x(%d+);', function(n) return string.char(tonumber(n,16)) end )
|
|
||||||
str = string.gsub( str, '&', '&' ) -- Be sure to do this after all others
|
|
||||||
return str
|
|
||||||
end
|
|
||||||
|
|
||||||
function cleanRSS(str)
|
function cleanRSS(str)
|
||||||
str = string.gsub(str, '%[mehr%]', '')
|
str = string.gsub(str, '%[mehr%]', '')
|
||||||
str = string.gsub(str, '%[video%]', '')
|
str = string.gsub(str, '%[video%]', '')
|
||||||
@ -344,23 +320,23 @@ function rss:cron(self_plz)
|
|||||||
local subscribers = {}
|
local subscribers = {}
|
||||||
local text = '' -- Send one message per feed with the latest entries
|
local text = '' -- Send one message per feed with the latest entries
|
||||||
for k2, v2 in pairs(newentr) do
|
for k2, v2 in pairs(newentr) do
|
||||||
local title = v2.title or 'Kein Titel'
|
local title = unescape(v2.title) or 'Kein Titel'
|
||||||
local link = v2.link or v2.id or 'Kein Link'
|
local link = v2.link or v2.id or 'Kein Link'
|
||||||
if v2.content then
|
if v2.content then
|
||||||
content = v2.content:gsub("%b<>", "")
|
content = v2.content:gsub("%b<>", "")
|
||||||
if string.len(v2.content) > 250 then
|
if string.len(v2.content) > 300 then
|
||||||
content = unescape_for_rss(content)
|
content = unescape(content)
|
||||||
content = string.sub(content, 1, 250)..'...'
|
content = string.sub(content, 1, 300)..'...'
|
||||||
else
|
else
|
||||||
content = unescape_for_rss(content)
|
content = unescape(content)
|
||||||
end
|
end
|
||||||
elseif v2.summary then
|
elseif v2.summary then
|
||||||
content = v2.summary:gsub("%b<>", "")
|
content = v2.summary:gsub("%b<>", "")
|
||||||
if string.len(v2.summary) > 250 then
|
if string.len(v2.summary) > 300 then
|
||||||
content = unescape_for_rss(content)
|
content = unescape(content)
|
||||||
content = string.sub(content, 1, 250)..'...'
|
content = string.sub(content, 1, 300)..'...'
|
||||||
else
|
else
|
||||||
content = unescape_for_rss(content)
|
content = unescape(content)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
content = ''
|
content = ''
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
local set = {}
|
local set = {}
|
||||||
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local redis = (loadfile "./miku/redis.lua")()
|
|
||||||
|
|
||||||
set.command = 'set <Variable> <Wert>'
|
set.command = 'set <Variable> <Wert>'
|
||||||
|
|
||||||
function set:init(config)
|
function set:init(config)
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
local shell = {}
|
local shell = {}
|
||||||
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
function shell:init(config)
|
function shell:init(config)
|
||||||
shell.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('sh', true).table
|
shell.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('sh', true).table
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
local site_header = {}
|
local site_header = {}
|
||||||
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
function site_header:init(config)
|
function site_header:init(config)
|
||||||
site_header.triggers = {
|
site_header.triggers = {
|
||||||
"^/(head) ([%w-_%.%?%.:,/%+=&#!]+)$",
|
"^/(head) ([%w-_%.%?%.:,/%+=&#!]+)$",
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
local soundcloud = {}
|
local soundcloud = {}
|
||||||
|
|
||||||
local http = require('socket.http')
|
|
||||||
local json = require('dkjson')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
soundcloud.triggers = {
|
soundcloud.triggers = {
|
||||||
"soundcloud.com/([A-Za-z0-9-/-_-.]+)"
|
"soundcloud.com/([A-Za-z0-9-/-_-.]+)"
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
local speedtest = {}
|
local speedtest = {}
|
||||||
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
speedtest.triggers = {
|
speedtest.triggers = {
|
||||||
"speedtest.net/my%-result/(%d+)",
|
"speedtest.net/my%-result/(%d+)",
|
||||||
"speedtest.net/my%-result/i/(%d+)"
|
"speedtest.net/my%-result/i/(%d+)"
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
local spotify = {}
|
local spotify = {}
|
||||||
|
|
||||||
local https = require('ssl.https')
|
|
||||||
local json = require('dkjson')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
spotify.triggers = {
|
spotify.triggers = {
|
||||||
"open.spotify.com/track/([A-Za-z0-9-]+)",
|
"open.spotify.com/track/([A-Za-z0-9-]+)",
|
||||||
"play.spotify.com/track/([A-Za-z0-9-]+)"
|
"play.spotify.com/track/([A-Za-z0-9-]+)"
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
local stats = {}
|
local stats = {}
|
||||||
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local redis = (loadfile "./miku/redis.lua")()
|
|
||||||
|
|
||||||
function stats:init(config)
|
function stats:init(config)
|
||||||
stats.triggers = {
|
stats.triggers = {
|
||||||
"^/([Ss]tats)$",
|
"^/([Ss]tats)$",
|
||||||
@ -57,6 +54,13 @@ function stats:chat_stats(chat_id)
|
|||||||
table.insert(users_info, user_info)
|
table.insert(users_info, user_info)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Get total message count
|
||||||
|
local all_msgs = 0
|
||||||
|
for n, user in pairs(users_info) do
|
||||||
|
local msg_num = users_info[n].msgs
|
||||||
|
all_msgs = all_msgs + msg_num
|
||||||
|
end
|
||||||
|
|
||||||
-- Sort users by msgs number
|
-- Sort users by msgs number
|
||||||
table.sort(users_info, function(a, b)
|
table.sort(users_info, function(a, b)
|
||||||
if a.msgs and b.msgs then
|
if a.msgs and b.msgs then
|
||||||
@ -66,10 +70,11 @@ function stats:chat_stats(chat_id)
|
|||||||
|
|
||||||
local text = ''
|
local text = ''
|
||||||
for k,user in pairs(users_info) do
|
for k,user in pairs(users_info) do
|
||||||
text = text..user.name..': '..user.msgs..'\n'
|
text = text..user.name..': '..comma_value(user.msgs)..'\n'
|
||||||
text = string.gsub(text, "%_", " ") -- Bot API doesn't use underscores anymore! Yippie!
|
text = string.gsub(text, "%_", " ") -- Bot API doesn't use underscores anymore! Yippie!
|
||||||
end
|
end
|
||||||
if text:isempty() then return 'Keine Stats für diesen Chat verfügbar!'end
|
if text:isempty() then return 'Keine Stats für diesen Chat verfügbar!'end
|
||||||
|
local text = utilities.md_escape(text)..'\n*TOTAL*: '..comma_value(all_msgs)
|
||||||
return text
|
return text
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -124,7 +129,7 @@ function stats:action(msg, config, matches)
|
|||||||
return
|
return
|
||||||
else
|
else
|
||||||
local chat_id = msg.chat.id
|
local chat_id = msg.chat.id
|
||||||
utilities.send_reply(self, msg, stats:chat_stats(chat_id))
|
utilities.send_reply(self, msg, stats:chat_stats(chat_id), true)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -134,7 +139,7 @@ function stats:action(msg, config, matches)
|
|||||||
utilities.send_reply(self, msg, config.errors.sudo)
|
utilities.send_reply(self, msg, config.errors.sudo)
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
utilities.send_reply(self, msg, stats:chat_stats(matches[3]))
|
utilities.send_reply(self, msg, stats:chat_stats(matches[3]), true)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
local steam = {}
|
local steam = {}
|
||||||
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local http = require('socket.http')
|
|
||||||
local json = require('dkjson')
|
|
||||||
local bindings = require('miku.bindings')
|
|
||||||
|
|
||||||
steam.triggers = {
|
steam.triggers = {
|
||||||
"store.steampowered.com/app/([0-9]+)",
|
"store.steampowered.com/app/([0-9]+)",
|
||||||
"steamcommunity.com/app/([0-9]+)"
|
"steamcommunity.com/app/([0-9]+)"
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
local streamable = {}
|
local streamable = {}
|
||||||
|
|
||||||
local https = require('ssl.https')
|
|
||||||
local json = require('dkjson')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
streamable.triggers = {
|
streamable.triggers = {
|
||||||
"streamable.com/([A-Za-z0-9-_-]+)",
|
"streamable.com/([A-Za-z0-9-_-]+)",
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
local surrogate = {}
|
local surrogate = {}
|
||||||
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
surrogate.triggers = {
|
surrogate.triggers = {
|
||||||
"^/s (%-%d+) +(.+)$",
|
"^/s (%-%d+) +(.+)$",
|
||||||
"^/s (%d+) +(.+)$"
|
"^/s (%d+) +(.+)$"
|
||||||
|
@ -1,15 +1,11 @@
|
|||||||
local tagesschau = {}
|
local tagesschau = {}
|
||||||
|
|
||||||
local https = require('ssl.https')
|
|
||||||
local URL = require('socket.url')
|
|
||||||
local json = require('dkjson')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local bindings = require('miku.bindings')
|
|
||||||
|
|
||||||
tagesschau.triggers = {
|
tagesschau.triggers = {
|
||||||
"tagesschau.de/([A-Za-z0-9-_-_-/]+).html"
|
"tagesschau.de/([A-Za-z0-9-_-_-/]+).html"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tagesschau.inline_triggers = tagesschau.triggers
|
||||||
|
|
||||||
local BASE_URL = 'https://www.tagesschau.de/api'
|
local BASE_URL = 'https://www.tagesschau.de/api'
|
||||||
|
|
||||||
local makeOurDate = function(dateString)
|
local makeOurDate = function(dateString)
|
||||||
@ -36,12 +32,33 @@ function tagesschau:get_tagesschau_article(article)
|
|||||||
|
|
||||||
local text = '*'..title..'*\n_'..posted_at..'_\n'..news
|
local text = '*'..title..'*\n_'..posted_at..'_\n'..news
|
||||||
if data.banner[1] then
|
if data.banner[1] then
|
||||||
return text, data.banner[1].variants[1].modPremium
|
return text, data.banner[1].variants[1].modPremium, data.shortheadline, data.shorttext
|
||||||
else
|
else
|
||||||
return text
|
return text, nil, data.shortheadline, data.shorttext
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function tagesschau:inline_callback(inline_query, config, matches)
|
||||||
|
local article = matches[1]
|
||||||
|
local full_url = 'http://www.tagesschau.de/'..article..'.html'
|
||||||
|
local text, img_url, headline, shorttext = tagesschau:get_tagesschau_article(article)
|
||||||
|
if text == 'HTTP-Fehler' or text == 'Artikel nicht gefunden!' then return end
|
||||||
|
|
||||||
|
if text:match('"') then
|
||||||
|
text = text:gsub('"', '\\"')
|
||||||
|
end
|
||||||
|
if shorttext:match('"') then
|
||||||
|
shorttext = shorttext:gsub('"', '\\"')
|
||||||
|
end
|
||||||
|
if headline:match('"') then
|
||||||
|
headline = headline:gsub('"', '\\"')
|
||||||
|
end
|
||||||
|
|
||||||
|
local text = text:gsub('\n', '\\n')
|
||||||
|
local results = '[{"type":"article","id":"'..math.random(100000000000000000)..'","title":"'..headline..'","description":"'..shorttext..'","url":"'..full_url..'","thumb_url":"https://anditest.perseus.uberspace.de/inlineQuerys/tagesschau/tagesschau.jpg","thumb_width":150,"thumb_height":150,"hide_url":true,"reply_markup":{"inline_keyboard":[[{"text":"Artikel aufrufen","url":"'..full_url..'"}]]},"input_message_content":{"message_text":"'..text..'","parse_mode":"Markdown"}}]'
|
||||||
|
utilities.answer_inline_query(self, inline_query, results, 7200)
|
||||||
|
end
|
||||||
|
|
||||||
function tagesschau:action(msg, config, matches)
|
function tagesschau:action(msg, config, matches)
|
||||||
local article = matches[1]
|
local article = matches[1]
|
||||||
local text, image_url = tagesschau:get_tagesschau_article(article)
|
local text, image_url = tagesschau:get_tagesschau_article(article)
|
||||||
|
@ -1,112 +0,0 @@
|
|||||||
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('miku.utilities')
|
|
||||||
local redis = (loadfile "./miku/redis.lua")()
|
|
||||||
|
|
||||||
tagesschau_eil.command = 'eil <sub/del>'
|
|
||||||
|
|
||||||
function tagesschau_eil:init(config)
|
|
||||||
tagesschau_eil.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('eil', true).table
|
|
||||||
tagesschau_eil.doc = [[*
|
|
||||||
]]..config.cmd_pat..[[eil* _sub_: Eilmeldungen abonnieren
|
|
||||||
*]]..config.cmd_pat..[[eil* _del_: Eilmeldungen deabonnieren
|
|
||||||
*]]..config.cmd_pat..[[eil* _sync_: Nach neuen Eilmeldungen prüfen (nur Superuser)]]
|
|
||||||
end
|
|
||||||
|
|
||||||
local makeOurDate = function(dateString)
|
|
||||||
local pattern = "(%d+)%-(%d+)%-(%d+)T(%d+)%:(%d+)%:(%d+)"
|
|
||||||
local year, month, day, hours, minutes, seconds = dateString:match(pattern)
|
|
||||||
return day..'.'..month..'.'..year..' um '..hours..':'..minutes..':'..seconds
|
|
||||||
end
|
|
||||||
|
|
||||||
local url = 'http://www.tagesschau.de/api'
|
|
||||||
local hash = 'telegram:tagesschau'
|
|
||||||
|
|
||||||
function tagesschau_eil:abonnieren(id)
|
|
||||||
if redis:sismember(hash..':subs', id) == false then
|
|
||||||
redis:sadd(hash..':subs', id)
|
|
||||||
return '*Eilmeldungen abonniert.*'
|
|
||||||
else
|
|
||||||
return 'Die Eilmeldungen wurden hier bereits abonniert.'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function tagesschau_eil:deabonnieren(id)
|
|
||||||
if redis:sismember(hash..':subs', id) == true then
|
|
||||||
redis:srem(hash..':subs', id)
|
|
||||||
return '*Eilmeldungen deabonniert.*'
|
|
||||||
else
|
|
||||||
return 'Die Eilmeldungen wurden hier noch nicht abonniert.'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function tagesschau_eil: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(self, msg.chat.id, tagesschau_eil.doc, true, msg.message_id, true)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local id = "user#id" .. msg.from.id
|
|
||||||
if msg.chat.type == 'channel' then
|
|
||||||
print('Kanäle werden momentan nicht unterstützt')
|
|
||||||
end
|
|
||||||
if msg.chat.type == 'group' or msg.chat.type == 'supergroup' then
|
|
||||||
id = 'chat#id'..msg.chat.id
|
|
||||||
end
|
|
||||||
|
|
||||||
if input:match('(sub)$') then
|
|
||||||
local output = tagesschau_eil:abonnieren(id)
|
|
||||||
utilities.send_reply(self, msg, output, true)
|
|
||||||
elseif input:match('(del)$') then
|
|
||||||
local output = tagesschau_eil:deabonnieren(id)
|
|
||||||
utilities.send_reply(self, msg, output, true)
|
|
||||||
elseif input:match('(sync)$') then
|
|
||||||
if msg.from.id ~= config.admin then
|
|
||||||
utilities.send_reply(self, msg, config.errors.sudo)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
tagesschau_eil:cron(self)
|
|
||||||
end
|
|
||||||
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
function tagesschau_eil:cron(self_plz)
|
|
||||||
if not self.BASE_URL then
|
|
||||||
self = self_plz
|
|
||||||
end
|
|
||||||
-- print('EIL: Prüfe...')
|
|
||||||
local last_eil = redis:get(hash..':last_entry')
|
|
||||||
local res,code = http.request(url)
|
|
||||||
if code ~= 200 then return end
|
|
||||||
local data = json.decode(res)
|
|
||||||
if not data then return end
|
|
||||||
if data.breakingnews[1] then
|
|
||||||
if data.breakingnews[1].date ~= last_eil then
|
|
||||||
local title = '#EIL: *'..data.breakingnews[1].headline..'*'
|
|
||||||
local news = data.breakingnews[1].shorttext
|
|
||||||
local posted_at = makeOurDate(data.breakingnews[1].date)..' Uhr'
|
|
||||||
local post_url = string.gsub(data.breakingnews[1].details, '/api/', '/')
|
|
||||||
local post_url = string.gsub(post_url, '.json', '.html')
|
|
||||||
local eil = title..'\n_'..posted_at..'_\n'..news
|
|
||||||
redis:set(hash..':last_entry', data.breakingnews[1].date)
|
|
||||||
for _,user in pairs(redis:smembers(hash..':subs')) do
|
|
||||||
local user = string.gsub(user, 'chat%#id', '')
|
|
||||||
local user = string.gsub(user, 'user%#id', '')
|
|
||||||
utilities.send_message(self, user, eil, true, nil, true, '{"inline_keyboard":[[{"text":"Eilmeldung aufrufen","url":"'..post_url..'"}]]}')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return tagesschau_eil
|
|
@ -1,34 +0,0 @@
|
|||||||
local tex = {}
|
|
||||||
|
|
||||||
local URL = require('socket.url')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
tex.command = 'tex <LaTeX>'
|
|
||||||
|
|
||||||
function tex:init(config)
|
|
||||||
tex.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('tex', true).table
|
|
||||||
tex.doc = [[*
|
|
||||||
]]..config.cmd_pat..[[tex* _<LaTeX>_: 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(self, msg.chat.id, tex.doc, true, msg.message_id, true)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
utilities.send_typing(self, 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(self, msg.chat.id, file, nil, msg.message_id)
|
|
||||||
end
|
|
||||||
|
|
||||||
return tex
|
|
@ -1,9 +1,6 @@
|
|||||||
local tv = {}
|
local tv = {}
|
||||||
|
|
||||||
local http = require('socket.http')
|
|
||||||
local URL = require('socket.url')
|
|
||||||
local xml = require("xml")
|
local xml = require("xml")
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
tv.command = 'tv <TV-Serie>'
|
tv.command = 'tv <TV-Serie>'
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
local time = {}
|
local time = {}
|
||||||
|
|
||||||
local HTTPS = require('ssl.https')
|
|
||||||
local JSON = require('dkjson')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
|
|
||||||
time.command = 'time <Ort>'
|
time.command = 'time <Ort>'
|
||||||
|
|
||||||
function time:init(config)
|
function time:init(config)
|
||||||
@ -67,13 +63,13 @@ function time:action(msg, config)
|
|||||||
local utc = os.time(os.date("!*t", now))
|
local utc = os.time(os.date("!*t", now))
|
||||||
|
|
||||||
local url = 'https://maps.googleapis.com/maps/api/timezone/json?location=' .. coords.lat ..','.. coords.lon .. '×tamp='..utc..'&language=de'
|
local url = 'https://maps.googleapis.com/maps/api/timezone/json?location=' .. coords.lat ..','.. coords.lon .. '×tamp='..utc..'&language=de'
|
||||||
local jstr, res = HTTPS.request(url)
|
local jstr, res = https.request(url)
|
||||||
if res ~= 200 then
|
if res ~= 200 then
|
||||||
utilities.send_reply(self, msg, config.errors.connection)
|
utilities.send_reply(self, msg, config.errors.connection)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local jdat = JSON.decode(jstr)
|
local jdat = json.decode(jstr)
|
||||||
local timezoneid = '*'..string.gsub(jdat.timeZoneId, '_', ' ' )..'*'
|
local timezoneid = '*'..string.gsub(jdat.timeZoneId, '_', ' ' )..'*'
|
||||||
local timestamp = now + jdat.rawOffset + jdat.dstOffset
|
local timestamp = now + jdat.rawOffset + jdat.dstOffset
|
||||||
local utcoff = (jdat.rawOffset + jdat.dstOffset) / 3600
|
local utcoff = (jdat.rawOffset + jdat.dstOffset) / 3600
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
local translate = {}
|
local translate = {}
|
||||||
|
|
||||||
local https = require('ssl.https')
|
|
||||||
local URL = require('socket.url')
|
|
||||||
local json = require('dkjson')
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local mime = require("mime")
|
local mime = require("mime")
|
||||||
require("./miku/plugins/pasteee")
|
require("./miku/plugins/pasteee")
|
||||||
|
|
||||||
translate.command = 'translate [Text]'
|
translate.command = 'translate [Text]'
|
||||||
|
|
||||||
function translate:init(config)
|
function translate:init(config)
|
||||||
|
if not cred_data.bing_key then
|
||||||
|
print('Fehlender Key: bing_key.')
|
||||||
|
print('translate.lua wird nicht aktiviert.')
|
||||||
|
return
|
||||||
|
end
|
||||||
translate.triggers = {
|
translate.triggers = {
|
||||||
"^/translate ([%w]+),([%a]+) (.+)",
|
"^/translate ([%w]+),([%a]+) (.+)",
|
||||||
"^/translate (to%:)([%w]+) (.+)",
|
"^/translate (to%:)([%w]+) (.+)",
|
||||||
|
@ -1,28 +1,21 @@
|
|||||||
local tweet = {}
|
local tweet = {}
|
||||||
|
|
||||||
local utilities = require('miku.utilities')
|
|
||||||
local HTTPS = require('ssl.https')
|
|
||||||
local JSON = require('dkjson')
|
|
||||||
local redis = (loadfile "./miku/redis.lua")()
|
|
||||||
local OAuth = (require "OAuth")
|
|
||||||
local bindings = require('miku.bindings')
|
|
||||||
|
|
||||||
function tweet:init(config)
|
function tweet:init(config)
|
||||||
if not cred_data.tw_consumer_key then
|
if not cred_data.tw_consumer_key then
|
||||||
print('Missing config value: tw_consumer_key.')
|
print('Fehlender Key: tw_consumer_key.')
|
||||||
print('tweet.lua will not be enabled.')
|
print('tweet.lua wird nicht aktiviert.')
|
||||||
return
|
return
|
||||||
elseif not cred_data.tw_consumer_secret then
|
elseif not cred_data.tw_consumer_secret then
|
||||||
print('Missing config value: tw_consumer_secret.')
|
print('Fehlender Key: tw_consumer_secret.')
|
||||||
print('tweet.lua will not be enabled.')
|
print('tweet.lua wird nicht aktiviert.')
|
||||||
return
|
return
|
||||||
elseif not cred_data.tw_access_token then
|
elseif not cred_data.tw_access_token then
|
||||||
print('Missing config value: tw_access_token.')
|
print('Fehlender Key: tw_access_token.')
|
||||||
print('tweet.lua will not be enabled.')
|
print('tweet.lua wird nicht aktiviert.')
|
||||||
return
|
return
|
||||||
elseif not cred_data.tw_access_token_secret then
|
elseif not cred_data.tw_access_token_secret then
|
||||||
print('Missing config value: tw_access_token_secret.')
|
print('Fehlender Key: tw_access_token_secret.')
|
||||||
print('tweet.lua will not be enabled.')
|
print('tweet.lua wird nicht aktiviert.')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -145,7 +138,7 @@ function tweet:getTweet(self, msg, base, all)
|
|||||||
return "Konnte nicht verbinden, evtl. existiert der User nicht?"
|
return "Konnte nicht verbinden, evtl. existiert der User nicht?"
|
||||||
end
|
end
|
||||||
|
|
||||||
local response = JSON.decode(response_body)
|
local response = json.decode(response_body)
|
||||||
if #response == 0 then
|
if #response == 0 then
|
||||||
return "Konnte keinen Tweet bekommen, sorry"
|
return "Konnte keinen Tweet bekommen, sorry"
|
||||||
end
|
end
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user