Merge Upstream
This commit is contained in:
@ -43,7 +43,7 @@ function app_store:send_appstore_data(data)
|
||||
else
|
||||
game_center = ''
|
||||
end
|
||||
local category_count = tablelength(data.genres)
|
||||
local category_count = #data.genres
|
||||
if category_count == 1 then
|
||||
category = '\nKategorie: '..data.genres[1]
|
||||
else
|
||||
|
@ -124,10 +124,10 @@ function bitly_create:action(msg, config, matches)
|
||||
end
|
||||
|
||||
if matches[2] == nil then
|
||||
long_url = url_encode(matches[1])
|
||||
long_url = URL.encode(matches[1])
|
||||
domain = 'bit.ly'
|
||||
else
|
||||
long_url = url_encode(matches[2])
|
||||
long_url = URL.encode(matches[2])
|
||||
domain = matches[1]
|
||||
end
|
||||
utilities.send_reply(msg, bitly_create:create_bitlink(long_url, domain, bitly_access_token))
|
||||
|
@ -47,7 +47,7 @@ function channels:pre_process(msg, config)
|
||||
end
|
||||
|
||||
function channels:action(msg, config, matches)
|
||||
if msg.from.id ~= config.admin then
|
||||
if not is_sudo(msg, config) then
|
||||
utilities.send_reply(msg, config.errors.sudo, true)
|
||||
return
|
||||
end
|
||||
|
@ -12,7 +12,7 @@ end
|
||||
|
||||
function control:action(msg, config)
|
||||
|
||||
if msg.from.id ~= config.admin then
|
||||
if not is_sudo(msg, config) then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -89,7 +89,7 @@ end
|
||||
|
||||
function creds_manager:action(msg, config, matches)
|
||||
local receiver = msg.from.id
|
||||
if receiver ~= config.admin then
|
||||
if not is_sudo(msg, config) then
|
||||
utilities.send_reply(msg, config.errors.sudo, true)
|
||||
return
|
||||
end
|
||||
|
@ -14,11 +14,11 @@ local BASE_URL = 'https://mobil.dhl.de'
|
||||
function dhl:sendungsstatus(id)
|
||||
local url = BASE_URL..'/shipmentdetails.html?shipmentId='..id
|
||||
local res,code = https.request(url)
|
||||
if code ~= 200 then return 'Fehler beim Abrufen von mobil.dhl.de' end
|
||||
local status = string.match(res, '<div id%=\"detailShortStatus\">(.-)</div>')
|
||||
local status = all_trim(status)
|
||||
local zeit = string.match(res, '<div id%=\"detailStatusDateTime\">(.-)</div>')
|
||||
local zeit = all_trim(zeit)
|
||||
if code ~= 200 then return "Fehler beim Abrufen von mobil.dhl.de" end
|
||||
local status = string.match(res, "<div id%=\"detailShortStatus\">(.-)</div>")
|
||||
local status = utilities.trim(status)
|
||||
local zeit = string.match(res, "<div id%=\"detailStatusDateTime\">(.-)</div>")
|
||||
local zeit = utilities.trim(zeit)
|
||||
if not zeit or zeit == '<br />' then
|
||||
return status
|
||||
end
|
||||
|
@ -26,6 +26,19 @@ end
|
||||
|
||||
gImages.command = 'img <Suchbegriff>'
|
||||
|
||||
function gImages:is_blacklisted(msg)
|
||||
_blacklist = redis:smembers("telegram:img_blacklist")
|
||||
local var = false
|
||||
for v,word in pairs(_blacklist) do
|
||||
if string.find(string.lower(msg), string.lower(word)) then
|
||||
print("Wort steht auf der Blacklist!")
|
||||
var = true
|
||||
break
|
||||
end
|
||||
end
|
||||
return var
|
||||
end
|
||||
|
||||
-- Yes, the callback is copied from below, but I can't think of another method :\
|
||||
function gImages:callback(callback, msg, self, config, input)
|
||||
if not msg then return end
|
||||
@ -153,7 +166,7 @@ function gImages:action(msg, config, matches)
|
||||
end
|
||||
|
||||
print ('Überprüfe, ob das Wort auf der Blackliste steht: '..input)
|
||||
if is_blacklisted(input) then
|
||||
if gImages:is_blacklisted(input) then
|
||||
utilities.send_reply(msg, 'Vergiss es!')
|
||||
return
|
||||
end
|
||||
|
@ -26,6 +26,19 @@ end
|
||||
|
||||
gImages_nsfw.command = 'img2 <Suchbegriff>'
|
||||
|
||||
function gImages_nsfw:is_blacklisted(msg)
|
||||
_blacklist = redis:smembers("telegram:img_blacklist")
|
||||
local var = false
|
||||
for v,word in pairs(_blacklist) do
|
||||
if string.find(string.lower(msg), string.lower(word)) then
|
||||
print("Wort steht auf der Blacklist!")
|
||||
var = true
|
||||
break
|
||||
end
|
||||
end
|
||||
return var
|
||||
end
|
||||
|
||||
-- Yes, the callback is copied from below, but I can't think of another method :\
|
||||
function gImages_nsfw:callback(callback, msg, self, config, input)
|
||||
if not msg then return end
|
||||
@ -153,7 +166,7 @@ function gImages_nsfw:action(msg, config, matches)
|
||||
end
|
||||
|
||||
print ('Überprüfe, ob das Wort auf der Blackliste steht: '..input)
|
||||
if is_blacklisted(input) then
|
||||
if gImages_nsfw:is_blacklisted(input) then
|
||||
utilities.send_reply(msg, 'Vergiss es!')
|
||||
return
|
||||
end
|
||||
|
@ -75,7 +75,7 @@ function games:send_game_data(game_id, self, msg)
|
||||
|
||||
if xml.find(result, 'Genres') then
|
||||
local genres = xml.find(result, 'Genres')
|
||||
local genre_count = tablelength(genres)-1
|
||||
local genre_count = #genres-1
|
||||
if genre_count == 1 then
|
||||
genre = '\nGenre: '..genres[1][1]
|
||||
else
|
||||
|
@ -180,7 +180,7 @@ function gh_feed:action(msg, config, matches)
|
||||
|
||||
-- For channels
|
||||
if matches[1] == 'sub' and matches[2] and matches[3] then
|
||||
if msg.from.id ~= config.admin then
|
||||
if not is_sudo(msg, config) then
|
||||
utilities.send_reply(msg, config.errors.sudo, true)
|
||||
return
|
||||
end
|
||||
@ -194,7 +194,7 @@ function gh_feed:action(msg, config, matches)
|
||||
utilities.send_reply(msg, output, true)
|
||||
return
|
||||
elseif matches[1] == 'del' and matches[2] and matches[3] then
|
||||
if msg.from.id ~= config.admin then
|
||||
if not is_sudo(msg, config) then
|
||||
utilities.send_reply(msg, config.errors.sudo, true)
|
||||
return
|
||||
end
|
||||
@ -227,7 +227,7 @@ function gh_feed:action(msg, config, matches)
|
||||
end
|
||||
|
||||
if matches[1] == 'sub' and matches[2] then
|
||||
if msg.from.id ~= config.admin then
|
||||
if not is_sudo(msg, config) then
|
||||
utilities.send_reply(msg, config.errors.sudo, true)
|
||||
return
|
||||
end
|
||||
@ -235,7 +235,7 @@ function gh_feed:action(msg, config, matches)
|
||||
utilities.send_reply(msg, output, true)
|
||||
return
|
||||
elseif matches[1] == 'del' and matches[2] then
|
||||
if msg.from.id ~= config.admin then
|
||||
if not is_sudo(msg, config) then
|
||||
utilities.send_reply(msg, config.errors.sudo, true)
|
||||
return
|
||||
end
|
||||
@ -247,7 +247,7 @@ function gh_feed:action(msg, config, matches)
|
||||
utilities.send_reply(msg, list_subs, true, keyboard)
|
||||
return
|
||||
elseif matches[1] == 'sync' then
|
||||
if msg.from.id ~= config.admin then
|
||||
if not is_sudo(msg, config) then
|
||||
utilities.send_reply(msg, config.errors.sudo, true)
|
||||
return
|
||||
end
|
||||
|
@ -63,27 +63,27 @@ function id:action(msg, config, matches)
|
||||
end
|
||||
|
||||
local chat_id = msg.chat.id
|
||||
local user = 'Du bist @%s, auch bekannt als *%s* `[%s]`'
|
||||
local user = 'Du bist @%s, auch bekannt als <b>%s</b> <code>[%s]</code>'
|
||||
if msg.from.username then
|
||||
user = user:format(utilities.markdown_escape(msg.from.username), msg.from.name, msg.from.id)
|
||||
user = user:format(utilities.html_escape(msg.from.username), msg.from.name, msg.from.id)
|
||||
else
|
||||
user = 'Du bist *%s* `[%s]`,'
|
||||
user = 'Du bist <b>%s</b> <code>[%s]</code>,'
|
||||
user = user:format(msg.from.name, msg.from.id)
|
||||
end
|
||||
|
||||
local group = '@%s, auch bekannt als *%s* `[%s]`.'
|
||||
local group = '@%s, auch bekannt als <b>%s</b> <code>[%s]</code>.'
|
||||
if msg.chat.type == 'private' then
|
||||
group = group:format(utilities.markdown_escape(self.info.username), self.info.first_name, self.info.id)
|
||||
group = group:format(utilities.html_escape(self.info.username), self.info.first_name, self.info.id)
|
||||
elseif msg.chat.username then
|
||||
group = group:format(utilities.markdown_escape(msg.chat.username), msg.chat.title, chat_id)
|
||||
group = group:format(utilities.html_escape(msg.chat.username), msg.chat.title, chat_id)
|
||||
else
|
||||
group = '*%s* `[%s]`.'
|
||||
group = '<b>%s</b> <code>[%s]</code>.'
|
||||
group = group:format(msg.chat.title, chat_id)
|
||||
end
|
||||
|
||||
local output = user .. ', und du bist in der Gruppe ' .. group
|
||||
|
||||
utilities.send_message(msg.chat.id, output, true, msg.message_id, true)
|
||||
utilities.send_message(msg.chat.id, output, true, msg.message_id, 'HTML')
|
||||
elseif matches[1] == "chat" then
|
||||
if msg.chat.type ~= 'group' and msg.chat.type ~= 'supergroup' then
|
||||
utilities.send_reply(msg, 'Das hier ist keine Gruppe!')
|
||||
@ -115,21 +115,21 @@ function id:action(msg, config, matches)
|
||||
local result = id:get_member_count(msg, chat_id)
|
||||
local member_count = result.result
|
||||
if member_count == 1 then
|
||||
member_count = 'ist *1 Mitglied'
|
||||
member_count = 'ist <b>1 Mitglied'
|
||||
else
|
||||
member_count = 'sind *'..member_count..' Mitglieder'
|
||||
member_count = 'sind <b>'..member_count..' Mitglieder'
|
||||
end
|
||||
local text = 'IDs für *'..chat_name..'* `['..chat_id..']`\nHier '..member_count..':*\n---------\n'
|
||||
local text = 'IDs für <b>'..chat_name..'</b> <code>['..chat_id..']</code>\nHier '..member_count..':</b>\n---------\n'
|
||||
for k,user in pairs(users_info) do
|
||||
if table.contains(admins, tostring(user.id)) then
|
||||
text = text..'*'..user.name..'* `['..user.id..']` _Administrator_\n'
|
||||
text = text..'<b>'..user.name..'</b> <code>['..user.id..']</code> <i>Administrator</i>\n'
|
||||
elseif tostring(creator_id) == user.id then
|
||||
text = text..'*'..user.name..'* `['..user.id..']` _Gründer_\n'
|
||||
text = text..'<b>'..user.name..'</b> <code>['..user.id..']</code> <i>Gründer</i>\n'
|
||||
else
|
||||
text = text..'*'..user.name..'* `['..user.id..']`\n'
|
||||
text = text..'<b>'..user.name..'</b> <code>['..user.id..']</code>\n'
|
||||
end
|
||||
end
|
||||
utilities.send_reply(msg, text..'_(Bots sind nicht gelistet)_', true)
|
||||
utilities.send_reply(msg, text..'<i>(Bots sind nicht gelistet)</i>', 'HTML')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -49,7 +49,7 @@ function imgblacklist:remove_blacklist(word)
|
||||
end
|
||||
|
||||
function imgblacklist:action(msg, config, matches)
|
||||
if msg.from.id ~= config.admin then
|
||||
if not is_sudo(msg, config) then
|
||||
utilities.send_reply(msg, config.errors.sudo, true)
|
||||
return
|
||||
end
|
||||
|
@ -27,7 +27,7 @@ end
|
||||
|
||||
function luarun:action(msg, config)
|
||||
|
||||
if msg.from.id ~= config.admin then
|
||||
if not is_sudo(msg, config) then
|
||||
return true
|
||||
end
|
||||
|
||||
|
@ -16,7 +16,7 @@ lyrics.command = 'lyrics <Lied>'
|
||||
|
||||
function lyrics:getLyrics(text)
|
||||
local apikey = cred_data.lyricsnmusic_apikey
|
||||
local q = url_encode(text)
|
||||
local q = URL.encode(text)
|
||||
local b = http.request("http://api.lyricsnmusic.com/songs?api_key="..apikey.."&q=" .. q)
|
||||
response = json.decode(b)
|
||||
local reply = ""
|
||||
|
@ -1,5 +1,7 @@
|
||||
local media = {}
|
||||
|
||||
local mime = (loadfile "./miku/mimetype.lua")()
|
||||
|
||||
media.triggers = {
|
||||
"(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(gif))$",
|
||||
"(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(mp4))$",
|
||||
|
@ -24,6 +24,18 @@ end
|
||||
|
||||
plugin_manager.command = 'plugins <nur für Superuser>'
|
||||
|
||||
-- Returns at table of lua files inside plugins
|
||||
function plugin_manager:plugins_names()
|
||||
local files = {}
|
||||
for k, v in pairs(scandir("miku/plugins")) do
|
||||
-- Ends with .lua
|
||||
if (v:match(".lua$")) then
|
||||
files[#files+1] = v
|
||||
end
|
||||
end
|
||||
return files
|
||||
end
|
||||
|
||||
-- Returns the key (index) in the config.enabled_plugins table
|
||||
function plugin_manager:plugin_enabled(name, chat)
|
||||
for k,v in pairs(enabled_plugins) do
|
||||
@ -37,7 +49,7 @@ end
|
||||
|
||||
-- Returns true if file exists in plugins folder
|
||||
function plugin_manager:plugin_exists(name)
|
||||
for k,v in pairs(plugins_names()) do
|
||||
for k,v in pairs(plugin_manager:plugins_names()) do
|
||||
if name..'.lua' == v then
|
||||
return true
|
||||
end
|
||||
@ -47,7 +59,7 @@ end
|
||||
|
||||
function plugin_manager:list_plugins()
|
||||
local text = ''
|
||||
for k, v in pairs(plugins_names()) do
|
||||
for k, v in pairs(plugin_manager:plugins_names()) do
|
||||
-- ✔ enabled, ❌ disabled
|
||||
local status = '❌'
|
||||
-- Check if is enabled
|
||||
@ -161,7 +173,7 @@ function plugin_manager:reenable_plugin_on_chat(msg, plugin)
|
||||
end
|
||||
|
||||
function plugin_manager:action(msg, config, matches)
|
||||
if msg.from.id ~= config.admin then
|
||||
if not is_sudo(msg, config) then
|
||||
utilities.send_reply(msg, config.errors.sudo, true)
|
||||
return
|
||||
end
|
||||
|
@ -74,6 +74,7 @@ function pocket:add_pocket_item(access_token, url)
|
||||
local code = result.item.response_code
|
||||
|
||||
local text = title..' ('..given_url..') hinzugefügt!'
|
||||
if not code then return text end
|
||||
if code ~= "200" and code ~= "0" then text = text..'\nAber die Seite liefert Fehler '..code..' zurück.' end
|
||||
return text
|
||||
end
|
||||
|
@ -21,10 +21,6 @@ end
|
||||
quotes.command = 'quote'
|
||||
|
||||
function quotes:save_quote(msg)
|
||||
if msg.text:sub(11):isempty() then
|
||||
return "Benutzung: /addquote [Zitat]"
|
||||
end
|
||||
|
||||
local quote = msg.text:sub(11)
|
||||
local hash = get_redis_hash(msg, 'quotes')
|
||||
print('Saving quote to redis set '..hash)
|
||||
@ -33,10 +29,6 @@ function quotes:save_quote(msg)
|
||||
end
|
||||
|
||||
function quotes:delete_quote(msg)
|
||||
if msg.text:sub(11):isempty() then
|
||||
return "Benutzung: /delquote [Zitat]"
|
||||
end
|
||||
|
||||
local quote = msg.text:sub(11)
|
||||
local hash = get_redis_hash(msg, 'quotes')
|
||||
print('Deleting quote from redis set '..hash)
|
||||
|
@ -224,7 +224,7 @@ function rss:action(msg, config, matches)
|
||||
|
||||
-- For channels
|
||||
if matches[1] == 'sub' and matches[2] and matches[3] then
|
||||
if msg.from.id ~= config.admin then
|
||||
if not is_sudo(msg, config) then
|
||||
utilities.send_reply(msg, config.errors.sudo, true)
|
||||
return
|
||||
end
|
||||
@ -238,7 +238,7 @@ function rss:action(msg, config, matches)
|
||||
utilities.send_reply(msg, output, 'HTML')
|
||||
return
|
||||
elseif matches[1] == 'del' and matches[2] and matches[3] then
|
||||
if msg.from.id ~= config.admin then
|
||||
if not is_sudo(msg, config) then
|
||||
utilities.send_reply(msg, config.errors.sudo, true)
|
||||
return
|
||||
end
|
||||
@ -271,7 +271,7 @@ function rss:action(msg, config, matches)
|
||||
end
|
||||
|
||||
if matches[1] == 'sub' and matches[2] then
|
||||
if msg.from.id ~= config.admin then
|
||||
if not is_sudo(msg, config) then
|
||||
utilities.send_reply(msg, config.errors.sudo, true)
|
||||
return
|
||||
end
|
||||
@ -279,7 +279,7 @@ function rss:action(msg, config, matches)
|
||||
utilities.send_reply(msg, output, 'HTML')
|
||||
return
|
||||
elseif matches[1] == 'del' and matches[2] then
|
||||
if msg.from.id ~= config.admin then
|
||||
if not is_sudo(msg, config) then
|
||||
utilities.send_reply(msg, config.errors.sudo, true)
|
||||
return
|
||||
end
|
||||
@ -291,7 +291,7 @@ function rss:action(msg, config, matches)
|
||||
utilities.send_reply(msg, list_subs, 'HTML', keyboard)
|
||||
return
|
||||
elseif matches[1] == 'sync' then
|
||||
if msg.from.id ~= config.admin then
|
||||
if not is_sudo(msg, config) then
|
||||
utilities.send_reply(msg, config.errors.sudo, true)
|
||||
return
|
||||
end
|
||||
|
@ -8,7 +8,7 @@ function site_header:init(config)
|
||||
end
|
||||
|
||||
function site_header:action(msg, config, matches)
|
||||
if msg.from.id ~= config.admin then
|
||||
if not is_sudo(msg, config) then
|
||||
utilities.send_reply(msg, config.errors.sudo, true)
|
||||
end
|
||||
|
||||
|
@ -136,7 +136,7 @@ function stats:action(msg, config, matches)
|
||||
end
|
||||
|
||||
if matches[2] == "chat" then
|
||||
if msg.from.id ~= config.admin then
|
||||
if not is_sudo(msg, config) then
|
||||
utilities.send_reply(msg, config.errors.sudo, true)
|
||||
return
|
||||
else
|
||||
|
@ -16,10 +16,10 @@ end
|
||||
|
||||
function tagesschau:get_tagesschau_article(article)
|
||||
local url = BASE_URL..'/'..article..'.json'
|
||||
local res,code = https.request(url)
|
||||
local data = json.decode(res)
|
||||
local res, code = https.request(url)
|
||||
if code == 404 then return "Artikel nicht gefunden!" end
|
||||
if code ~= 200 then return "HTTP-Fehler" end
|
||||
local data = json.decode(res)
|
||||
if not data then return "HTTP-Fehler" end
|
||||
if data.type ~= "story" then
|
||||
print('Typ "'..data.type..'" wird nicht unterstützt')
|
||||
|
@ -248,7 +248,7 @@ end
|
||||
|
||||
function twitter_send:action(msg, config, matches)
|
||||
if matches[1] == "twwhitelist add" then
|
||||
if msg.from.id ~= config.admin then
|
||||
if not is_sudo(msg, config) then
|
||||
utilities.send_reply(msg, config.errors.sudo, true)
|
||||
return
|
||||
else
|
||||
@ -265,7 +265,7 @@ function twitter_send:action(msg, config, matches)
|
||||
end
|
||||
|
||||
if matches[1] == "twwhitelist del" then
|
||||
if msg.from.id ~= config.admin then
|
||||
if not is_sudo(msg, config) then
|
||||
utilities.send_reply(msg, config.errors.sudo, true)
|
||||
return
|
||||
else
|
||||
@ -288,7 +288,7 @@ function twitter_send:action(msg, config, matches)
|
||||
-- Thanks to the great doc at https://github.com/ignacio/LuaOAuth#a-more-involved-example
|
||||
if not oauth_token and not oauth_token_secret then
|
||||
if msg.chat.type == 'group' or msg.chat.type == 'supergroup' then
|
||||
if msg.from.id ~= config.admin then
|
||||
if not is_sudo(msg, config) then
|
||||
utilities.send_reply(msg, config.errors.sudo, true)
|
||||
return
|
||||
else
|
||||
@ -312,7 +312,7 @@ function twitter_send:action(msg, config, matches)
|
||||
|
||||
if matches[1] == 'auth' and matches[2] then
|
||||
if msg.chat.type == 'group' or msg.chat.type == 'supergroup' then
|
||||
if msg.from.id ~= config.admin then
|
||||
if not is_sudo(msg, config) then
|
||||
utilities.send_reply(msg, config.errors.sudo, true)
|
||||
return
|
||||
end
|
||||
@ -327,7 +327,7 @@ function twitter_send:action(msg, config, matches)
|
||||
|
||||
if matches[1] == 'unauth' then
|
||||
if msg.chat.type == 'group' or msg.chat.type == 'supergroup' then
|
||||
if msg.from.id ~= config.admin then
|
||||
if not is_sudo(msg, config) then
|
||||
utilities.send_reply(msg, config.errors.sudo, true)
|
||||
return
|
||||
end
|
||||
|
Reference in New Issue
Block a user