Upstream + alle Plugins angepasst

This commit is contained in:
Andreas Bielawski 2016-08-24 17:18:17 +02:00
commit 494d06f063
161 changed files with 1074 additions and 937 deletions

View File

@ -106,7 +106,8 @@ Einige Funktionen, die oft benötigt werden, sind in `utilites.lua` verfügbar.
## Bindings ## Bindings
**Diese Sektion wurde noch nicht lokalisiert.** **Diese Sektion wurde noch nicht lokalisiert.**
Calls to the Telegram bot API are performed with the `bindings.lua` file through the multipart-post library. otouto's bindings file supports all standard API methods and all arguments. Its main function, `bindings.request`, accepts four arguments: `self`, `method`, `parameters`, `file`. (At the very least, `self` should be a table containing `BASE_URL`, which is bot's API endpoint, ending with a slash, eg `https://api.telegram.org/bot123456789:ABCDEFGHIJKLMNOPQRSTUVWXYZ987654321/`.)
Calls to the Telegram bot API are performed with the `bindings.lua` file through the multipart-post library. otouto's bindings file supports all standard API methods and all arguments. Its main function, `bindings.request`, accepts three arguments: `method`, `parameters`, `file`. Before using it, initialize the bindings module with its `init` function, passing your bot token as the argument.
`method` is the name of the API method. `parameters` (optional) is a table of key/value pairs of the method's parameters to be sent with the method. `file` (super-optional) is a table of a single key/value pair, where the key is the name of the parameter and the value is the filename (if these are included in `parameters` instead, otouto will attempt to send the filename as a file ID). `method` is the name of the API method. `parameters` (optional) is a table of key/value pairs of the method's parameters to be sent with the method. `file` (super-optional) is a table of a single key/value pair, where the key is the name of the parameter and the value is the filename (if these are included in `parameters` instead, otouto will attempt to send the filename as a file ID).
@ -114,45 +115,41 @@ Additionally, any method can be called as a key in the `bindings` table (for exa
``` ```
bindings.request( bindings.request(
self, 'sendMessage',
'sendMessage', {
{ chat_id = 987654321,
chat_id = 987654321, text = 'Quick brown fox.',
text = 'Quick brown fox.', reply_to_message_id = 54321,
reply_to_message_id = 54321, disable_web_page_preview = false,
disable_web_page_preview = false, parse_method = 'Markdown'
parse_method = 'Markdown' }
}
) )
bindings.sendMessage( bindings.sendMessage{
self, chat_id = 987654321,
{ text = 'Quick brown fox.',
chat_id = 987654321, reply_to_message_id = 54321,
text = 'Quick brown fox.', disable_web_page_preview = false,
reply_to_message_id = 54321, parse_method = 'Markdown'
disable_web_page_preview = false, }
parse_method = 'Markdown'
}
)
``` ```
Furthermore, `utilities.lua` provides two "shortcut" functions to mimic the behavior of otouto's old bindings: `send_message` and `send_reply`. `send_message` accepts these arguments: `self`, `chat_id`, `text`, `disable_web_page_preview`, `reply_to_message_id`, `use_markdown`. The following function call is equivalent to the two above: Furthermore, `utilities.lua` provides two "shortcut" functions to mimic the behavior of otouto's old bindings: `send_message` and `send_reply`. `send_message` accepts these arguments: `self`, `chat_id`, `text`, `disable_web_page_preview`, `reply_to_message_id`, `use_markdown`. The following function call is equivalent to the two above:
``` ```
utilities.send_message(self, 987654321, 'Quick brown fox.', false, 54321, true) utilities.send_message(987654321, 'Quick brown fox.', false, 54321, true)
``` ```
Uploading a file for the `sendPhoto` method would look like this: Uploading a file for the `sendPhoto` method would look like this:
``` ```
bindings.sendPhoto(self, { chat_id = 987654321 }, { photo = 'rarepepe.jpg' } ) bindings.sendPhoto({ chat_id = 987654321 }, { photo = 'dankmeme.jpg' } )
``` ```
and using `sendPhoto` with a file ID would look like this: and using `sendPhoto` with a file ID would look like this:
``` ```
bindings.sendPhoto(self, { chat_id = 987654321, photo = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789' } ) bindings.sendPhoto{ chat_id = 987654321, photo = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789' }
``` ```
Upon success, bindings will return the deserialized result from the API. Upon failure, it will return false and the result. In the case of a connection error, it will return two false values. If an invalid method name is given, bindings will throw an exception. This is to mimic the behavior of more conventional bindings as well as to prevent "silent errors". Upon success, bindings will return the deserialized result from the API. Upon failure, it will return false and the result. In the case of a connection error, it will return two false values. If an invalid method name is given, bindings will throw an exception. This is to mimic the behavior of more conventional bindings as well as to prevent "silent errors".

View File

@ -1,9 +1,23 @@
--[[ --[[
bindings.lua (rev. 2016/05/28) bindings.lua (rev. 2016/08/20)
otouto's bindings for the Telegram bot API. otouto's bindings for the Telegram bot API.
https://core.telegram.org/bots/api https://core.telegram.org/bots/api
Copyright 2016 topkecleon. Published under the AGPLv3. See the "Bindings" section of README.md for usage information.
See the "Bindings" section of README.md for usage information.
Copyright 2016 topkecleon <drew@otou.to>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License version 3 as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
for more details.
You should have received a copy of the GNU Affero General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
]]-- ]]--
local bindings = {} local bindings = {}
@ -14,6 +28,11 @@ local JSON = require('dkjson')
local ltn12 = require('ltn12') local ltn12 = require('ltn12')
local MP_ENCODE = require('multipart-post').encode local MP_ENCODE = require('multipart-post').encode
function bindings.init(token)
bindings.BASE_URL = 'https://api.telegram.org/bot' .. token .. '/'
return bindings
end
-- Build and send a request to the API. -- Build and send a request to the API.
-- Expecting self, method, and parameters, where method is a string indicating -- Expecting self, method, and parameters, where method is a string indicating
-- the API method and parameters is a key/value table of parameters with their -- the API method and parameters is a key/value table of parameters with their
@ -21,7 +40,7 @@ local MP_ENCODE = require('multipart-post').encode
-- Returns the table response with success. Returns false and the table -- Returns the table response with success. Returns false and the table
-- response with failure. Returns false and false with a connection error. -- response with failure. Returns false and false with a connection error.
-- To mimic old/normal behavior, it errs if used with an invalid method. -- To mimic old/normal behavior, it errs if used with an invalid method.
function bindings:request(method, parameters, file) function bindings.request(method, parameters, file)
parameters = parameters or {} parameters = parameters or {}
for k,v in pairs(parameters) do for k,v in pairs(parameters) do
parameters[k] = tostring(v) parameters[k] = tostring(v)
@ -48,7 +67,7 @@ function bindings:request(method, parameters, file)
local response = {} local response = {}
local body, boundary = MP_ENCODE(parameters) local body, boundary = MP_ENCODE(parameters)
local success, code = HTTPS.request{ local success, code = HTTPS.request{
url = self.BASE_URL .. method, url = bindings.BASE_URL .. method,
method = 'POST', method = 'POST',
headers = { headers = {
["Content-Type"] = "multipart/form-data; boundary=" .. boundary, ["Content-Type"] = "multipart/form-data; boundary=" .. boundary,
@ -75,8 +94,8 @@ function bindings:request(method, parameters, file)
end end
function bindings.gen(_, key) function bindings.gen(_, key)
return function(self, params, file) return function(params, file)
return bindings.request(self, key, params, file) return bindings.request(key, params, file)
end end
end end
setmetatable(bindings, { __index = bindings.gen }) setmetatable(bindings, { __index = bindings.gen })

View File

@ -1,23 +1,39 @@
--[[
bot.lua
The heart and sole of otouto, ie the init and main loop.
Copyright 2016 topkecleon <drew@otou.to>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License version 3 as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
for more details.
You should have received a copy of the GNU Affero General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
]]--
local bot = {} local bot = {}
bindings = require('miku.bindings') bindings = require('miku.bindings')
utilities = require('miku.utilities') utilities = require('miku.utilities')
bot.version = '160823' bot.version = '160824'
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('otouto.bindings').init(config.bot_api_key)
utilities = require('otouto.utilities')
cred_data = load_cred() cred_data = load_cred()
assert(
config.bot_api_key,
'You did not set your bot token in the config!'
)
self.BASE_URL = 'https://api.telegram.org/bot' .. config.bot_api_key .. '/'
-- Fetch bot information. Try until it succeeds. -- Fetch bot information. Try until it succeeds.
repeat repeat
print('Sammel Bot-Informationen...') print('Sammel Bot-Informationen...')
self.info = bindings.getMe(self) self.info = bindings.getMe()
until self.info until self.info
self.info = self.info.result self.info = self.info.result
@ -87,7 +103,7 @@ function bot:on_callback_receive(callback, msg, config) -- whenever a new callba
-- vardump(callback) -- vardump(callback)
if msg.date < os.time() - 1800 then -- Do not process old messages. if msg.date < os.time() - 1800 then -- Do not process old messages.
utilities.answer_callback_query(self, callback, 'Nachricht älter als eine halbe Stunde, bitte sende den Befehl selbst noch einmal.', true) utilities.answer_callback_query(callback, 'Nachricht älter als eine halbe Stunde, bitte sende den Befehl selbst noch einmal.', true)
return return
end end
@ -99,14 +115,14 @@ function bot:on_callback_receive(callback, msg, config) -- whenever a new callba
local user_id = callback.from.id local user_id = callback.from.id
local chat_id = msg.chat.id local chat_id = msg.chat.id
if redis:get('blocked:'..user_id) then if redis:get('blocked:'..user_id) then
utilities.answer_callback_query(self, callback, 'Du darfst den Bot nicht nutzen!', true) utilities.answer_callback_query(callback, 'Du darfst den Bot nicht nutzen!', true)
return return
end end
-- Check if user is banned -- Check if user is banned
local banned = redis:get('banned:'..chat_id..':'..user_id) local banned = redis:get('banned:'..chat_id..':'..user_id)
if banned then if banned then
utilities.answer_callback_query(self, callback, 'Du darfst den Bot nicht nutzen!', true) utilities.answer_callback_query(callback, 'Du darfst den Bot nicht nutzen!', true)
return return
end end
@ -119,11 +135,11 @@ function bot:on_callback_receive(callback, msg, config) -- whenever a new callba
if msg.chat.type == 'group' or msg.chat.type == 'supergroup' then if msg.chat.type == 'group' or msg.chat.type == 'supergroup' then
local allowed = redis:get('whitelist:chat#id'.. chat_id) local allowed = redis:get('whitelist:chat#id'.. chat_id)
if not allowed then if not allowed then
utilities.answer_callback_query(self, callback, 'Du darfst den Bot nicht nutzen!', true) utilities.answer_callback_query(callback, 'Du darfst den Bot nicht nutzen!', true)
return return
end end
else else
utilities.answer_callback_query(self, callback, 'Du darfst den Bot nicht nutzen!', true) utilities.answer_callback_query(callback, 'Du darfst den Bot nicht nutzen!', true)
return return
end end
end end
@ -156,13 +172,13 @@ function bot:process_inline_query(inline_query, config) -- When an inline query
-- but he WON'T be able to make new requests. -- but he WON'T be able to make new requests.
local user_id = inline_query.from.id local user_id = inline_query.from.id
if redis:get('blocked:'..user_id) then if redis:get('blocked:'..user_id) then
utilities.answer_inline_query(self, inline_query, nil, 0, true) abort_inline_query(inline_query)
return return
end end
if not config.enable_inline_for_everyone then if not config.enable_inline_for_everyone then
local is_whitelisted = redis:get('whitelist:user#id'..inline_query.from.id) local is_whitelisted = redis:get('whitelist:user#id'..inline_query.from.id)
if not is_whitelisted then utilities.answer_inline_query(self, inline_query, nil, 0, true) return end if not is_whitelisted then abort_inline_query(inline_query) return end
end end
if inline_query.query:match('"') then if inline_query.query:match('"') then
@ -175,7 +191,7 @@ function bot:process_inline_query(inline_query, config) -- When an inline query
end end
-- Stop the spinning circle -- Stop the spinning circle
utilities.answer_inline_query(self, inline_query, nil, 0, true) abort_inline_query(inline_query)
end end
function bot:run(config) function bot:run(config)
@ -183,7 +199,7 @@ function bot:run(config)
while self.is_started do while self.is_started do
-- Update loop -- Update loop
local res = bindings.getUpdates(self, { timeout = 20, offset = self.last_update+1 } ) local res = bindings.getUpdates{ timeout = 20, offset = self.last_update+1 }
if res then if res then
-- Iterate over every new message. -- Iterate over every new message.
for n=1, #res.result do for n=1, #res.result do
@ -210,7 +226,7 @@ function bot:run(config)
if v.cron then -- Call each plugin's cron function, if it has one. if v.cron then -- Call each plugin's cron function, if it has one.
local result, err = pcall(function() v.cron(self, config) end) local result, err = pcall(function() v.cron(self, config) end)
if not result then if not result then
utilities.handle_exception(self, err, 'CRON: ' .. n, config) utilities.handle_exception(self, err, 'CRON: ' .. n, config.log_chat)
end end
end end
end end
@ -232,7 +248,8 @@ function pre_process_msg(self, msg, config)
local plugin = self.plugins[n] local plugin = self.plugins[n]
if plugin.pre_process and msg then if plugin.pre_process and msg then
-- print('Preprocess '..plugin.name) -- remove comment to restore old behaviour -- print('Preprocess '..plugin.name) -- remove comment to restore old behaviour
new_msg = plugin:pre_process(msg, self, config) new_msg = plugin:pre_process(msg, config)
if not new_msg then return end -- Message was deleted
end end
end end
return new_msg return new_msg
@ -274,7 +291,7 @@ function match_plugins(self, msg, config, plugin)
end end
end) end)
if not success then if not success then
utilities.handle_exception(self, result, msg.from.id .. ': ' .. msg.text, config) utilities.handle_exception(self, result, msg.from.id .. ': ' .. msg.text, config.log_chat)
return return
end end
-- if one pattern matches, end -- if one pattern matches, end
@ -310,11 +327,16 @@ function create_plugin_set()
'control', 'control',
'about', 'about',
'id', 'id',
'post_photo',
'images',
'media',
'service_migrate_to_supergroup',
'creds', 'creds',
'echo', 'echo',
'banhammer', 'banhammer',
'channels', 'channels',
'plugins', 'plugins',
'settings',
'help' 'help'
} }
print ('Aktiviere Plugins und speicher in telegram:enabled_plugins') print ('Aktiviere Plugins und speicher in telegram:enabled_plugins')

View File

@ -31,7 +31,7 @@ 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 utilities.answer_inline_query(self, inline_query) return end if code ~= 200 then abort_inline_query(inline_query) return end
local gag = json.decode(res) local gag = json.decode(res)
local results = '[' local results = '['
@ -45,19 +45,19 @@ function ninegag:inline_callback(inline_query, config)
end end
end end
local results = results..']' local results = results..']'
utilities.answer_inline_query(self, inline_query, results, 300) utilities.answer_inline_query(inline_query, results, 300)
end end
function ninegag:action(msg, config) function ninegag:action(msg, config)
utilities.send_typing(self, msg.chat.id, 'upload_photo') utilities.send_typing(msg.chat.id, 'upload_photo')
local url, title, post_url = ninegag:get_9GAG() local url, title, post_url = ninegag:get_9GAG()
if not url then if not url then
utilities.send_reply(self, msg, config.errors.connection) utilities.send_reply(msg, config.errors.connection)
return return
end end
local file = download_to_file(url) local file = download_to_file(url)
utilities.send_photo(self, msg.chat.id, file, title, msg.message_id, '{"inline_keyboard":[[{"text":"Post aufrufen","url":"'..post_url..'"}]]}') utilities.send_photo(msg.chat.id, file, title, msg.message_id, '{"inline_keyboard":[[{"text":"Post aufrufen","url":"'..post_url..'"}]]}')
end end
return ninegag return ninegag

View File

@ -14,7 +14,7 @@ function about:init(config)
end end
function about:action(msg, config) function about:action(msg, config)
utilities.send_message(self, msg.chat.id, about.text, true, nil, true) utilities.send_message(msg.chat.id, about.text, true, nil, true)
end end
return about return about

View File

@ -27,11 +27,11 @@ function adfly:inline_callback(inline_query, config, matches)
url = redis:get(hash) url = redis:get(hash)
end end
if not url then utilities.answer_inline_query(self, inline_query) return end if not url then abort_inline_query(inline_query) return end
if url == 'NOTFOUND' then utilities.answer_inline_query(self, inline_query) return end if url == 'NOTFOUND' then abort_inline_query(inline_query) return end
local results = '[{"type":"article","id":"1","title":"Verlängerte URL","description":"'..url..'","url":"'..url..'","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":"'..url..'"}}]' local results = '[{"type":"article","id":"1","title":"Verlängerte URL","description":"'..url..'","url":"'..url..'","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":"'..url..'"}}]'
utilities.answer_inline_query(self, inline_query, results, 3600, true) utilities.answer_inline_query(inline_query, results, 3600, true)
end end
function adfly:action(msg, config, matches) function adfly:action(msg, config, matches)
@ -40,17 +40,17 @@ function adfly:action(msg, config, matches)
if redis:exists(hash) == false then if redis:exists(hash) == false then
local expanded_url = adfly:expand_adfly_link(adfly_code) local expanded_url = adfly:expand_adfly_link(adfly_code)
if not expanded_url then if not expanded_url then
utilities.send_reply(self, msg, config.errors.connection) utilities.send_reply(msg, config.errors.connection)
return return
end end
if expanded_url == 'NOTFOUND' then if expanded_url == 'NOTFOUND' then
utilities.send_reply(self, msg, 'Fehler: Keine Adf.ly-URL gefunden!') utilities.send_reply(msg, 'Fehler: Keine Adf.ly-URL gefunden!')
return return
end end
utilities.send_reply(self, msg, expanded_url) utilities.send_reply(msg, expanded_url)
else else
local data = redis:get(hash) local data = redis:get(hash)
utilities.send_reply(self, msg, data) utilities.send_reply(msg, data)
end end
end end

View File

@ -58,10 +58,10 @@ function afk:switch_afk(user_name, user_id, chat_id, timestamp, text)
end end
end end
function afk:pre_process(msg, self) function afk:pre_process(msg)
if msg.chat.type == "private" then if msg.chat.type == "private" then
-- Ignore -- Ignore
return return msg
end end
local user_name = get_name(msg) local user_name = get_name(msg)
@ -84,15 +84,15 @@ function afk:pre_process(msg, self)
if afk_text then if afk_text then
redis:hset(hash, 'afk_text', false) redis:hset(hash, 'afk_text', false)
if show_afk_keyboard == 'true' then if show_afk_keyboard == 'true' then
utilities.send_reply(self, msg, user_name..' ist wieder da! (war: <b>'..afk_text..'</b> für '..duration..')', 'HTML', '{"hide_keyboard":true,"selective":true}') utilities.send_reply(msg, user_name..' ist wieder da! (war: <b>'..afk_text..'</b> für '..duration..')', 'HTML', '{"hide_keyboard":true,"selective":true}')
else else
utilities.send_message(self, chat_id, user_name..' ist wieder da! (war: <b>'..afk_text..'</b> für '..duration..')', true, nil, 'HTML') utilities.send_message(chat_id, user_name..' ist wieder da! (war: <b>'..afk_text..'</b> für '..duration..')', true, nil, 'HTML')
end end
else else
if show_afk_keyboard == 'true' then if show_afk_keyboard == 'true' then
utilities.send_reply(self, msg, user_name..' ist wieder da! (war '..duration..' weg)', nil, '{"hide_keyboard":true,"selective":true}') utilities.send_reply(msg, user_name..' ist wieder da! (war '..duration..' weg)', nil, '{"hide_keyboard":true,"selective":true}')
else else
utilities.send_message(self, chat_id, user_name..' ist wieder da! (war '..duration..' weg)') utilities.send_message(chat_id, user_name..' ist wieder da! (war '..duration..' weg)')
end end
end end
end end
@ -102,7 +102,7 @@ end
function afk:action(msg, config, matches) function afk:action(msg, config, matches)
if msg.chat.type == "private" then if msg.chat.type == "private" then
utilities.send_reply(self, msg, "Mir ist's egal, ob du AFK bist.") utilities.send_reply(msg, "Mir ist's egal, ob du AFK bist.")
return return
end end
@ -118,7 +118,7 @@ function afk:action(msg, config, matches)
keyboard = nil keyboard = nil
end end
utilities.send_reply(self, msg, afk:switch_afk(user_name, user_id, chat_id, timestamp, matches[2]), false, keyboard) utilities.send_reply(msg, afk:switch_afk(user_name, user_id, chat_id, timestamp, matches[2]), false, keyboard)
end end
return afk return afk

View File

@ -96,15 +96,15 @@ function app_store:action(msg, config, matches)
local data = app_store:get_appstore_data() local data = app_store:get_appstore_data()
if data == nil then print('Das Appstore-Plugin unterstützt nur Apps!') end if data == nil then print('Das Appstore-Plugin unterstützt nur Apps!') end
if data == 'HTTP-FEHLER' or data == 'NOTFOUND' then if data == 'HTTP-FEHLER' or data == 'NOTFOUND' then
utilities.send_reply(self, msg, '<b>App nicht gefunden!</b>', 'HTML') utilities.send_reply(msg, '<b>App nicht gefunden!</b>', 'HTML')
return return
else else
local output, image_url = app_store:send_appstore_data(data) local output, image_url = app_store:send_appstore_data(data)
utilities.send_reply(self, msg, output, 'HTML') utilities.send_reply(msg, output, 'HTML')
if image_url then if image_url then
utilities.send_typing(self, msg.chat.id, 'upload_photo') utilities.send_typing(msg.chat.id, 'upload_photo')
local file = download_to_file(image_url) local file = download_to_file(image_url)
utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id) utilities.send_photo(msg.chat.id, file, nil, msg.message_id)
end end
end end
end end

View File

@ -59,8 +59,8 @@ function bImages:inline_callback(inline_query, config, matches)
results = bImages:getImages(query) results = bImages:getImages(query)
end end
if not results then utilities.answer_inline_query(self, inline_query) return end if not results then abort_inline_query(inline_query) return end
utilities.answer_inline_query(self, inline_query, results, 3600) utilities.answer_inline_query(inline_query, results, 3600)
end end
function bImages:action() function bImages:action()

View File

@ -39,11 +39,11 @@ function banhammer:init(config)
Alternativ kann auch auf die Nachricht des Users geantwortet werden, die Befehle sind dnn die obrigen ohne `user` bzw.`delete`.]] Alternativ kann auch auf die Nachricht des Users geantwortet werden, die Befehle sind dnn die obrigen ohne `user` bzw.`delete`.]]
end end
function banhammer:kick_user(user_id, chat_id, self, onlykick) function banhammer:kick_user(user_id, chat_id, onlykick)
if user_id == tostring(our_id) then if user_id == tostring(our_id) then
return "Ich werde mich nicht selbst kicken!" return "Ich werde mich nicht selbst kicken!"
else else
local request = bindings.request(self, 'kickChatMember', { local request = bindings.request('kickChatMember', {
chat_id = chat_id, chat_id = chat_id,
user_id = user_id user_id = user_id
} ) } )
@ -56,7 +56,7 @@ function banhammer:kick_user(user_id, chat_id, self, onlykick)
end end
end end
function banhammer:ban_user(user_id, chat_id, self) function banhammer:ban_user(user_id, chat_id)
if user_id == tostring(our_id) then if user_id == tostring(our_id) then
return "Ich werde mich nicht selbst kicken!" return "Ich werde mich nicht selbst kicken!"
else else
@ -64,15 +64,15 @@ function banhammer:ban_user(user_id, chat_id, self)
local hash = 'banned:'..chat_id..':'..user_id local hash = 'banned:'..chat_id..':'..user_id
redis:set(hash, true) redis:set(hash, true)
-- Kick from chat -- Kick from chat
return banhammer:kick_user(user_id, chat_id, self) return banhammer:kick_user(user_id, chat_id)
end end
end end
function banhammer:unban_user(user_id, chat_id, self, chat_type) function banhammer:unban_user(user_id, chat_id, chat_type)
local hash = 'banned:'..chat_id..':'..user_id local hash = 'banned:'..chat_id..':'..user_id
redis:del(hash) redis:del(hash)
if chat_type == 'supergroup' then if chat_type == 'supergroup' then
bindings.request(self, 'unbanChatMember', { bindings.request('unbanChatMember', {
chat_id = chat_id, chat_id = chat_id,
user_id = user_id user_id = user_id
} ) } )
@ -98,7 +98,7 @@ function banhammer:is_chat_whitelisted(id)
return white return white
end end
function banhammer:pre_process(msg, self, config) function banhammer:pre_process(msg, config)
-- SERVICE MESSAGE -- SERVICE MESSAGE
if msg.new_chat_member then if msg.new_chat_member then
local user_id = msg.new_chat_member.id local user_id = msg.new_chat_member.id
@ -106,7 +106,7 @@ function banhammer:pre_process(msg, self, config)
local banned = banhammer:is_banned(user_id, msg.chat.id) local banned = banhammer:is_banned(user_id, msg.chat.id)
if banned then if banned then
print('User is banned!') print('User is banned!')
banhammer:kick_user(user_id, msg.chat.id, self, true) banhammer:kick_user(user_id, msg.chat.id, true)
end end
-- No further checks -- No further checks
return msg return msg
@ -119,7 +119,7 @@ function banhammer:pre_process(msg, self, config)
local banned = banhammer:is_banned(user_id, chat_id) local banned = banhammer:is_banned(user_id, chat_id)
if banned then if banned then
print('Banned user talking!') print('Banned user talking!')
banhammer:ban_user(user_id, chat_id, self) banhammer:ban_user(user_id, chat_id)
return return
end end
end end
@ -155,7 +155,7 @@ function banhammer:pre_process(msg, self, config)
end end
else else
if not has_been_warned then if not has_been_warned then
utilities.send_reply(self, msg, "Dies ist ein privater Bot, der erst nach einer Freischaltung benutzt werden kann.\nThis is a private bot, which can only be after an approval.") utilities.send_reply(msg, "Dies ist ein privater Bot, der erst nach einer Freischaltung benutzt werden kann.\nThis is a private bot, which can only be after an approval.")
redis:hset('user:'..user_id, 'has_been_warned', true) redis:hset('user:'..user_id, 'has_been_warned', true)
else else
print('User has already been warned!') print('User has already been warned!')
@ -181,7 +181,7 @@ function banhammer:action(msg, config, matches)
if matches[1] == 'leave' then if matches[1] == 'leave' then
if msg.chat.type == 'group' or msg.chat.type == 'supergroup' then if msg.chat.type == 'group' or msg.chat.type == 'supergroup' then
bindings.request(self, 'leaveChat', { bindings.request('leaveChat', {
chat_id = msg.chat.id chat_id = msg.chat.id
} ) } )
return return
@ -206,17 +206,17 @@ function banhammer:action(msg, config, matches)
if msg.chat.type == 'group' or msg.chat.type == 'supergroup' then if msg.chat.type == 'group' or msg.chat.type == 'supergroup' then
if matches[2] == 'user' or not matches[2] then if matches[2] == 'user' or not matches[2] then
local text = banhammer:ban_user(user_id, chat_id, self) local text = banhammer:ban_user(user_id, chat_id)
utilities.send_reply(self, msg, text) utilities.send_reply(msg, text)
return return
end end
if matches[2] == 'delete' then if matches[2] == 'delete' then
local text = banhammer:unban_user(user_id, chat_id, self, msg.chat.type) local text = banhammer:unban_user(user_id, chat_id, msg.chat.type)
utilities.send_reply(self, msg, text) utilities.send_reply(msg, text)
return return
end end
else else
utilities.send_reply(self, msg, 'Das ist keine Chat-Gruppe') utilities.send_reply(msg, 'Das ist keine Chat-Gruppe')
return return
end end
end end
@ -234,10 +234,10 @@ function banhammer:action(msg, config, matches)
user_id = msg.reply_to_message.from.id user_id = msg.reply_to_message.from.id
end end
end end
banhammer:kick_user(user_id, msg.chat.id, self, true) banhammer:kick_user(user_id, msg.chat.id, true)
return return
else else
utilities.send_reply(self, msg, 'Das ist keine Chat-Gruppe') utilities.send_reply(msg, 'Das ist keine Chat-Gruppe')
return return
end end
end end
@ -246,14 +246,14 @@ function banhammer:action(msg, config, matches)
if matches[2] == 'enable' then if matches[2] == 'enable' then
local hash = 'whitelist:enabled' local hash = 'whitelist:enabled'
redis:set(hash, true) redis:set(hash, true)
utilities.send_reply(self, msg, 'Whitelist aktiviert') utilities.send_reply(msg, 'Whitelist aktiviert')
return return
end end
if matches[2] == 'disable' then if matches[2] == 'disable' then
local hash = 'whitelist:enabled' local hash = 'whitelist:enabled'
redis:del(hash) redis:del(hash)
utilities.send_reply(self, msg, 'Whitelist deaktiviert') utilities.send_reply(msg, 'Whitelist deaktiviert')
return return
end end
@ -268,7 +268,7 @@ function banhammer:action(msg, config, matches)
end end
local hash = 'whitelist:user#id'..user_id local hash = 'whitelist:user#id'..user_id
redis:set(hash, true) redis:set(hash, true)
utilities.send_reply(self, msg, 'User '..user_id..' whitelisted') utilities.send_reply(msg, 'User '..user_id..' whitelisted')
return return
end end
@ -285,14 +285,14 @@ function banhammer:action(msg, config, matches)
end end
local hash = 'whitelist:user#id'..user_id local hash = 'whitelist:user#id'..user_id
redis:del(hash) redis:del(hash)
utilities.send_reply(self, msg, 'User '..user_id..' von der Whitelist entfernt!') utilities.send_reply(msg, 'User '..user_id..' von der Whitelist entfernt!')
return return
end end
if matches[2] == 'user' then if matches[2] == 'user' then
local hash = 'whitelist:user#id'..matches[3] local hash = 'whitelist:user#id'..matches[3]
redis:set(hash, true) redis:set(hash, true)
utilities.send_reply(self, msg, 'User '..matches[3]..' whitelisted') utilities.send_reply(msg, 'User '..matches[3]..' whitelisted')
return return
end end
@ -300,10 +300,10 @@ function banhammer:action(msg, config, matches)
if msg.chat.type == 'group' or msg.chat.type == 'supergroup' then if msg.chat.type == 'group' or msg.chat.type == 'supergroup' then
local hash = 'whitelist:chat#id'..msg.chat.id local hash = 'whitelist:chat#id'..msg.chat.id
redis:set(hash, true) redis:set(hash, true)
utilities.send_reply(self, msg, 'Chat '..msg.chat.id..' whitelisted') utilities.send_reply(msg, 'Chat '..msg.chat.id..' whitelisted')
return return
else else
utilities.send_reply(self, msg, 'Das ist keine Chat-Gruppe!') utilities.send_reply(msg, 'Das ist keine Chat-Gruppe!')
return return
end end
end end
@ -311,7 +311,7 @@ function banhammer:action(msg, config, matches)
if matches[2] == 'delete' and matches[3] == 'user' then if matches[2] == 'delete' and matches[3] == 'user' then
local hash = 'whitelist:user#id'..matches[4] local hash = 'whitelist:user#id'..matches[4]
redis:del(hash) redis:del(hash)
utilities.send_reply(self, msg, 'User '..matches[4]..' von der Whitelist entfernt!') utilities.send_reply(msg, 'User '..matches[4]..' von der Whitelist entfernt!')
return return
end end
@ -319,10 +319,10 @@ function banhammer:action(msg, config, matches)
if msg.chat.type == 'group' or msg.chat.type == 'supergroup' then if msg.chat.type == 'group' or msg.chat.type == 'supergroup' then
local hash = 'whitelist:chat#id'..msg.chat.id local hash = 'whitelist:chat#id'..msg.chat.id
redis:del(hash) redis:del(hash)
utilities.send_reply(self, msg, 'Chat '..msg.chat.id..' von der Whitelist entfernt') utilities.send_reply(msg, 'Chat '..msg.chat.id..' von der Whitelist entfernt')
return return
else else
utilities.send_reply(self, msg, 'Das ist keine Chat-Gruppe!') utilities.send_reply(msg, 'Das ist keine Chat-Gruppe!')
return return
end end
end end
@ -333,14 +333,14 @@ function banhammer:action(msg, config, matches)
if matches[2] == 'user' and matches[3] then if matches[2] == 'user' and matches[3] then
local hash = 'blocked:'..matches[3] local hash = 'blocked:'..matches[3]
redis:set(hash, true) redis:set(hash, true)
utilities.send_reply(self, msg, 'User '..matches[3]..' darf den Bot nun nicht mehr nutzen.') utilities.send_reply(msg, 'User '..matches[3]..' darf den Bot nun nicht mehr nutzen.')
return return
end end
if matches[2] == 'delete' and matches[3] then if matches[2] == 'delete' and matches[3] then
local hash = 'blocked:'..matches[3] local hash = 'blocked:'..matches[3]
redis:del(hash) redis:del(hash)
utilities.send_reply(self, msg, 'User '..matches[3]..' darf den Bot wieder nutzen.') utilities.send_reply(msg, 'User '..matches[3]..' darf den Bot wieder nutzen.')
return return
end end
@ -357,7 +357,7 @@ function banhammer:action(msg, config, matches)
end end
local hash = 'blocked:'..user_id local hash = 'blocked:'..user_id
redis:set(hash, true) redis:set(hash, true)
utilities.send_reply(self, msg, 'User '..user_id..' darf den Bot nun nicht mehr nutzen.') utilities.send_reply(msg, 'User '..user_id..' darf den Bot nun nicht mehr nutzen.')
return return
end end
@ -374,7 +374,7 @@ function banhammer:action(msg, config, matches)
end end
local hash = 'blocked:'..user_id local hash = 'blocked:'..user_id
redis:del(hash) redis:del(hash)
utilities.send_reply(self, msg, 'User '..user_id..' darf den Bot wieder nutzen.') utilities.send_reply(msg, 'User '..user_id..' darf den Bot wieder nutzen.')
return return
end end

View File

@ -90,7 +90,7 @@ function birthday:action(msg, config, matches)
end end
end end
utilities.send_reply(self, msg, text, 'HTML') utilities.send_reply(msg, text, 'HTML')
end end
return birthday return birthday

View File

@ -38,10 +38,10 @@ function bitly:inline_callback(inline_query, config, matches)
url = data.long_url url = data.long_url
end end
if not url then utilities.answer_inline_query(self, inline_query) return end if not url then abort_inline_query(inline_query) return end
local results = '[{"type":"article","id":"2","title":"Verlängerte URL","description":"'..url..'","url":"'..url..'","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":"'..url..'"}}]' local results = '[{"type":"article","id":"2","title":"Verlängerte URL","description":"'..url..'","url":"'..url..'","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":"'..url..'"}}]'
utilities.answer_inline_query(self, inline_query, results, 3600) utilities.answer_inline_query(inline_query, results, 3600)
end end
function bitly:action(msg, config, matches) function bitly:action(msg, config, matches)
@ -50,14 +50,14 @@ function bitly:action(msg, config, matches)
if redis:exists(hash) == false then if redis:exists(hash) == false then
local longurl = bitly:expand_bitly_link(shorturl) local longurl = bitly:expand_bitly_link(shorturl)
if not longurl then if not longurl then
utilities.send_reply(self, msg, config.errors.connection) utilities.send_reply( msg, config.errors.connection)
return return
end end
utilities.send_reply(self, msg, longurl) utilities.send_reply(msg, longurl)
return return
else else
local data = redis:hgetall(hash) local data = redis:hgetall(hash)
utilities.send_reply(self, msg, data.long_url) utilities.send_reply(msg, data.long_url)
return return
end end
end end

View File

@ -83,38 +83,38 @@ function bitly_create:action(msg, config, matches)
bitly_access_token = redis:hget(hash, 'bitly') bitly_access_token = redis:hget(hash, 'bitly')
if matches[1] == 'auth' and matches[2] then if matches[1] == 'auth' and matches[2] then
utilities.send_reply(self, msg, bitly_create:get_bitly_access_token(hash, matches[2]), true) utilities.send_reply(msg, bitly_create:get_bitly_access_token(hash, matches[2]), true)
local message_id = redis:hget(hash, 'bitly_login_msg') local message_id = redis:hget(hash, 'bitly_login_msg')
utilities.edit_message(self, msg.chat.id, message_id, '*Anmeldung abgeschlossen!*', true, true) utilities.edit_message(msg.chat.id, message_id, '*Anmeldung abgeschlossen!*', true, true)
redis:hdel(hash, 'bitly_login_msg') redis:hdel(hash, 'bitly_login_msg')
return return
end end
if matches[1] == 'auth' then if matches[1] == 'auth' then
local result = utilities.send_reply(self, msg, '*Bitte logge dich ein und folge den Anweisungen.*', true, '{"inline_keyboard":[[{"text":"Bei Bitly anmelden","url":"https://bitly.com/oauth/authorize?client_id='..client_id..'&redirect_uri='..redirect_uri..'&state='..self.info.username..'"}]]}') local result = utilities.send_reply(msg, '*Bitte logge dich ein und folge den Anweisungen.*', true, '{"inline_keyboard":[[{"text":"Bei Bitly anmelden","url":"https://bitly.com/oauth/authorize?client_id='..client_id..'&redirect_uri='..redirect_uri..'&state='..self.info.username..'"}]]}')
redis:hset(hash, 'bitly_login_msg', result.result.message_id) redis:hset(hash, 'bitly_login_msg', result.result.message_id)
return return
end end
if matches[1] == 'unauth' and bitly_access_token then if matches[1] == 'unauth' and bitly_access_token then
redis:hdel(hash, 'bitly') redis:hdel(hash, 'bitly')
utilities.send_reply(self, msg, '*Erfolgreich ausgeloggt!* Du kannst den Zugriff [in deinen Kontoeinstellungen](https://bitly.com/a/settings/connected) endgültig entziehen.', true) utilities.send_reply(msg, '*Erfolgreich ausgeloggt!* Du kannst den Zugriff [in deinen Kontoeinstellungen](https://bitly.com/a/settings/connected) endgültig entziehen.', true)
return return
elseif matches[1] == 'unauth' and not bitly_access_token then elseif matches[1] == 'unauth' and not bitly_access_token then
utilities.send_reply(self, msg, 'Wie willst du dich ausloggen, wenn du gar nicht eingeloggt bist?', true) utilities.send_reply(msg, 'Wie willst du dich ausloggen, wenn du gar nicht eingeloggt bist?', true)
return return
end end
if matches[1] == 'me' and bitly_access_token then if matches[1] == 'me' and bitly_access_token then
local text = bitly_create:get_bitly_user_info(bitly_access_token) local text = bitly_create:get_bitly_user_info(bitly_access_token)
if text then if text then
utilities.send_reply(self, msg, text, true) utilities.send_reply(msg, text, true)
return return
else else
return return
end end
elseif matches[1] == 'me' and not bitly_access_token then elseif matches[1] == 'me' and not bitly_access_token then
utilities.send_reply(self, msg, 'Du bist nicht eingeloggt! Logge dich ein mit\n/short auth', true) utilities.send_reply(msg, 'Du bist nicht eingeloggt! Logge dich ein mit\n/short auth', true)
return return
end end
@ -130,7 +130,7 @@ function bitly_create:action(msg, config, matches)
long_url = url_encode(matches[2]) long_url = url_encode(matches[2])
domain = matches[1] domain = matches[1]
end end
utilities.send_reply(self, msg, bitly_create:create_bitlink(long_url, domain, bitly_access_token)) utilities.send_reply(msg, bitly_create:create_bitlink(long_url, domain, bitly_access_token))
return return
end end

View File

@ -57,10 +57,10 @@ function boobs:action(msg, config, matches)
if url ~= nil then if url ~= nil then
local file = download_to_file(url) local file = download_to_file(url)
utilities.send_photo(self, msg.chat.id, file, url, msg.message_id) utilities.send_photo(msg.chat.id, file, url, msg.message_id)
return return
else else
utilities.send_reply(self, msg, 'Nichts gefunden :(') utilities.send_reply(msg, 'Nichts gefunden :(')
return return
end end
end end

View File

@ -35,11 +35,11 @@ function br:action(msg, config, matches)
local article = URL.escape(matches[1]) local article = URL.escape(matches[1])
local text, image_url = br:get_br_article(article) local text, image_url = br:get_br_article(article)
if image_url then if image_url then
utilities.send_typing(self, msg.chat.id, 'upload_photo') utilities.send_typing(msg.chat.id, 'upload_photo')
local file = download_to_file(image_url, 'br_teaser.jpg') local file = download_to_file(image_url, 'br_teaser.jpg')
utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id) utilities.send_photo(msg.chat.id, file, nil, msg.message_id)
end end
utilities.send_reply(self, msg, text, true) utilities.send_reply(msg, text, true)
end end
return br return br

View File

@ -28,7 +28,7 @@ end
function btc:action(msg, config, matches) function btc:action(msg, config, matches)
utilities.send_reply(self, msg, btc:getBTCX(cur), true) utilities.send_reply(msg, btc:getBTCX(cur), true)
end end
return btc return btc

View File

@ -29,7 +29,7 @@ function calc:mathjs(exp)
end end
function calc:action(msg, config, matches) function calc:action(msg, config, matches)
utilities.send_reply(self, msg, calc:mathjs(matches[1])) utilities.send_reply(msg, calc:mathjs(matches[1]))
end end
return calc return calc

View File

@ -56,18 +56,18 @@ function cats:inline_callback(inline_query, config, matches)
end end
end end
local results = results..']' local results = results..']'
utilities.answer_inline_query(self, inline_query, results, 30) utilities.answer_inline_query(inline_query, results, 30)
end 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
local file = download_to_file(url, 'miau.gif') local file = download_to_file(url, 'miau.gif')
utilities.send_document(self, msg.chat.id, file, nil, msg.message_id) utilities.send_document(msg.chat.id, file, nil, msg.message_id)
else else
local url = 'http://thecatapi.com/api/images/get?type=jpg,png&apikey='..apikey local url = 'http://thecatapi.com/api/images/get?type=jpg,png&apikey='..apikey
local file = download_to_file(url, 'miau.png') local file = download_to_file(url, 'miau.png')
utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id) utilities.send_photo(msg.chat.id, file, nil, msg.message_id)
end end
end end

View File

@ -22,7 +22,7 @@ function cf_img:inline_callback(inline_query, config, matches)
local site = matches[1] local site = matches[1]
local pic = matches[2] local pic = matches[2]
local full_url = cf_img:get_full_url(site, pic) local full_url = cf_img:get_full_url(site, pic)
if not full_url then utilities.answer_inline_query(self, inline_query) return end if not full_url then abort_inline_query(inline_query) return end
local results local results
@ -31,7 +31,7 @@ function cf_img:inline_callback(inline_query, config, matches)
else else
results = '[{"type":"photo","id":"7777","photo_url":"'..full_url..'","thumb_url":"'..full_url..'"}]' results = '[{"type":"photo","id":"7777","photo_url":"'..full_url..'","thumb_url":"'..full_url..'"}]'
end end
utilities.answer_inline_query(self, inline_query, results, 3600, true) utilities.answer_inline_query(inline_query, results, 3600, true)
end end
function cf_img:action(msg, config, matches) function cf_img:action(msg, config, matches)
@ -39,16 +39,16 @@ function cf_img:action(msg, config, matches)
local pic = matches[2] local pic = matches[2]
local full_url = cf_img:get_full_url(site, pic) local full_url = cf_img:get_full_url(site, pic)
if not full_url then if not full_url then
utilities.send_reply(self, msg, config.errors.connection) utilities.send_reply(msg, config.errors.connection)
return return
end end
utilities.send_typing(self, msg.chat.id, 'upload_photo') utilities.send_typing(msg.chat.id, 'upload_photo')
local file = download_to_file(full_url) local file = download_to_file(full_url)
if string.ends(full_url, '.gif') then if string.ends(full_url, '.gif') then
utilities.send_document(self, msg.chat.id, file, nil, msg.message_id) utilities.send_document(msg.chat.id, file, nil, msg.message_id)
else else
utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id) utilities.send_photo(msg.chat.id, file, nil, msg.message_id)
end end
end end

View File

@ -21,7 +21,7 @@ function channel:action(msg, config)
local input = utilities.input(msg.text) local input = utilities.input(msg.text)
local output local output
local chat_id = '@'..matches[1] local chat_id = '@'..matches[1]
local admin_list, gca_results = utilities.get_chat_administrators(self, chat_id) local admin_list, gca_results = utilities.get_chat_administrators(chat_id)
if admin_list then if admin_list then
local is_admin = false local is_admin = false
@ -38,17 +38,17 @@ function channel:action(msg, config)
-- this plugin will also be ready :P -- this plugin will also be ready :P
-- Also, URL buttons work!? Maybe beta? -- Also, URL buttons work!? Maybe beta?
if reply_markup:match('"callback_data":"') then if reply_markup:match('"callback_data":"') then
utilities.send_reply(self, msg, 'callback_data ist in Buttons nicht erlaubt.') utilities.send_reply(msg, 'callback_data ist in Buttons nicht erlaubt.')
return return
elseif reply_markup:match('"switch_inline_query":"') then elseif reply_markup:match('"switch_inline_query":"') then
utilities.send_reply(self, msg, 'switch_inline_query ist in Buttons nicht erlaubt.') utilities.send_reply(msg, 'switch_inline_query ist in Buttons nicht erlaubt.')
return return
end end
else else
text = matches[2] text = matches[2]
reply_markup = nil reply_markup = nil
end end
local success, result = utilities.send_message(self, chat_id, text, true, nil, true, reply_markup) local success, result = utilities.send_message(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
@ -60,7 +60,7 @@ function channel:action(msg, config)
else else
output = 'Sorry, ich konnte die Administratorenliste nicht abrufen!\n`'..gca_results.description..'`' output = 'Sorry, ich konnte die Administratorenliste nicht abrufen!\n`'..gca_results.description..'`'
end end
utilities.send_reply(self, msg, output, true) utilities.send_reply(msg, output, true)
end end
return channel return channel

View File

@ -47,7 +47,7 @@ function channels:disable_channel(msg)
end end
end end
function channels:pre_process(msg, self, config) function channels:pre_process(msg, config)
-- If is sudo can reeanble the channel -- If is sudo can reeanble the channel
if is_sudo(msg, config) then if is_sudo(msg, config) then
if msg.text == "/channel enable" then if msg.text == "/channel enable" then
@ -57,9 +57,7 @@ function channels:pre_process(msg, self, config)
if channels:is_channel_disabled(msg) then if channels:is_channel_disabled(msg) then
print('Channel wurde deaktiviert') print('Channel wurde deaktiviert')
msg.text = '' return
msg.text_lower = ''
msg.entities = ''
end end
return msg return msg
@ -67,18 +65,18 @@ end
function channels:action(msg, config, matches) function channels:action(msg, config, matches)
if msg.from.id ~= config.admin then if msg.from.id ~= config.admin then
utilities.send_reply(self, msg, config.errors.sudo) utilities.send_reply(msg, config.errors.sudo)
return return
end end
-- Enable a channel -- Enable a channel
if matches[1] == 'enable' then if matches[1] == 'enable' then
utilities.send_reply(self, msg, channels:enable_channel(msg)) utilities.send_reply(msg, channels:enable_channel(msg))
return return
end end
-- Disable a channel -- Disable a channel
if matches[1] == 'disable' then if matches[1] == 'disable' then
utilities.send_reply(self, msg, channels:disable_channel(msg)) utilities.send_reply(msg, channels:disable_channel(msg))
return return
end end
end end

View File

@ -20,10 +20,10 @@ end
function chucknorris:action(msg, config) function chucknorris:action(msg, config)
local text = chucknorris:get_joke() local text = chucknorris:get_joke()
if not text then if not text then
utilities.send_reply(self, msg, config.errors.connection) utilities.send_reply(msg, config.errors.connection)
return return
end end
utilities.send_reply(self, msg, unescape(text)) utilities.send_reply(msg, unescape(text))
end end
return chucknorris return chucknorris

View File

@ -11,17 +11,17 @@ end
cleverbot.command = 'cbot <Text>' cleverbot.command = 'cbot <Text>'
function cleverbot:action(msg, config, matches) function cleverbot:action(msg, config, matches)
utilities.send_typing(self, msg.chat.id, 'typing') utilities.send_typing(msg.chat.id, 'typing')
local text = matches[1] local text = matches[1]
local query, code = https.request(cleverbot.url..URL.escape(text)) local query, code = https.request(cleverbot.url..URL.escape(text))
if code ~= 200 then if code ~= 200 then
utilities.send_reply(self, msg, 'Ich möchte jetzt nicht reden...') utilities.send_reply(msg, 'Ich möchte jetzt nicht reden...')
return return
end end
local data = json.decode(query) local data = json.decode(query)
if not data.clever then if not data.clever then
utilities.send_reply(self, msg, 'Ich möchte jetzt nicht reden...') utilities.send_reply(msg, 'Ich möchte jetzt nicht reden...')
return return
end end
@ -32,7 +32,7 @@ function cleverbot:action(msg, config, matches)
local answer = string.gsub(answer, "&Uuml;", "Ü") local answer = string.gsub(answer, "&Uuml;", "Ü")
local answer = string.gsub(answer, "&uuml;", "ü") local answer = string.gsub(answer, "&uuml;", "ü")
local answer = string.gsub(answer, "&szlig;", "ß") local answer = string.gsub(answer, "&szlig;", "ß")
utilities.send_reply(self, msg, answer) utilities.send_reply(msg, answer)
end end
return cleverbot return cleverbot

View File

@ -19,10 +19,10 @@ function clypit:get_clypit_details(shortcode)
end end
function clypit:action(msg, config, matches) function clypit:action(msg, config, matches)
utilities.send_typing(self, msg.chat.id, 'upload_audio') utilities.send_typing(msg.chat.id, 'upload_audio')
local audio, title, duration = clypit:get_clypit_details(matches[1]) local audio, title, duration = clypit:get_clypit_details(matches[1])
if not audio then return utilities.send_reply(self, msg, config.errors.connection) end if not audio then return utilities.send_reply(msg, config.errors.connection) end
utilities.send_audio(self, msg.chat.id, audio, nil, msg.message_id, duration, nil, title) utilities.send_audio(msg.chat.id, audio, nil, msg.message_id, duration, nil, title)
end end
return clypit return clypit

View File

@ -32,22 +32,22 @@ function control:action(msg, config)
config[k] = v config[k] = v
end end
end end
bot.init(self, config) bot.init(config)
utilities.send_reply(self, msg, 'Bot neu gestartet!') utilities.send_reply(msg, 'Bot neu gestartet!')
elseif msg.text_lower:match('^'..cmd_pat..'halt') then elseif msg.text_lower:match('^'..cmd_pat..'halt') then
self.is_started = false self.is_started = false
utilities.send_reply(self, msg, 'Stoppe Bot!') utilities.send_reply(msg, 'Stoppe Bot!')
elseif msg.text_lower:match('^'..cmd_pat..'script') then elseif msg.text_lower:match('^'..cmd_pat..'script') then
local input = msg.text_lower:match('^'..cmd_pat..'script\n(.+)') local input = msg.text_lower:match('^'..cmd_pat..'script\n(.+)')
if not input then if not input then
utilities.send_reply(self, msg, 'usage: ```\n'..cmd_pat..'script\n'..cmd_pat..'command <arg>\n...\n```', true) utilities.send_reply(msg, 'usage: ```\n'..cmd_pat..'script\n'..cmd_pat..'command <arg>\n...\n```', true)
return return
end end
input = input .. '\n' input = input .. '\n'
for command in input:gmatch('(.-)\n') do for command in input:gmatch('(.-)\n') do
command = utilities.trim(command) command = utilities.trim(command)
msg.text = command msg.text = command
bot.on_msg_receive(self, msg, config) bot.on_msg_receive(msg, config)
end end
end end

View File

@ -13,18 +13,18 @@ cowsay.command = 'cowsay <Text>'
function cowsay:inline_callback(inline_query, config, matches) function cowsay:inline_callback(inline_query, config, matches)
local input = matches[1] local input = matches[1]
if string.match(input, '"') then utilities.answer_inline_query(self, inline_query) return end if string.match(input, '"') then abort_inline_query(inline_query) return end
local text = '```'..run_command('cowsay "'..input..'"')..'```' local text = '```'..run_command('cowsay "'..input..'"')..'```'
local text = text:gsub('\\', '\\\\') local text = text:gsub('\\', '\\\\')
local results = '[{"type":"article","id":"7912","title":"Muh!","input_message_content":{"message_text":"'..text..'","parse_mode":"Markdown"}}]' local results = '[{"type":"article","id":"7912","title":"Muh!","input_message_content":{"message_text":"'..text..'","parse_mode":"Markdown"}}]'
utilities.answer_inline_query(self, inline_query, results, 2) utilities.answer_inline_query(inline_query, results, 2)
end end
function cowsay:action(msg, config) function cowsay:action(msg, config)
local input = utilities.input_from_msg(msg) local input = utilities.input_from_msg(msg)
if not input then if not input then
utilities.send_reply(self, msg, cowsay.doc, true) utilities.send_reply(msg, cowsay.doc, true)
return return
end end
@ -34,7 +34,7 @@ function cowsay:action(msg, config)
text = '```'..run_command('cowsay "'..input..'"')..'```' text = '```'..run_command('cowsay "'..input..'"')..'```'
end end
utilities.send_reply(self, msg, text, true) utilities.send_reply(msg, text, true)
end end
return cowsay return cowsay

View File

@ -90,31 +90,31 @@ end
function creds_manager:action(msg, config, matches) function creds_manager:action(msg, config, matches)
local receiver = msg.from.id local receiver = msg.from.id
if receiver ~= config.admin then if receiver ~= config.admin then
utilities.send_reply(self, msg, config.errors.sudo) utilities.send_reply(msg, config.errors.sudo)
return return
end end
if msg.chat.type ~= 'private' then if msg.chat.type ~= 'private' then
utilities.send_reply(self, msg, 'Dieses Plugin solltest du nur [privat](http://telegram.me/' .. self.info.username .. '?start=creds) verwenden!', true) utilities.send_reply(msg, 'Dieses Plugin solltest du nur [privat](http://telegram.me/' .. self.info.username .. '?start=creds) verwenden!', true)
return return
end end
if matches[1] == "/creds" then if matches[1] == "/creds" then
utilities.send_reply(self, msg, creds_manager:list_creds()) utilities.send_reply(msg, creds_manager:list_creds())
return return
elseif matches[1] == "/creds add" then elseif matches[1] == "/creds add" then
local var = string.lower(string.sub(matches[2], 1, 50)) local var = string.lower(string.sub(matches[2], 1, 50))
local key = string.sub(matches[3], 1, 1000) local key = string.sub(matches[3], 1, 1000)
utilities.send_reply(self, msg, creds_manager:add_creds(var, key)) utilities.send_reply(msg, creds_manager:add_creds(var, key))
return return
elseif matches[1] == "/creds del" then elseif matches[1] == "/creds del" then
local var = string.lower(matches[2]) local var = string.lower(matches[2])
utilities.send_reply(self, msg, creds_manager:del_creds(var)) utilities.send_reply(msg, creds_manager:del_creds(var))
return return
elseif matches[1] == "/creds rename" then elseif matches[1] == "/creds rename" then
local var = string.lower(string.sub(matches[2], 1, 50)) local var = string.lower(string.sub(matches[2], 1, 50))
local newvar = string.lower(string.sub(matches[3], 1, 1000)) local newvar = string.lower(string.sub(matches[3], 1, 1000))
utilities.send_reply(self, msg, creds_manager:rename_creds(var, newvar)) utilities.send_reply(msg, creds_manager:rename_creds(var, newvar))
return return
end end
end end

View File

@ -39,7 +39,7 @@ function currency:inline_callback(inline_query, config, matches)
end end
local value, iserr = currency:convert_money(base, to, amount) local value, iserr = currency:convert_money(base, to, amount)
if iserr then utilities.answer_inline_query(self, inline_query) return end if iserr then abort_inline_query(inline_query) return end
local output = amount..' '..base..' = *'..value..' '..to..'*' local output = amount..' '..base..' = *'..value..' '..to..'*'
if tonumber(amount) == 1 then if tonumber(amount) == 1 then
@ -48,7 +48,7 @@ function currency:inline_callback(inline_query, config, matches)
title = amount..' '..base..' entsprechen' title = amount..' '..base..' entsprechen'
end end
local results = '[{"type":"article","id":"20","title":"'..title..'","description":"'..value..' '..to..'","thumb_url":"https://anditest.perseus.uberspace.de/inlineQuerys/currency/cash.jpg","thumb_width":157,"thumb_height":140,"input_message_content":{"message_text":"'..output..'","parse_mode":"Markdown"}}]' local results = '[{"type":"article","id":"20","title":"'..title..'","description":"'..value..' '..to..'","thumb_url":"https://anditest.perseus.uberspace.de/inlineQuerys/currency/cash.jpg","thumb_width":157,"thumb_height":140,"input_message_content":{"message_text":"'..output..'","parse_mode":"Markdown"}}]'
utilities.answer_inline_query(self, inline_query, results, 3600) utilities.answer_inline_query(inline_query, results, 3600)
end end
function currency:convert_money(base, to, amount) function currency:convert_money(base, to, amount)
@ -83,7 +83,7 @@ end
function currency:action(msg, config, matches) function currency:action(msg, config, matches)
if matches[1] == '/cash' then if matches[1] == '/cash' then
utilities.send_reply(self, msg, currency.doc, true) utilities.send_reply(msg, currency.doc, true)
return return
elseif not matches[2] then -- first pattern elseif not matches[2] then -- first pattern
base = 'EUR' base = 'EUR'
@ -100,24 +100,24 @@ function currency:action(msg, config, matches)
end end
if from == to then if from == to then
utilities.send_reply(self, msg, 'Jaja, sehr witzig...') utilities.send_reply(msg, 'Jaja, sehr witzig...')
return return
end end
local value = currency:convert_money(base, to, amount) local value = currency:convert_money(base, to, amount)
if value == 'NOCONNECT' then if value == 'NOCONNECT' then
utilities.send_reply(self, msg, config.errors.connection) utilities.send_reply(msg, config.errors.connection)
return return
elseif value == 'WRONGBASE' then elseif value == 'WRONGBASE' then
utilities.send_reply(self, msg, 'Keine gültige Basiswährung.') utilities.send_reply(msg, 'Keine gültige Basiswährung.')
return return
elseif value == 'WRONGCONVERTRATE' then elseif value == 'WRONGCONVERTRATE' then
utilities.send_reply(self, msg, 'Keine gültige Umwandlungswährung.') utilities.send_reply(msg, 'Keine gültige Umwandlungswährung.')
return return
end end
local output = amount..' '..base..' = *'..value..' '..to..'*' local output = amount..' '..base..' = *'..value..' '..to..'*'
utilities.send_reply(self, msg, output, true) utilities.send_reply(msg, output, true)
end end
return currency return currency

View File

@ -20,8 +20,8 @@ end
function dailymotion:action(msg, config, matches) function dailymotion:action(msg, config, matches)
local text = dailymotion:send_dailymotion_info(matches[1]) local text = dailymotion:send_dailymotion_info(matches[1])
if not text then utilities.send_reply(self, msg, config.errors.connection) return end if not text then utilities.send_reply(msg, config.errors.connection) return end
utilities.send_reply(self, msg, text, true) utilities.send_reply(msg, text, true)
end end
return dailymotion return dailymotion

View File

@ -47,13 +47,13 @@ end
function danbooru:action(msg, config, matches) function danbooru:action(msg, config, matches)
if matches[1] == 'danbooru.donmai.us' and matches[2] then if matches[1] == 'danbooru.donmai.us' and matches[2] then
local url = danbooru:get_specific_post(matches[2]) local url = danbooru:get_specific_post(matches[2])
if not url then utilities.send_reply(self, msg, config.errors.connection) return end if not url then utilities.send_reply(msg, config.errors.connection) return end
utilities.send_typing(self, msg.chat.id, 'upload_photo') utilities.send_typing(msg.chat.id, 'upload_photo')
local file = download_to_file(url) local file = download_to_file(url)
if string.ends(url, ".gif") or string.ends(url, ".zip") or string.ends(url, ".webm") then if string.ends(url, ".gif") or string.ends(url, ".zip") or string.ends(url, ".webm") then
utilities.send_document(self, msg.chat.id, file, nil, msg.message_id) utilities.send_document(msg.chat.id, file, nil, msg.message_id)
else else
utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id) utilities.send_photo(msg.chat.id, file, nil, msg.message_id)
end end
return return
end end
@ -81,12 +81,12 @@ function danbooru:action(msg, config, matches)
if post then if post then
local download_url = BASE_URL..post.large_file_url local download_url = BASE_URL..post.large_file_url
utilities.send_typing(self, msg.chat.id, 'upload_photo') utilities.send_typing(msg.chat.id, 'upload_photo')
local img = download_to_file(download_url) local img = download_to_file(download_url)
if string.ends(download_url, ".gif") or string.ends(download_url, ".zip") or string.ends(download_url, ".webm") then if string.ends(download_url, ".gif") or string.ends(download_url, ".zip") or string.ends(download_url, ".webm") then
utilities.send_document(self, msg.chat.id, img, nil, msg.message_id) utilities.send_document(msg.chat.id, img, nil, msg.message_id)
else else
utilities.send_photo(self, msg.chat.id, img, nil, msg.message_id) utilities.send_photo(msg.chat.id, img, nil, msg.message_id)
end end
local txt = '' local txt = ''
@ -100,11 +100,11 @@ function danbooru:action(msg, config, matches)
txt = txt .. '[' .. math.ceil(post.file_size/1000) .. 'kb] ' .. BASE_URL .. post.file_url txt = txt .. '[' .. math.ceil(post.file_size/1000) .. 'kb] ' .. BASE_URL .. post.file_url
end end
if txt ~= '' then if txt ~= '' then
utilities.send_reply(self, msg, txt) utilities.send_reply(msg, txt)
end end
return return
else else
utilities.send_reply(self, msg, config.errors.results) utilities.send_reply(msg, config.errors.results)
return return
end end
end end

View File

@ -26,18 +26,18 @@ end
function derpibooru:action(msg, config) function derpibooru:action(msg, config)
local input = utilities.input_from_msg(msg) local input = utilities.input_from_msg(msg)
if not input then if not input then
utilities.send_reply(self, msg, derpibooru.doc, true) utilities.send_reply(msg, derpibooru.doc, true)
return return
end end
local tag = string.gsub(input, " ", '+' ) local tag = string.gsub(input, " ", '+' )
local url, source = derpibooru:get_dp(tag) local url, source = derpibooru:get_dp(tag)
if not url then if not url then
utilities.send_reply(self, msg, config.errors.results) utilities.send_reply(msg, config.errors.results)
return return
end end
utilities.send_typing(self, msg.chat.id, 'upload_photo') utilities.send_typing(msg.chat.id, 'upload_photo')
local file = download_to_file(url) local file = download_to_file(url)
utilities.send_photo(self, msg.chat.id, file, source, msg.message_id) utilities.send_photo(msg.chat.id, file, source, msg.message_id)
end end
return derpibooru return derpibooru

View File

@ -32,18 +32,18 @@ end
function derpibooru_nsfw:action(msg, config) function derpibooru_nsfw:action(msg, config)
local input = utilities.input_from_msg(msg) local input = utilities.input_from_msg(msg)
if not input then if not input then
utilities.send_reply(self, msg, derpibooru_nsfw.doc, true) utilities.send_reply(msg, derpibooru_nsfw.doc, true)
return return
end end
local tag = string.gsub(input, " ", '+' ) local tag = string.gsub(input, " ", '+' )
local url, source = derpibooru_nsfw:get_dp(tag) local url, source = derpibooru_nsfw:get_dp(tag)
if not url then if not url then
utilities.send_reply(self, msg, config.errors.results) utilities.send_reply(msg, config.errors.results)
return return
end end
utilities.send_typing(self, msg.chat.id, 'upload_photo') utilities.send_typing(msg.chat.id, 'upload_photo')
local file = download_to_file(url) local file = download_to_file(url)
utilities.send_photo(self, msg.chat.id, file, source, msg.message_id) utilities.send_photo(msg.chat.id, file, source, msg.message_id)
end end
return derpibooru_nsfw return derpibooru_nsfw

View File

@ -34,13 +34,13 @@ end
function deviantart:action(msg, config, matches) function deviantart:action(msg, config, matches)
local data = deviantart:get_da_data('http://'..matches[1]..'.deviantart.com/art/'..matches[2]) local data = deviantart:get_da_data('http://'..matches[1]..'.deviantart.com/art/'..matches[2])
if not data then utilities.send_reply(self, msg, config.errors.connection) return end if not data then utilities.send_reply(msg, config.errors.connection) return end
local text, file = deviantart:send_da_data(data) local text, file = deviantart:send_da_data(data)
if file then if file then
utilities.send_photo(self, msg.chat.id, file, text, msg.message_id) utilities.send_photo(msg.chat.id, file, text, msg.message_id)
else else
utilities.send_reply(self, msg, text) utilities.send_reply(msg, text)
return return
end end
end end

View File

@ -28,7 +28,7 @@ end
function dhl:action(msg, config, matches) function dhl:action(msg, config, matches)
local sendungs_id = matches[1] local sendungs_id = matches[1]
if string.len(sendungs_id) < 8 then return end if string.len(sendungs_id) < 8 then return end
utilities.send_reply(self, msg, dhl:sendungsstatus(sendungs_id), true) utilities.send_reply(msg, dhl:sendungsstatus(sendungs_id), true)
end end
return dhl return dhl

View File

@ -12,19 +12,19 @@ dogify.command = 'dogify text/den/du/willst'
function dogify:action(msg, config, matches) function dogify:action(msg, config, matches)
local input = utilities.input_from_msg(msg) local input = utilities.input_from_msg(msg)
if not input then if not input then
utilities.send_reply(self, msg, dogify.doc, true) utilities.send_reply(msg, dogify.doc, true)
return return
end end
utilities.send_typing(self, msg.chat.id, 'upload_photo') utilities.send_typing(msg.chat.id, 'upload_photo')
local path = input:gsub(" ", "%%20") local path = input:gsub(" ", "%%20")
local photo_url = 'http://dogr.io/'..path..'.png?split=false&.png' local photo_url = 'http://dogr.io/'..path..'.png?split=false&.png'
local file = download_to_file(photo_url) local file = download_to_file(photo_url)
if not file then if not file then
utilities.send_reply(self, msg, config.errors.connection) utilities.send_reply(msg, config.errors.connection)
return return
end end
utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id) utilities.send_photo(msg.chat.id, file, nil, msg.message_id)
end end
return dogify return dogify

View File

@ -13,18 +13,18 @@ function dropbox:action(msg, config, matches)
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(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(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(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(msg.chat.id, file, nil, msg.message_id)
return return
else else
utilities.send_reply(self, msg, link) utilities.send_reply(msg, link)
end end
return return
else else

View File

@ -24,17 +24,17 @@ end
function e621:action(msg, config) function e621:action(msg, config)
local input = utilities.input_from_msg(msg) local input = utilities.input_from_msg(msg)
if not input then if not input then
utilities.send_reply(self, msg, e621.doc, true) utilities.send_reply(msg, e621.doc, true)
return return
end end
local url = e621:get_e621(input) local url = e621:get_e621(input)
if not url then if not url then
utilities.send_reply(self, msg, config.errors.results) utilities.send_reply(msg, config.errors.results)
return return
end end
utilities.send_typing(self, msg.chat.id, 'upload_photo') utilities.send_typing(msg.chat.id, 'upload_photo')
local file = download_to_file(url) local file = download_to_file(url)
utilities.send_photo(self, msg.chat.id, file, url, msg.message_id) utilities.send_photo(msg.chat.id, file, url, msg.message_id)
end end
return e621 return e621

View File

@ -22,18 +22,18 @@ function echo:inline_callback(inline_query, config, matches)
end end
local results = results..'{"type":"article","id":"4","thumb_url":"https://anditest.perseus.uberspace.de/inlineQuerys/echo/fett.jpg","title":"Fett","description":"*'..text..'*","input_message_content":{"message_text":"<b>'..text..'</b>","parse_mode":"HTML"}},{"type":"article","id":"5","thumb_url":"https://anditest.perseus.uberspace.de/inlineQuerys/echo/kursiv.jpg","title":"Kursiv","description":"_'..text..'_","input_message_content":{"message_text":"<i>'..text..'</i>","parse_mode":"HTML"}},{"type":"article","id":"6","thumb_url":"https://anditest.perseus.uberspace.de/inlineQuerys/echo/fixedsys.jpg","title":"Feste Breite","description":"`'..text..'`","input_message_content":{"message_text":"<code>'..text..'</code>","parse_mode":"HTML"}}]' local results = results..'{"type":"article","id":"4","thumb_url":"https://anditest.perseus.uberspace.de/inlineQuerys/echo/fett.jpg","title":"Fett","description":"*'..text..'*","input_message_content":{"message_text":"<b>'..text..'</b>","parse_mode":"HTML"}},{"type":"article","id":"5","thumb_url":"https://anditest.perseus.uberspace.de/inlineQuerys/echo/kursiv.jpg","title":"Kursiv","description":"_'..text..'_","input_message_content":{"message_text":"<i>'..text..'</i>","parse_mode":"HTML"}},{"type":"article","id":"6","thumb_url":"https://anditest.perseus.uberspace.de/inlineQuerys/echo/fixedsys.jpg","title":"Feste Breite","description":"`'..text..'`","input_message_content":{"message_text":"<code>'..text..'</code>","parse_mode":"HTML"}}]'
utilities.answer_inline_query(self, inline_query, results, 0) utilities.answer_inline_query(inline_query, results, 0)
end end
function echo:action(msg) function echo:action(msg)
local input = utilities.input_from_msg(msg) local input = utilities.input_from_msg(msg)
if not input then if not input then
utilities.send_message(self, msg.chat.id, echo.doc, true, msg.message_id, true) utilities.send_message(msg.chat.id, echo.doc, true, msg.message_id, true)
else else
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) utilities.send_message(msg.chat.id, output, true, nil, true)
return return
elseif msg.chat.type == 'group' then elseif msg.chat.type == 'group' then
local b = 1 local b = 1
@ -42,7 +42,7 @@ function echo:action(msg)
input,b = input:gsub('^/+','') input,b = input:gsub('^/+','')
end end
end end
utilities.send_message(self, msg.chat.id, input, true, nil, true) utilities.send_message(msg.chat.id, input, true, nil, true)
end end
end end

View File

@ -27,7 +27,7 @@ function expand:inline_callback(inline_query, config, matches)
end end
local results = '[{"type":"article","id":"7","title":"'..title..'","description":"'..description..'","url":"'..url..'","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":"'..url..'"}}]' local results = '[{"type":"article","id":"7","title":"'..title..'","description":"'..description..'","url":"'..url..'","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":"'..url..'"}}]'
utilities.answer_inline_query(self, inline_query, results, 3600) utilities.answer_inline_query(inline_query, results, 3600)
end end
function expand:url(long_url) function expand:url(long_url)
@ -47,10 +47,10 @@ end
function expand:action(msg, config, matches) function expand:action(msg, config, matches)
local ok, response_headers = expand:url(matches[1]) local ok, response_headers = expand:url(matches[1])
if ok and response_headers.location then if ok and response_headers.location then
utilities.send_reply(self, msg, response_headers.location) utilities.send_reply(msg, response_headers.location)
return return
else else
utilities.send_reply(self, msg, 'Fehler beim Erweitern der URL.') utilities.send_reply(msg, "Fehler beim Erweitern der URL.")
return return
end end
end end

View File

@ -136,7 +136,7 @@ function facebook:action(msg, config, matches)
else else
id = matches[4] id = matches[4]
end end
utilities.send_reply(self, msg, facebook:fb_post(id, story_id), 'HTML') utilities.send_reply(msg, facebook:fb_post(id, story_id), 'HTML')
return return
elseif matches[1] == 'photo' or matches[2] == 'photos' then elseif matches[1] == 'photo' or matches[2] == 'photos' then
if not matches[4] then if not matches[4] then
@ -146,10 +146,10 @@ function facebook:action(msg, config, matches)
end end
local text, image_url = facebook:send_facebook_photo(photo_id, receiver) local text, image_url = facebook:send_facebook_photo(photo_id, receiver)
if not image_url then return end if not image_url then return end
utilities.send_typing(self, msg.chat.id, 'upload_photo') utilities.send_typing(msg.chat.id, 'upload_photo')
local file = download_to_file(image_url, 'photo.jpg') local file = download_to_file(image_url, 'photo.jpg')
utilities.send_reply(self, msg, text, 'HTML') utilities.send_reply(msg, text, 'HTML')
utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id) utilities.send_photo(msg.chat.id, file, nil, msg.message_id)
return return
elseif matches[1] == 'video' or matches[2] == 'videos' then elseif matches[1] == 'video' or matches[2] == 'videos' then
if not matches[3] then if not matches[3] then
@ -164,10 +164,10 @@ function facebook:action(msg, config, matches)
title = 'VIDEO: '..title title = 'VIDEO: '..title
end end
if not video_url then return end if not video_url then return end
utilities.send_reply(self, msg, output, 'HTML', '{"inline_keyboard":[[{"text":"'..utilities.md_escape(title)..'","url":"'..video_url..'"}]]}') utilities.send_reply(msg, output, 'HTML', '{"inline_keyboard":[[{"text":"'..utilities.md_escape(title)..'","url":"'..video_url..'"}]]}')
return return
else else
utilities.send_reply(self, msg, facebook:facebook_info(matches[1]), 'HTML') utilities.send_reply(msg, facebook:facebook_info(matches[1]), 'HTML')
return return
end end
end end

View File

@ -49,21 +49,21 @@ end
function flickr:action(msg, config, matches) function flickr:action(msg, config, matches)
local data = flickr:get_flickr_photo_data(matches[2]) local data = flickr:get_flickr_photo_data(matches[2])
if not data then utilities.send_reply(self, msg, config.errors.connection) return end if not data then utilities.send_reply(msg, config.errors.connection) return end
local text, image_url, isgif = flickr:send_flickr_photo_data(data) local text, image_url, isgif = flickr:send_flickr_photo_data(data)
if image_url then if image_url then
utilities.send_typing(self, msg.chat.id, 'upload_photo') utilities.send_typing(msg.chat.id, 'upload_photo')
local file = download_to_file(image_url) local file = download_to_file(image_url)
if isgif then if isgif then
utilities.send_document(self, msg.chat.id, file, text, msg.message_id) utilities.send_document(msg.chat.id, file, text, msg.message_id)
return return
else else
utilities.send_photo(self, msg.chat.id, file, text, msg.message_id) utilities.send_photo(msg.chat.id, file, text, msg.message_id)
return return
end end
else else
utilities.send_reply(self, msg, text) utilities.send_reply(msg, text)
return return
end end
end end

View File

@ -32,15 +32,15 @@ end
function flickr_search:action(msg, config, matches) function flickr_search:action(msg, config, matches)
local url = flickr_search:get_flickr(matches[1]) local url = flickr_search:get_flickr(matches[1])
if not url then utilities.send_reply(self, msg, config.errors.results) return end if not url then utilities.send_reply(msg, config.errors.results) return end
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(msg.chat.id, file, url)
return return
else else
utilities.send_photo(self, msg.chat.id, file, url) utilities.send_photo(msg.chat.id, file, url)
return return
end end
end end

View File

@ -15,14 +15,14 @@ function flip:action(msg, config, matches)
local command = matches[1] local command = matches[1]
local text = matches[2] local text = matches[2]
if text:match('"') then if text:match('"') then
utilities.send_reply(self, msg, 'Vergiss es!') utilities.send_reply(msg, 'Vergiss es!')
return return
elseif command == 'flip' then elseif command == 'flip' then
new_text = run_command('flip "'..text..'"') new_text = run_command('flip "'..text..'"')
elseif command == 'rev' then elseif command == 'rev' then
new_text = run_command('echo "' .. text .. '" | rev') new_text = run_command('echo "' .. text .. '" | rev')
end end
utilities.send_reply(self, msg, new_text) utilities.send_reply(msg, new_text)
end end
return flip return flip

View File

@ -217,17 +217,17 @@ function forecast:inline_callback(inline_query, config, matches)
end end
local lat, lng = get_city_coordinates(city, config) local lat, lng = get_city_coordinates(city, config)
if not lat and not lng then utilities.answer_inline_query(self, inline_query) return end if not lat and not lng then abort_inline_query(inline_query) return end
if matches[1] == 'f' then if matches[1] == 'f' then
title, description, text, ttl = forecast:get_forecast(lat, lng, true) title, description, text, ttl = forecast:get_forecast(lat, lng, true)
else else
title, description, text, ttl = forecast:get_forecast_hourly(lat, lng, true) title, description, text, ttl = forecast:get_forecast_hourly(lat, lng, true)
end end
if not title and not description and not text and not ttl then utilities.answer_inline_query(self, inline_query) return end if not title and not description and not text and not ttl then abort_inline_query(inline_query) return end
local text = text:gsub('\n', '\\n') local text = text:gsub('\n', '\\n')
local results = '[{"type":"article","id":"28062013","title":"'..title..'","description":"'..description..'","thumb_url":"https://anditest.perseus.uberspace.de/inlineQuerys/weather/cloudy.jpg","thumb_width":80,"thumb_height":80,"input_message_content":{"message_text":"'..text..'", "parse_mode":"Markdown"}}]' local results = '[{"type":"article","id":"28062013","title":"'..title..'","description":"'..description..'","thumb_url":"https://anditest.perseus.uberspace.de/inlineQuerys/weather/cloudy.jpg","thumb_width":80,"thumb_height":80,"input_message_content":{"message_text":"'..text..'", "parse_mode":"Markdown"}}]'
utilities.answer_inline_query(self, inline_query, results, ttl, is_personal) utilities.answer_inline_query(inline_query, results, ttl, is_personal)
end end
function forecast:action(msg, config, matches) function forecast:action(msg, config, matches)
@ -246,7 +246,7 @@ function forecast:action(msg, config, matches)
local lat, lng = get_city_coordinates(city, config) local lat, lng = get_city_coordinates(city, config)
if not lat and not lng then if not lat and not lng then
utilities.send_reply(self, msg, '*Diesen Ort gibt es nicht!*', true) utilities.send_reply(msg, '*Diesen Ort gibt es nicht!*', true)
return return
end end
@ -258,7 +258,7 @@ function forecast:action(msg, config, matches)
if not text then if not text then
text = '*Konnte die Wettervorhersage für diese Stadt nicht bekommen.*' text = '*Konnte die Wettervorhersage für diese Stadt nicht bekommen.*'
end end
utilities.send_reply(self, msg, text, true) utilities.send_reply(msg, text, true)
end end
return forecast return forecast

View File

@ -29,8 +29,8 @@ gImages.command = 'img <Suchbegriff>'
-- Yes, the callback is copied from below, but I can't think of another method :\ -- Yes, the callback is copied from below, but I can't think of another method :\
function gImages:callback(callback, msg, self, config, input) function gImages:callback(callback, msg, self, config, input)
if not msg then return end if not msg then return end
utilities.answer_callback_query(self, callback, 'Suche nochmal nach "'..URL.unescape(input)..'"') utilities.answer_callback_query(callback, 'Suche nochmal nach "'..URL.unescape(input)..'"')
utilities.send_typing(self, msg.chat.id, 'upload_photo') utilities.send_typing(msg.chat.id, 'upload_photo')
local hash = 'telegram:cache:gImages' local hash = 'telegram:cache:gImages'
local results = redis:smembers(hash..':'..string.lower(URL.unescape(input))) local results = redis:smembers(hash..':'..string.lower(URL.unescape(input)))
@ -38,10 +38,10 @@ function gImages:callback(callback, msg, self, config, input)
print('doing web request') print('doing web request')
results = gImages:get_image(input) results = gImages:get_image(input)
if results == 403 then if results == 403 then
utilities.send_reply(self, msg, config.errors.quotaexceeded, true) utilities.send_reply(msg, config.errors.quotaexceeded, true)
return return
elseif not results then elseif not results then
utilities.send_reply(self, msg, config.errors.results, true) utilities.send_reply(msg, config.errors.results, true)
return return
end end
gImages:cache_result(results, input) gImages:cache_result(results, input)
@ -89,18 +89,18 @@ 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) utilities.send_reply(msg, 'Fehler beim Herunterladen eines Bildes.', true)
return return
end end
if mimetype == 'image/gif' then if mimetype == 'image/gif' then
result = utilities.send_document(self, msg.chat.id, file, nil, msg.message_id, '{"inline_keyboard":[[{"text":"Seite aufrufen","url":"'..context..'"},{"text":"Bild aufrufen","url":"'..img_url..'"},{"text":"Nochmal suchen","callback_data":"@'..self.info.username..' gImages:'..input..'"}]]}') result = utilities.send_document(msg.chat.id, file, nil, msg.message_id, '{"inline_keyboard":[[{"text":"Seite aufrufen","url":"'..context..'"},{"text":"Bild aufrufen","url":"'..img_url..'"},{"text":"Nochmal suchen","callback_data":"@'..self.info.username..' gImages:'..input..'"}]]}')
else else
result = utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id, '{"inline_keyboard":[[{"text":"Seite aufrufen","url":"'..context..'"},{"text":"Bild aufrufen","url":"'..img_url..'"},{"text":"Nochmal suchen","callback_data":"@'..self.info.username..' gImages:'..input..'"}]]}') result = utilities.send_photo(msg.chat.id, file, nil, msg.message_id, '{"inline_keyboard":[[{"text":"Seite aufrufen","url":"'..context..'"},{"text":"Bild aufrufen","url":"'..img_url..'"},{"text":"Nochmal suchen","callback_data":"@'..self.info.username..' gImages:'..input..'"}]]}')
end end
if not result then if not result then
utilities.send_reply(self, msg, config.errors.connection, true, '{"inline_keyboard":[[{"text":"Nochmal versuchen","callback_data":"@'..self.info.username..' gImages:'..input..'"}]]}') utilities.send_reply(msg, config.errors.connection, true, '{"inline_keyboard":[[{"text":"Nochmal versuchen","callback_data":"@'..self.info.username..' gImages:'..input..'"}]]}')
return return
end end
end end
@ -147,18 +147,18 @@ function gImages:action(msg, config, matches)
if msg.reply_to_message and msg.reply_to_message.text then if msg.reply_to_message and msg.reply_to_message.text then
input = msg.reply_to_message.text input = msg.reply_to_message.text
else else
utilities.send_message(self, msg.chat.id, gImages.doc, true, msg.message_id, true) utilities.send_message(msg.chat.id, gImages.doc, true, msg.message_id, true)
return return
end end
end end
print ('Überprüfe, ob das Wort auf der Blackliste steht: '..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(msg, 'Vergiss es!')
return return
end end
utilities.send_typing(self, msg.chat.id, 'upload_photo') utilities.send_typing(msg.chat.id, 'upload_photo')
local hash = 'telegram:cache:gImages' local hash = 'telegram:cache:gImages'
local results = redis:smembers(hash..':'..string.lower(input)) local results = redis:smembers(hash..':'..string.lower(input))
@ -167,10 +167,10 @@ function gImages:action(msg, config, matches)
print('doing web request') print('doing web request')
results = gImages:get_image(URL.escape(input)) results = gImages:get_image(URL.escape(input))
if results == 403 then if results == 403 then
utilities.send_reply(self, msg, config.errors.quotaexceeded, true) utilities.send_reply(msg, config.errors.quotaexceeded, true)
return return
elseif not results or results == 'NORESULTS' then elseif not results or results == 'NORESULTS' then
utilities.send_reply(self, msg, config.errors.results, true) utilities.send_reply(msg, config.errors.results, true)
return return
end end
gImages:cache_result(results, input) gImages:cache_result(results, input)
@ -218,18 +218,18 @@ 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) utilities.send_reply(msg, 'Fehler beim Herunterladen eines Bildes.', true)
return return
end end
if mimetype == 'image/gif' then if mimetype == 'image/gif' then
result = utilities.send_document(self, msg.chat.id, file, nil, msg.message_id, '{"inline_keyboard":[[{"text":"Seite aufrufen","url":"'..context..'"},{"text":"Bild aufrufen","url":"'..img_url..'"},{"text":"Nochmal suchen","callback_data":"@'..self.info.username..' gImages:'..URL.escape(input)..'"}]]}') result = utilities.send_document(msg.chat.id, file, nil, msg.message_id, '{"inline_keyboard":[[{"text":"Seite aufrufen","url":"'..context..'"},{"text":"Bild aufrufen","url":"'..img_url..'"},{"text":"Nochmal suchen","callback_data":"@'..self.info.username..' gImages:'..URL.escape(input)..'"}]]}')
else else
result = utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id, '{"inline_keyboard":[[{"text":"Seite aufrufen","url":"'..context..'"},{"text":"Bild aufrufen","url":"'..img_url..'"},{"text":"Nochmal suchen","callback_data":"@'..self.info.username..' gImages:'..URL.escape(input)..'"}]]}') result = utilities.send_photo(msg.chat.id, file, nil, msg.message_id, '{"inline_keyboard":[[{"text":"Seite aufrufen","url":"'..context..'"},{"text":"Bild aufrufen","url":"'..img_url..'"},{"text":"Nochmal suchen","callback_data":"@'..self.info.username..' gImages:'..URL.escape(input)..'"}]]}')
end end
if not result then if not result then
utilities.send_reply(self, msg, config.errors.connection, true, '{"inline_keyboard":[[{"text":"Nochmal versuchen","callback_data":"@'..self.info.username..' gImages:'..URL.escape(input)..'"}]]}') utilities.send_reply(msg, config.errors.connection, true, '{"inline_keyboard":[[{"text":"Nochmal versuchen","callback_data":"@'..self.info.username..' gImages:'..URL.escape(input)..'"}]]}')
return return
end end
end end

View File

@ -29,8 +29,8 @@ gImages_nsfw.command = 'img2 <Suchbegriff>'
-- Yes, the callback is copied from below, but I can't think of another method :\ -- Yes, the callback is copied from below, but I can't think of another method :\
function gImages_nsfw:callback(callback, msg, self, config, input) function gImages_nsfw:callback(callback, msg, self, config, input)
if not msg then return end if not msg then return end
utilities.answer_callback_query(self, callback, 'Suche nochmal nach "'..URL.unescape(input)..'"') utilities.answer_callback_query(callback, 'Suche nochmal nach "'..URL.unescape(input)..'"')
utilities.send_typing(self, msg.chat.id, 'upload_photo') utilities.send_typing(msg.chat.id, 'upload_photo')
local hash = 'telegram:cache:gImages_nsfw' local hash = 'telegram:cache:gImages_nsfw'
local results = redis:smembers(hash..':'..string.lower(URL.unescape(input))) local results = redis:smembers(hash..':'..string.lower(URL.unescape(input)))
@ -38,10 +38,10 @@ function gImages_nsfw:callback(callback, msg, self, config, input)
print('doing web request') print('doing web request')
results = gImages_nsfw:get_image(input) results = gImages_nsfw:get_image(input)
if results == 403 then if results == 403 then
utilities.send_reply(self, msg, config.errors.quotaexceeded, true) utilities.send_reply(msg, config.errors.quotaexceeded, true)
return return
elseif not results then elseif not results then
utilities.send_reply(self, msg, config.errors.results, true) utilities.send_reply(msg, config.errors.results, true)
return return
end end
gImages_nsfw:cache_result(results, input) gImages_nsfw:cache_result(results, input)
@ -89,18 +89,18 @@ 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) utilities.send_reply(msg, 'Fehler beim Herunterladen eines Bildes.', true)
return return
end end
if mimetype == 'image/gif' then if mimetype == 'image/gif' then
result = utilities.send_document(self, msg.chat.id, file, nil, msg.message_id, '{"inline_keyboard":[[{"text":"Seite aufrufen","url":"'..context..'"},{"text":"Bild aufrufen","url":"'..img_url..'"},{"text":"Nochmal suchen","callback_data":"@'..self.info.username..' gImages_nsfw:'..input..'"}]]}') result = utilities.send_document(msg.chat.id, file, nil, msg.message_id, '{"inline_keyboard":[[{"text":"Seite aufrufen","url":"'..context..'"},{"text":"Bild aufrufen","url":"'..img_url..'"},{"text":"Nochmal suchen","callback_data":"@'..self.info.username..' gImages_nsfw:'..input..'"}]]}')
else else
result = utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id, '{"inline_keyboard":[[{"text":"Seite aufrufen","url":"'..context..'"},{"text":"Bild aufrufen","url":"'..img_url..'"},{"text":"Nochmal suchen","callback_data":"@'..self.info.username..' gImages_nsfw:'..input..'"}]]}') result = utilities.send_photo(msg.chat.id, file, nil, msg.message_id, '{"inline_keyboard":[[{"text":"Seite aufrufen","url":"'..context..'"},{"text":"Bild aufrufen","url":"'..img_url..'"},{"text":"Nochmal suchen","callback_data":"@'..self.info.username..' gImages_nsfw:'..input..'"}]]}')
end end
if not result then if not result then
utilities.send_reply(self, msg, config.errors.connection, true, '{"inline_keyboard":[[{"text":"Nochmal versuchen","callback_data":"@'..self.info.username..' gImages_nsfw:'..input..'"}]]}') utilities.send_reply(msg, config.errors.connection, true, '{"inline_keyboard":[[{"text":"Nochmal versuchen","callback_data":"@'..self.info.username..' gImages_nsfw:'..input..'"}]]}')
return return
end end
end end
@ -147,18 +147,18 @@ function gImages_nsfw:action(msg, config, matches)
if msg.reply_to_message and msg.reply_to_message.text then if msg.reply_to_message and msg.reply_to_message.text then
input = msg.reply_to_message.text input = msg.reply_to_message.text
else else
utilities.send_message(self, msg.chat.id, gImages_nsfw.doc, true, msg.message_id, true) utilities.send_message(msg.chat.id, gImages_nsfw.doc, true, msg.message_id, true)
return return
end end
end end
print ('Überprüfe, ob das Wort auf der Blackliste steht: '..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(msg, 'Vergiss es!')
return return
end end
utilities.send_typing(self, msg.chat.id, 'upload_photo') utilities.send_typing(msg.chat.id, 'upload_photo')
local hash = 'telegram:cache:gImages_nsfw' local hash = 'telegram:cache:gImages_nsfw'
local results = redis:smembers(hash..':'..string.lower(input)) local results = redis:smembers(hash..':'..string.lower(input))
@ -167,10 +167,10 @@ function gImages_nsfw:action(msg, config, matches)
print('doing web request') print('doing web request')
results = gImages_nsfw:get_image(URL.escape(input)) results = gImages_nsfw:get_image(URL.escape(input))
if results == 403 then if results == 403 then
utilities.send_reply(self, msg, config.errors.quotaexceeded, true) utilities.send_reply(msg, config.errors.quotaexceeded, true)
return return
elseif not results or results == 'NORESULTS' then elseif not results or results == 'NORESULTS' then
utilities.send_reply(self, msg, config.errors.results, true) utilities.send_reply(msg, config.errors.results, true)
return return
end end
gImages_nsfw:cache_result(results, input) gImages_nsfw:cache_result(results, input)
@ -218,18 +218,18 @@ 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) utilities.send_reply(msg, 'Fehler beim Herunterladen eines Bildes.', true)
return return
end end
if mimetype == 'image/gif' then if mimetype == 'image/gif' then
result = utilities.send_document(self, msg.chat.id, file, nil, msg.message_id, '{"inline_keyboard":[[{"text":"Seite aufrufen","url":"'..context..'"},{"text":"Bild aufrufen","url":"'..img_url..'"},{"text":"Nochmal suchen","callback_data":"@'..self.info.username..' gImages_nsfw:'..URL.escape(input)..'"}]]}') result = utilities.send_document(msg.chat.id, file, nil, msg.message_id, '{"inline_keyboard":[[{"text":"Seite aufrufen","url":"'..context..'"},{"text":"Bild aufrufen","url":"'..img_url..'"},{"text":"Nochmal suchen","callback_data":"@'..self.info.username..' gImages_nsfw:'..URL.escape(input)..'"}]]}')
else else
result = utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id, '{"inline_keyboard":[[{"text":"Seite aufrufen","url":"'..context..'"},{"text":"Bild aufrufen","url":"'..img_url..'"},{"text":"Nochmal suchen","callback_data":"@'..self.info.username..' gImages_nsfw:'..URL.escape(input)..'"}]]}') result = utilities.send_photo(msg.chat.id, file, nil, msg.message_id, '{"inline_keyboard":[[{"text":"Seite aufrufen","url":"'..context..'"},{"text":"Bild aufrufen","url":"'..img_url..'"},{"text":"Nochmal suchen","callback_data":"@'..self.info.username..' gImages_nsfw:'..URL.escape(input)..'"}]]}')
end end
if not result then if not result then
utilities.send_reply(self, msg, config.errors.connection, true, '{"inline_keyboard":[[{"text":"Nochmal versuchen","callback_data":"@'..self.info.username..' gImages_nsfw:'..URL.escape(input)..'"}]]}') utilities.send_reply(msg, config.errors.connection, true, '{"inline_keyboard":[[{"text":"Nochmal versuchen","callback_data":"@'..self.info.username..' gImages_nsfw:'..URL.escape(input)..'"}]]}')
return return
end end
end end

View File

@ -22,29 +22,29 @@ end
function gMaps:inline_callback(inline_query, config, matches) function gMaps:inline_callback(inline_query, config, matches)
local place = matches[1] local place = matches[1]
local coords = utilities.get_coords(place, config) local coords = utilities.get_coords(place, config)
if type(coords) == 'string' then utilities.answer_inline_query(self, inline_query) return end if type(coords) == 'string' then abort_inline_query(inline_query) return end
local results = '[{"type":"venue","id":"10","latitude":'..coords.lat..',"longitude":'..coords.lon..',"title":"Ort","address":"'..coords.addr..'"}]' local results = '[{"type":"venue","id":"10","latitude":'..coords.lat..',"longitude":'..coords.lon..',"title":"Ort","address":"'..coords.addr..'"}]'
utilities.answer_inline_query(self, inline_query, results, 10000) utilities.answer_inline_query(inline_query, results, 10000)
end end
function gMaps:action(msg, config) function gMaps:action(msg, config)
local input = utilities.input_from_msg(msg) local input = utilities.input_from_msg(msg)
if not input then if not input then
utilities.send_reply(self, msg, gMaps.doc, true) utilities.send_reply(msg, gMaps.doc, true)
return return
end end
utilities.send_typing(self, msg.chat.id, 'find_location') utilities.send_typing(msg.chat.id, 'find_location')
local coords = utilities.get_coords(input, config) local coords = utilities.get_coords(input, config)
if type(coords) == 'string' then if type(coords) == 'string' then
utilities.send_reply(self, msg, coords) utilities.send_reply(msg, coords)
return return
end end
utilities.send_location(self, msg.chat.id, coords.lat, coords.lon, msg.message_id) utilities.send_location(msg.chat.id, coords.lat, coords.lon, msg.message_id)
utilities.send_photo(self, msg.chat.id, gMaps:get_staticmap(input, coords.lat, coords.lon), nil, msg.message_id) utilities.send_photo(msg.chat.id, gMaps:get_staticmap(input, coords.lat, coords.lon), nil, msg.message_id)
end end
return gMaps return gMaps

View File

@ -23,7 +23,7 @@ function gSearch:googlethat(query, config)
return '403' return '403'
end end
if code ~= 200 then if code ~= 200 then
utilities.send_reply(self, msg, config.errors.connection) utilities.send_reply(msg, config.errors.connection)
return return
end end
local data = json.decode(res) local data = json.decode(res)
@ -53,22 +53,22 @@ end
function gSearch:action(msg, config) function gSearch:action(msg, config)
local input = utilities.input_from_msg(msg) local input = utilities.input_from_msg(msg)
if not input then if not input then
utilities.send_reply(self, msg, gSearch.doc, true) utilities.send_reply(msg, gSearch.doc, true)
return return
end end
local results, stats = gSearch:googlethat(input, onfig) local results, stats = gSearch:googlethat(input, onfig)
if results == '403' then if results == '403' then
utilities.send_reply(self, msg, config.errors.quotaexceeded) utilities.send_reply(msg, config.errors.quotaexceeded)
return return
end end
if not results then if not results then
utilities.send_reply(self, msg, config.errors.results) utilities.send_reply(msg, config.errors.results)
return return
end end
utilities.send_message(self, msg.chat.id, gSearch:stringlinks(results, stats), true, nil, true, '{"inline_keyboard":[[{"text":"Alle Ergebnisse anzeigen","url":"https://www.google.com/search?q='..URL.escape(input)..'"}]]}') utilities.send_message(msg.chat.id, gSearch:stringlinks(results, stats), true, nil, true, '{"inline_keyboard":[[{"text":"Alle Ergebnisse anzeigen","url":"https://www.google.com/search?q='..URL.escape(input)..'"}]]}')
end end

View File

@ -48,7 +48,7 @@ function games:send_game_photo(result, self, msg)
for k, v in pairs(images) do for k, v in pairs(images) do
i = i+1 i = i+1
local file = download_to_file(v, 'game'..i..'.jpg') local file = download_to_file(v, 'game'..i..'.jpg')
utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id) utilities.send_photo(msg.chat.id, file, nil, msg.message_id)
end end
end end
@ -113,10 +113,10 @@ function games:send_game_data(game_id, self, msg)
end end
local text = '*'..title..'* für *'..platform..'*'..date..desc..genre..players..video..publisher local text = '*'..title..'* für *'..platform..'*'..date..desc..genre..players..video..publisher
utilities.send_reply(self, msg, text, true) utilities.send_reply(msg, text, true)
if xml.find(result, 'boxart') then if xml.find(result, 'boxart') then
utilities.send_typing(self, msg.chat.id, 'upload_photo') utilities.send_typing(msg.chat.id, 'upload_photo')
games:send_game_photo(result, self, msg) games:send_game_photo(result, self, msg)
end end
return return
@ -128,14 +128,14 @@ function games:action(msg, config)
if msg.reply_to_message and msg.reply_to_message.text then if msg.reply_to_message and msg.reply_to_message.text then
game = msg.reply_to_message.text game = msg.reply_to_message.text
else else
utilities.send_message(self, msg.chat.id, fun.doc, true, msg.message_id, true) utilities.send_message(msg.chat.id, fun.doc, true, msg.message_id, true)
return return
end end
end end
local game_id = games:get_game_id(game) local game_id = games:get_game_id(game)
if not game_id then if not game_id then
utilities.send_reply(self, msg, 'Spiel nicht gefunden!') utilities.send_reply(msg, 'Spiel nicht gefunden!')
return return
else else
games:send_game_data(game_id, self, msg) games:send_game_data(game_id, self, msg)

View File

@ -38,15 +38,15 @@ function gdrive:send_drive_document_data(data, self, msg)
if mimetype:match('google') then -- if document is Google document (like a Spreadsheet) if mimetype:match('google') then -- if document is Google document (like a Spreadsheet)
if mimetype:match('drawing') then -- Drawing if mimetype:match('drawing') then -- Drawing
local image_url = BASE_URL..'/files/'..id..'/export?key='..apikey..'&mimeType=image/png' local image_url = BASE_URL..'/files/'..id..'/export?key='..apikey..'&mimeType=image/png'
utilities.send_typing(self, msg.chat.id, 'upload_photo') utilities.send_typing(msg.chat.id, 'upload_photo')
local file = download_to_file(image_url, 'export.png') local file = download_to_file(image_url, 'export.png')
utilities.send_photo(self, msg.chat.id, file, text, msg.message_id) utilities.send_photo(msg.chat.id, file, text, msg.message_id)
return return
else else
local pdf_url = BASE_URL..'/files/'..id..'/export?key='..apikey..'&mimeType=application/pdf' local pdf_url = BASE_URL..'/files/'..id..'/export?key='..apikey..'&mimeType=application/pdf'
utilities.send_typing(self, msg.chat.id, 'upload_document') utilities.send_typing(msg.chat.id, 'upload_document')
local file = download_to_file(pdf_url, 'document.pdf') local file = download_to_file(pdf_url, 'document.pdf')
utilities.send_document(self, msg.chat.id, file, text, msg.message_id) utilities.send_document(msg.chat.id, file, text, msg.message_id)
return return
end end
else else
@ -65,19 +65,19 @@ function gdrive:send_drive_document_data(data, self, msg)
local headers = response[3] local headers = response[3]
local file_url = headers.location local file_url = headers.location
if ext == "jpg" or ext == "jpeg" or ext == "png" then if ext == "jpg" or ext == "jpeg" or ext == "png" then
utilities.send_typing(self, msg.chat.id, 'upload_photo') utilities.send_typing(msg.chat.id, 'upload_photo')
local file = download_to_file(file_url, 'photo.'..ext) local file = download_to_file(file_url, 'photo.'..ext)
utilities.send_photo(self, msg.chat.id, file, text, msg.message_id, keyboard) utilities.send_photo(msg.chat.id, file, text, msg.message_id, keyboard)
return return
else else
utilities.send_typing(self, msg.chat.id, 'upload_document') utilities.send_typing(msg.chat.id, 'upload_document')
local file = download_to_file(file_url, 'document.'..ext) local file = download_to_file(file_url, 'document.'..ext)
utilities.send_document(self, msg.chat.id, file, text, msg.message_id, keyboard) utilities.send_document(msg.chat.id, file, text, msg.message_id, keyboard)
return return
end end
else else
local text = '*'..title..'*, freigegeben von _'..owner..'_' local text = '*'..title..'*, freigegeben von _'..owner..'_'
utilities.send_reply(self, msg, text, true, keyboard) utilities.send_reply(msg, text, true, keyboard)
return return
end end
end end
@ -86,7 +86,7 @@ end
function gdrive:action(msg, config, matches) function gdrive:action(msg, config, matches)
local docid = matches[2] local docid = matches[2]
local data = gdrive:get_drive_document_data(docid) local data = gdrive:get_drive_document_data(docid)
if not data then utilities.send_reply(self, msg, config.errors.connection) return end if not data then utilities.send_reply(msg, config.errors.connection) return end
gdrive:send_drive_document_data(data, self, msg) gdrive:send_drive_document_data(data, self, msg)
return return
end end

View File

@ -50,7 +50,7 @@ function get:action(msg)
output = get:list_variables(msg) output = get:list_variables(msg)
end end
utilities.send_message(self, msg.chat.id, output, true, nil, true) utilities.send_message(msg.chat.id, output, true, nil, true)
end end
return get return get

View File

@ -10,17 +10,17 @@ get_data.command = 'me'
function get_data:action(msg, config) function get_data:action(msg, config)
local input = utilities.input_from_msg(msg) local input = utilities.input_from_msg(msg)
if not input then if not input then
utilities.send_reply(self, msg, get_data.doc, true) utilities.send_reply(msg, get_data.doc, true)
return return
end end
utilities.send_typing(self, msg.chat.id, 'upload_document') utilities.send_typing(msg.chat.id, 'upload_document')
local file = download_to_file(input) local file = download_to_file(input)
if not file then if not file then
utilities.send_reply(self, msg, config.errors.connection) utilities.send_reply(msg, config.errors.connection)
return return
end end
utilities.send_document(self, msg.chat.id, file, nil, msg.message_id) utilities.send_document(msg.chat.id, file, nil, msg.message_id)
end end
return get_data return get_data

View File

@ -12,10 +12,10 @@ function get_txt:action(msg, config, matches)
end end
local res, code = doer.request(url) local res, code = doer.request(url)
if code ~= 200 then if code ~= 200 then
utilities.send_reply(self, msg, config.errors.connection) utilities.send_reply(msg, config.errors.connection)
return return
end end
utilities.send_reply(self, msg, res) utilities.send_reply(msg, res)
end end
return get_txt return get_txt

View File

@ -31,7 +31,7 @@ function media_download:download_to_file_permanently(url, save_dir, file_name)
return true return true
end end
function media_download:pre_process(msg, self, config) function media_download:pre_process(msg, config)
if msg.photo then if msg.photo then
local lv = #msg.photo -- find biggest photo, always the last value local lv = #msg.photo -- find biggest photo, always the last value
file_id = msg.photo[lv].file_id file_id = msg.photo[lv].file_id
@ -74,7 +74,7 @@ function media_download:pre_process(msg, self, config)
end end
-- Saving file to the Telegram Cloud -- Saving file to the Telegram Cloud
local request = bindings.request(self, 'getFile', { local request = bindings.request('getFile', {
file_id = file_id file_id = file_id
} ) } )

View File

@ -6,26 +6,26 @@ gfycat.triggers = {
"gfycat.com/([A-Za-z0-9-_-]+)" "gfycat.com/([A-Za-z0-9-_-]+)"
} }
function gfycat:send_gfycat_video(name, self, msg) function gfycat:send_gfycat_video(name, msg)
local BASE_URL = "https://gfycat.com" local BASE_URL = "https://gfycat.com"
local url = BASE_URL..'/cajax/get/'..name local url = BASE_URL..'/cajax/get/'..name
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 "HTTP-FEHLER" end
local data = json.decode(res).gfyItem local data = json.decode(res).gfyItem
utilities.send_typing(self, msg.chat.id, 'upload_video') utilities.send_typing(msg.chat.id, 'upload_video')
local file = download_to_file(data.webmUrl) local file = download_to_file(data.webmUrl)
if file == nil then if file == nil then
send_reply(self, msg, 'Fehler beim Herunterladen von '..name) send_reply(msg, 'Fehler beim Herunterladen von '..name)
return return
else else
utilities.send_video(self, msg.chat.id, file, nil, msg.message_id) utilities.send_video(msg.chat.id, file, nil, msg.message_id)
return return
end end
end end
function gfycat:action(msg, config, matches) function gfycat:action(msg, config, matches)
local name = matches[1] local name = matches[1]
gfycat:send_gfycat_video(name, self, msg) gfycat:send_gfycat_video(name, msg)
return return
end end

View File

@ -14,10 +14,10 @@ gifeye.command = 'ge <ID>'
function gifeye:action(msg, config, matches) function gifeye:action(msg, config, matches)
local url = 'http://i.gifeye.com/'..matches[1]..'.gif' local url = 'http://i.gifeye.com/'..matches[1]..'.gif'
utilities.send_typing(self, msg.chat.id, 'upload_document') utilities.send_typing(msg.chat.id, 'upload_document')
local file = download_to_file(url) local file = download_to_file(url)
if not file then if not file then
utilities.send_reply(self, msg, config.errors.results) utilities.send_reply(msg, config.errors.results)
return return
end end
@ -26,7 +26,7 @@ function gifeye:action(msg, config, matches)
else else
source = nil source = nil
end end
utilities.send_document(self, msg.chat.id, file, source, msg.message_id) utilities.send_document(msg.chat.id, file, source, msg.message_id)
end end
return gifeye return gifeye

View File

@ -30,8 +30,8 @@ function giphy:inline_callback(inline_query, config, matches)
else else
data = giphy:get_gifs(matches[2]) data = giphy:get_gifs(matches[2])
end end
if not data then utilities.answer_inline_query(self, inline_query) return end if not data then abort_inline_query(inline_query) return end
if not data[1] then utilities.answer_inline_query(self, inline_query) return end if not data[1] then abort_inline_query(inline_query) return end
local results = '[' local results = '['
local id = 450 local id = 450
@ -43,7 +43,7 @@ function giphy:inline_callback(inline_query, config, matches)
end end
end end
local results = results..']' local results = results..']'
utilities.answer_inline_query(self, inline_query, results, 3600) utilities.answer_inline_query(inline_query, results, 3600)
end end
function giphy:action() function giphy:action()

View File

@ -63,7 +63,7 @@ function github:action(msg, config, matches)
else else
output = github:send_gh_commit_data(gh_code, gh_commit_sha, data) output = github:send_gh_commit_data(gh_code, gh_commit_sha, data)
end end
utilities.send_reply(self, msg, output, true) utilities.send_reply(msg, output, true)
end end
return github return github

View File

@ -181,42 +181,42 @@ function gh_feed:action(msg, config, matches)
-- For channels -- For channels
if matches[1] == 'sub' and matches[2] and matches[3] then if matches[1] == 'sub' and matches[2] and matches[3] then
if msg.from.id ~= config.admin then if msg.from.id ~= config.admin then
utilities.send_reply(self, msg, config.errors.sudo) utilities.send_reply(msg, config.errors.sudo)
return return
end end
local id = '@'..matches[3] local id = '@'..matches[3]
local result = utilities.get_chat_info(self, id) local result = utilities.get_chat_info(id)
if not result then if not result then
utilities.send_reply(self, msg, 'Diesen Kanal gibt es nicht!') utilities.send_reply(msg, 'Diesen Kanal gibt es nicht!')
return return
end end
local output = gh_feed:subscribe(id, matches[2]) local output = gh_feed:subscribe(id, matches[2])
utilities.send_reply(self, msg, output, true) utilities.send_reply(msg, output, true)
return return
elseif matches[1] == 'del' and matches[2] and matches[3] then elseif matches[1] == 'del' and matches[2] and matches[3] then
if msg.from.id ~= config.admin then if msg.from.id ~= config.admin then
utilities.send_reply(self, msg, config.errors.sudo) utilities.send_reply(msg, config.errors.sudo)
return return
end end
local id = '@'..matches[3] local id = '@'..matches[3]
local result = utilities.get_chat_info(self, id) local result = utilities.get_chat_info(id)
if not result then if not result then
utilities.send_reply(self, msg, 'Diesen Kanal gibt es nicht!') utilities.send_reply(msg, 'Diesen Kanal gibt es nicht!')
return return
end end
local output = gh_feed:unsubscribe(id, matches[2]) local output = gh_feed:unsubscribe(id, matches[2])
utilities.send_reply(self, msg, output, true) utilities.send_reply(msg, output, true)
return return
elseif matches[1] == 'gh' and matches[2] then elseif matches[1] == 'gh' and matches[2] then
local id = '@'..matches[2] local id = '@'..matches[2]
local result = utilities.get_chat_info(self, id) local result = utilities.get_chat_info(id)
if not result then if not result then
utilities.send_reply(self, msg, 'Diesen Kanal gibt es nicht!') utilities.send_reply(msg, 'Diesen Kanal gibt es nicht!')
return return
end end
local chat_name = result.result.title local chat_name = result.result.title
local output = gh_feed:print_subs(id, chat_name) local output = gh_feed:print_subs(id, chat_name)
utilities.send_reply(self, msg, output, true) utilities.send_reply(msg, output, true)
return return
end end
@ -228,42 +228,39 @@ function gh_feed:action(msg, config, matches)
if matches[1] == 'sub' and matches[2] then if matches[1] == 'sub' and matches[2] then
if msg.from.id ~= config.admin then if msg.from.id ~= config.admin then
utilities.send_reply(self, msg, config.errors.sudo) utilities.send_reply(msg, config.errors.sudo)
return return
end end
local output = gh_feed:subscribe(id, matches[2]) local output = gh_feed:subscribe(id, matches[2])
utilities.send_reply(self, msg, output, true) utilities.send_reply(msg, output, true)
return return
elseif matches[1] == 'del' and matches[2] then elseif matches[1] == 'del' and matches[2] then
if msg.from.id ~= config.admin then if msg.from.id ~= config.admin then
utilities.send_reply(self, msg, config.errors.sudo) utilities.send_reply(msg, config.errors.sudo)
return return
end end
local output = gh_feed:unsubscribe(id, matches[2]) local output = gh_feed:unsubscribe(id, matches[2])
utilities.send_reply(self, msg, output, true, '{"hide_keyboard":true}') utilities.send_reply(msg, output, true, '{"hide_keyboard":true}')
return return
elseif matches[1] == 'del' and not matches[2] then elseif matches[1] == 'del' and not matches[2] then
local list_subs, keyboard = gh_feed:print_subs(id, chat_name) local list_subs, keyboard = gh_feed:print_subs(id, chat_name)
utilities.send_reply(self, msg, list_subs, true, keyboard) utilities.send_reply(msg, list_subs, true, keyboard)
return return
elseif matches[1] == 'sync' then elseif matches[1] == 'sync' then
if msg.from.id ~= config.admin then if msg.from.id ~= config.admin then
utilities.send_reply(self, msg, config.errors.sudo) utilities.send_reply(msg, config.errors.sudo)
return return
end end
gh_feed:cron(self) gh_feed:cron()
return return
end end
local output = gh_feed:print_subs(id, chat_name) local output = gh_feed:print_subs(id, chat_name)
utilities.send_reply(self, msg, output, true) utilities.send_reply(msg, output, true)
return return
end end
function gh_feed:cron(self_plz) function gh_feed:cron()
if not self.BASE_URL then
self = self_plz
end
local keys = redis:keys(gh_feed_get_base_redis("*", "subs")) local keys = redis:keys(gh_feed_get_base_redis("*", "subs"))
for k,v in pairs(keys) do for k,v in pairs(keys) do
local repo = string.match(v, "github:(.+):subs") local repo = string.match(v, "github:(.+):subs")
@ -292,7 +289,7 @@ function gh_feed:cron(self_plz)
redis:set(gh_feed_get_base_redis(repo, "etag"), last_etag) redis:set(gh_feed_get_base_redis(repo, "etag"), last_etag)
redis:set(gh_feed_get_base_redis(repo, "date"), last_date) redis:set(gh_feed_get_base_redis(repo, "date"), last_date)
for k2, receiver in pairs(redis:smembers(v)) do for k2, receiver in pairs(redis:smembers(v)) do
utilities.send_message(self, receiver, text, true, nil, true) utilities.send_message(receiver, text, true, nil, true)
end end
end end
end end

View File

@ -25,10 +25,10 @@ end
function googl:inline_callback(inline_query, config, matches) function googl:inline_callback(inline_query, config, matches)
local shorturl = matches[1] local shorturl = matches[1]
local text, longUrl = googl:send_googl_info(shorturl) local text, longUrl = googl:send_googl_info(shorturl)
if not longUrl then utilities.answer_inline_query(self, inline_query) return end if not longUrl then abort_inline_query(inline_query) return end
local results = '[{"type":"article","id":"9","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..'"}}]' local results = '[{"type":"article","id":"9","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) utilities.answer_inline_query(inline_query, results, 1)
end end
function googl:send_googl_info (shorturl) function googl:send_googl_info (shorturl)
@ -49,8 +49,8 @@ end
function googl:action(msg, config, matches) function googl:action(msg, config, matches)
local shorturl = matches[1] local shorturl = matches[1]
local text = 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 if not text then utilities.send_reply(msg, config.errors.connection) return end
utilities.send_reply(self, msg, text) utilities.send_reply(msg, text)
end end
return googl return googl

View File

@ -27,11 +27,11 @@ function gps:inline_callback(inline_query, config, matches)
local results = '[{"type":"location","id":"8","latitude":'..lat..',"longitude":'..lon..',"title":"Standort"}]' local results = '[{"type":"location","id":"8","latitude":'..lat..',"longitude":'..lon..',"title":"Standort"}]'
utilities.answer_inline_query(self, inline_query, results, 10000) utilities.answer_inline_query(inline_query, results, 10000)
end end
function gps:action(msg, config, matches) function gps:action(msg, config, matches)
utilities.send_typing(self, msg.chat.id, 'upload_photo') utilities.send_typing(msg.chat.id, 'upload_photo')
local lat = matches[1] local lat = matches[1]
local lon = matches[2] local lon = matches[2]
@ -42,10 +42,10 @@ function gps:action(msg, config, matches)
local zoom = zooms[i] local zoom = zooms[i]
local url = "https://maps.googleapis.com/maps/api/staticmap?zoom=" .. zoom .. "&size=600x300&maptype=hybrid&center=" .. lat .. "," .. lon .. "&markers=color:red%7Clabel:•%7C" .. lat .. "," .. lon local url = "https://maps.googleapis.com/maps/api/staticmap?zoom=" .. zoom .. "&size=600x300&maptype=hybrid&center=" .. lat .. "," .. lon .. "&markers=color:red%7Clabel:•%7C" .. lat .. "," .. lon
local file = download_to_file(url, 'zoom_'..i..'.png') local file = download_to_file(url, 'zoom_'..i..'.png')
utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id) utilities.send_photo(msg.chat.id, file, nil, msg.message_id)
end end
utilities.send_location(self, msg.chat.id, lat, lon, msg.message_id) utilities.send_location(msg.chat.id, lat, lon, msg.message_id)
end end
return gps return gps

View File

@ -6,7 +6,7 @@ hallo.triggers = {
function hallo:action(msg, config) function hallo:action(msg, config)
local name = msg.from.first_name local name = msg.from.first_name
utilities.send_reply(self, msg, 'Hallo '..name..'!') utilities.send_reply(msg, 'Hallo '..name..'!')
end end
return hallo return hallo

View File

@ -17,9 +17,9 @@ function hdf:action(msg, config)
"/hdf5.jpg" "/hdf5.jpg"
} }
local random_pic = math.random(#hdf_pics) local random_pic = math.random(#hdf_pics)
utilities.send_typing(self, msg.chat.id, 'upload_photo') utilities.send_typing(msg.chat.id, 'upload_photo')
local file = download_to_file(HDF_URL..hdf_pics[random_pic]) local file = download_to_file(HDF_URL..hdf_pics[random_pic])
utilities.send_photo(self, msg.chat.id, file) utilities.send_photo(msg.chat.id, file)
end end
return hdf return hdf

View File

@ -28,10 +28,10 @@ function help:inline_callback(inline_query, config, matches)
local doc = doc:gsub('\\n', '\\\n') local doc = doc:gsub('\\n', '\\\n')
local chosen_plugin = utilities.get_word(plugin.command, 1) local chosen_plugin = utilities.get_word(plugin.command, 1)
local results = '[{"type":"article","id":"9","title":"Hilfe für '..chosen_plugin..'","description":"Hilfe für das Plugin \\"'..chosen_plugin..'\\" wird gepostet.","thumb_url":"https://anditest.perseus.uberspace.de/inlineQuerys/help/hilfe.jpg","input_message_content":{"message_text":"'..doc..'","parse_mode":"Markdown"}}]' local results = '[{"type":"article","id":"9","title":"Hilfe für '..chosen_plugin..'","description":"Hilfe für das Plugin \\"'..chosen_plugin..'\\" wird gepostet.","thumb_url":"https://anditest.perseus.uberspace.de/inlineQuerys/help/hilfe.jpg","input_message_content":{"message_text":"'..doc..'","parse_mode":"Markdown"}}]'
utilities.answer_inline_query(self, inline_query, results, 600, nil, nil, 'Hilfe anzeigen', 'hilfe_'..chosen_plugin) utilities.answer_inline_query(inline_query, results, 600, nil, nil, 'Hilfe anzeigen', 'hilfe_'..chosen_plugin)
end end
end end
utilities.answer_inline_query(self, inline_query) utilities.answer_inline_query(inline_query)
end end
function help:action(msg, config, matches) function help:action(msg, config, matches)
@ -61,11 +61,11 @@ function help:action(msg, config, matches)
local help_text = help_text .. table.concat(commandlist, '\n'..config.cmd_pat) .. '\nParameter: <benötigt> [optional]' local help_text = help_text .. table.concat(commandlist, '\n'..config.cmd_pat) .. '\nParameter: <benötigt> [optional]'
local help_text = help_text:gsub('%[', '\\[') local help_text = help_text:gsub('%[', '\\[')
local res = utilities.send_message(self, msg.from.id, help_text, true, nil, true) local res = utilities.send_message(msg.from.id, help_text, true, nil, true)
if not res then if not res then
utilities.send_reply(self, msg, 'Bitte schreibe mir zuerst [privat](http://telegram.me/' .. self.info.username .. '?start=help) für eine Hilfe.', true) utilities.send_reply(msg, 'Bitte schreibe mir zuerst [privat](http://telegram.me/' .. self.info.username .. '?start=help) für eine Hilfe.', true)
elseif msg.chat.type ~= 'private' then elseif msg.chat.type ~= 'private' then
utilities.send_reply(self, msg, 'Ich habe dir die Hilfe privat gesendet!.') utilities.send_reply(msg, 'Ich habe dir die Hilfe privat gesendet!.')
end end
return return
end end
@ -74,12 +74,12 @@ function help:action(msg, config, matches)
local plugin = self.plugins[n] local plugin = self.plugins[n]
if plugin.command and utilities.get_word(plugin.command, 1) == input and plugin.doc then if plugin.command and utilities.get_word(plugin.command, 1) == input and plugin.doc then
local output = '*Hilfe für* _' .. utilities.get_word(plugin.command, 1) .. '_ *:*' .. plugin.doc local output = '*Hilfe für* _' .. utilities.get_word(plugin.command, 1) .. '_ *:*' .. plugin.doc
utilities.send_message(self, msg.chat.id, output, true, nil, true) utilities.send_message(msg.chat.id, output, true, nil, true)
return return
end end
end end
utilities.send_reply(self, msg, 'Für diesen Befehl gibt es keine Hilfe.') utilities.send_reply(msg, 'Für diesen Befehl gibt es keine Hilfe.')
end end
return help return help

View File

@ -15,8 +15,8 @@ function id:init(config)
id.doc = [[```Zeige dir deine ID und die IDs aller Gruppenmitglieder an.``]] id.doc = [[```Zeige dir deine ID und die IDs aller Gruppenmitglieder an.``]]
end end
function id:get_member_count(self, msg, chat_id) function id:get_member_count(msg, chat_id)
return bindings.request(self, 'getChatMembersCount', { return bindings.request('getChatMembersCount', {
chat_id = chat_id chat_id = chat_id
} ) } )
end end
@ -51,7 +51,7 @@ function id:inline_callback(inline_query, config, matches)
local name = utilities.build_name(inline_query.from.first_name, inline_query.from.last_name) local name = utilities.build_name(inline_query.from.first_name, inline_query.from.last_name)
local results = '[{"type":"article","id":"30","title":"Deine Telegram-ID ist:","description":"'..id..'","input_message_content":{"message_text":"<b>'..name..'</b>: <code>'..id..'</code>","parse_mode":"HTML"}}]' local results = '[{"type":"article","id":"30","title":"Deine Telegram-ID ist:","description":"'..id..'","input_message_content":{"message_text":"<b>'..name..'</b>: <code>'..id..'</code>","parse_mode":"HTML"}}]'
utilities.answer_inline_query(self, inline_query, results, 10000, true) utilities.answer_inline_query(inline_query, results, 10000, true)
end end
function id:action(msg, config, matches) function id:action(msg, config, matches)
@ -83,10 +83,10 @@ function id:action(msg, config, matches)
local output = user .. ', und du bist in der Gruppe ' .. group local output = user .. ', und du bist in der Gruppe ' .. group
utilities.send_message(self, msg.chat.id, output, true, msg.message_id, true) utilities.send_message(msg.chat.id, output, true, msg.message_id, true)
elseif matches[1] == "chat" then elseif matches[1] == "chat" then
if msg.chat.type ~= 'group' and msg.chat.type ~= 'supergroup' then if msg.chat.type ~= 'group' and msg.chat.type ~= 'supergroup' then
utilities.send_reply(self, msg, 'Das hier ist keine Gruppe!') utilities.send_reply(msg, 'Das hier ist keine Gruppe!')
return return
end end
local chat_name = msg.chat.title local chat_name = msg.chat.title
@ -103,7 +103,7 @@ function id:action(msg, config, matches)
end end
-- get all administrators and the creator -- get all administrators and the creator
local administrators = utilities.get_chat_administrators(self, chat_id) local administrators = utilities.get_chat_administrators(chat_id)
local admins = {} local admins = {}
for num in pairs(administrators.result) do for num in pairs(administrators.result) do
if administrators.result[num].status ~= 'creator' then if administrators.result[num].status ~= 'creator' then
@ -112,7 +112,7 @@ function id:action(msg, config, matches)
creator_id = administrators.result[num].user.id creator_id = administrators.result[num].user.id
end end
end end
local result = id:get_member_count(self, msg, chat_id) local result = id:get_member_count(msg, chat_id)
local member_count = result.result 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'
@ -129,7 +129,7 @@ function id:action(msg, config, matches)
text = text..'*'..user.name..'* `['..user.id..']`\n' text = text..'*'..user.name..'* `['..user.id..']`\n'
end end
end end
utilities.send_reply(self, msg, text..'_(Bots sind nicht gelistet)_', true) utilities.send_reply(msg, text..'_(Bots sind nicht gelistet)_', true)
end end
end end

View File

@ -7,8 +7,8 @@ images.triggers = {
function images:action(msg, config, matches) function images:action(msg, config, matches)
local url = matches[1] local url = matches[1]
local file, last_modified, nocache = get_cached_file(url, nil, msg.chat.id, 'upload_photo', self) local file, last_modified, nocache = get_cached_file(url, nil, msg.chat.id, 'upload_photo')
local result = utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id) local result = utilities.send_photo(msg.chat.id, file, nil, msg.message_id)
if nocache then return end if nocache then return end
if not result then return end if not result then return end

View File

@ -26,9 +26,9 @@ function imdb:inline_callback(inline_query, config, matches)
local query = matches[1] local query = matches[1]
local url = BASE_URL..'/?s='..URL.escape(query) local url = BASE_URL..'/?s='..URL.escape(query)
local res, code = https.request(url) local res, code = https.request(url)
if code ~= 200 then utilities.answer_inline_query(self, inline_query) return end if code ~= 200 then abort_inline_query(inline_query) return end
local data = json.decode(res) local data = json.decode(res)
if data.Response ~= "True" then utilities.answer_inline_query(self, inline_query) return end if data.Response ~= "True" then abort_inline_query(inline_query) return end
local results = '[' local results = '['
local id = 500 local id = 500
@ -63,26 +63,26 @@ function imdb:inline_callback(inline_query, config, matches)
local results = results:sub(0, -2) local results = results:sub(0, -2)
local results = results..']' local results = results..']'
utilities.answer_inline_query(self, inline_query, results, 10000) utilities.answer_inline_query(inline_query, results, 10000)
end end
function imdb:action(msg, config) function imdb:action(msg, config)
local input = utilities.input_from_msg(msg) local input = utilities.input_from_msg(msg)
if not input then if not input then
utilities.send_reply(self, msg, imdb.doc, true) utilities.send_reply(msg, imdb.doc, true)
return return
end end
local url = BASE_URL..'/?t='..URL.escape(input) local url = BASE_URL..'/?t='..URL.escape(input)
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(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(msg, config.errors.results)
return return
end end
@ -90,11 +90,11 @@ function imdb:action(msg, config)
output = output..string.gsub(jdat.imdbRating, '%.', ',')..'/10 | '..jdat.Runtime..' | '.. jdat.Genre..'\n' output = output..string.gsub(jdat.imdbRating, '%.', ',')..'/10 | '..jdat.Runtime..' | '.. jdat.Genre..'\n'
output = output..'<i>' .. jdat.Plot .. '</i>' output = output..'<i>' .. jdat.Plot .. '</i>'
utilities.send_reply(self, msg, output, 'HTML', '{"inline_keyboard":[[{"text":"IMDb-Seite aufrufen","url":"http://imdb.com/title/'.. jdat.imdbID..'"}]]}') utilities.send_reply(msg, output, 'HTML', '{"inline_keyboard":[[{"text":"IMDb-Seite aufrufen","url":"http://imdb.com/title/'.. jdat.imdbID..'"}]]}')
if jdat.Poster ~= "N/A" then if jdat.Poster ~= "N/A" then
local file = download_to_file(jdat.Poster) local file = download_to_file(jdat.Poster)
utilities.send_photo(self, msg.chat.id, file) utilities.send_photo(msg.chat.id, file)
end end
end end

View File

@ -50,7 +50,7 @@ end
function imgblacklist:action(msg, config, matches) function imgblacklist:action(msg, config, matches)
if msg.from.id ~= config.admin then if msg.from.id ~= config.admin then
utilities.send_reply(self, msg, config.errors.sudo) utilities.send_reply(msg, config.errors.sudo)
return return
end end
@ -60,22 +60,22 @@ function imgblacklist:action(msg, config, matches)
_blacklist = redis:smembers("telegram:img_blacklist") _blacklist = redis:smembers("telegram:img_blacklist")
if action == 'add' and not word then if action == 'add' and not word then
utilities.send_reply(self, msg, imgblacklist.doc, true) utilities.send_reply(msg, imgblacklist.doc, true)
return return
elseif action == "add" and word then elseif action == "add" and word then
utilities.send_reply(self, msg, imgblacklist:add_blacklist(word), true) utilities.send_reply(msg, imgblacklist:add_blacklist(word), true)
return return
end end
if action == 'remove' and not word then if action == 'remove' and not word then
utilities.send_reply(self, msg, imgblacklist.doc, true) utilities.send_reply(msg, imgblacklist.doc, true)
return return
elseif action == "remove" and word then elseif action == "remove" and word then
utilities.send_reply(self, msg, imgblacklist:remove_blacklist(word), true) utilities.send_reply(msg, imgblacklist:remove_blacklist(word), true)
return return
end end
utilities.send_reply(self, msg, imgblacklist:show_blacklist()) utilities.send_reply(msg, imgblacklist:show_blacklist())
end end
return imgblacklist return imgblacklist

View File

@ -40,14 +40,14 @@ end
function imgur:action(msg) function imgur:action(msg)
local imgur_code = matches[1] local imgur_code = matches[1]
if imgur_code == "login" then return nil end if imgur_code == "login" then return nil end
utilities.send_typing(self, msg.chat.id, 'upload_photo') utilities.send_typing(msg.chat.id, 'upload_photo')
local link = imgur:get_imgur_data(imgur_code) local link = imgur:get_imgur_data(imgur_code)
if link then if link then
local file = download_to_file(link) local file = download_to_file(link)
if string.ends(link, ".gif") then if string.ends(link, ".gif") then
utilities.send_document(self, msg.chat.id, file, nil, msg.message_id) utilities.send_document(msg.chat.id, file, nil, msg.message_id)
else else
utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id) utilities.send_photo(msg.chat.id, file, nil, msg.message_id)
end end
end end
end end

View File

@ -39,7 +39,7 @@ function insider:action(msg, config)
'<b>Insider:</b> MeeeeeeeM\n<b>Erschaffen/hauptsächlich verwendet von:</b> Brawl, nino\n<b>Wo eingesetzt?:</b> FiiiiiiiiiiiiiiiiiF\n<b>Bemerkung:</b> SooooooooooooooooS', '<b>Insider:</b> MeeeeeeeM\n<b>Erschaffen/hauptsächlich verwendet von:</b> Brawl, nino\n<b>Wo eingesetzt?:</b> FiiiiiiiiiiiiiiiiiF\n<b>Bemerkung:</b> SooooooooooooooooS',
'<b>Insider:</b> DJ mP\n<b>Erschaffen/hauptsächlich verwendet von:</b> Brawl\n<b>Wo eingesetzt?:</b> Telegram\n<b>Bemerkung:</b> als Kurzname für masterP', '<b>Insider:</b> DJ mP\n<b>Erschaffen/hauptsächlich verwendet von:</b> Brawl\n<b>Wo eingesetzt?:</b> Telegram\n<b>Bemerkung:</b> als Kurzname für masterP',
'<b>Insider:</b> Satya Nutella\n<b>Erschaffen/hauptsächlich verwendet von:</b> Brawl\n<b>Wo eingesetzt?:</b> Telegram\n<b>Bemerkung:</b> Anstelle von "Satya Nadella"'} '<b>Insider:</b> Satya Nutella\n<b>Erschaffen/hauptsächlich verwendet von:</b> Brawl\n<b>Wo eingesetzt?:</b> Telegram\n<b>Bemerkung:</b> Anstelle von "Satya Nadella"'}
utilities.send_reply(self, msg, insiders[math.random(#insiders)], 'HTML') utilities.send_reply(msg, insiders[math.random(#insiders)], 'HTML')
end end
return insider return insider

View File

@ -73,14 +73,14 @@ end
function ip_info:action(msg, config, matches) function ip_info:action(msg, config, matches)
local host = matches[1] local host = matches[1]
local text, image_url = ip_info:get_host_data(host) local text, image_url = ip_info:get_host_data(host)
if not text then utilities.send_reply(self, msg, config.errors.connection) return end if not text then utilities.send_reply(msg, config.errors.connection) return end
if image_url then if image_url then
utilities.send_typing(self, msg.chat.id, 'upload_photo') utilities.send_typing(msg.chat.id, 'upload_photo')
local file = download_to_file(image_url, 'map.png') local file = download_to_file(image_url, 'map.png')
utilities.send_photo(self, msg.chat.id, file, text, msg.message_id) utilities.send_photo(msg.chat.id, file, text, msg.message_id)
else else
utilities.send_reply(self, msg, text) utilities.send_reply(msg, text)
end end
end end

View File

@ -68,10 +68,10 @@ end
function isup:action(msg, config) function isup:action(msg, config)
if isup:isup(matches[1]) then if isup:isup(matches[1]) then
utilities.send_reply(self, msg, matches[1]..' ist UP! ✅') utilities.send_reply(msg, matches[1]..' ist UP! ✅')
return return
else else
utilities.send_reply(self, msg, matches[1]..' ist DOWN! ❌') utilities.send_reply(msg, matches[1]..' ist DOWN! ❌')
return return
end end
end end

View File

@ -18,9 +18,9 @@ function jk:action(msg, config)
"/justkitten6.jpg" "/justkitten6.jpg"
} }
local random_pic = math.random(#jk_pics) local random_pic = math.random(#jk_pics)
utilities.send_typing(self, msg.chat.id, 'upload_photo') utilities.send_typing(msg.chat.id, 'upload_photo')
local file = download_to_file(JK_URL..jk_pics[random_pic]) local file = download_to_file(JK_URL..jk_pics[random_pic])
utilities.send_photo(self, msg.chat.id, file) utilities.send_photo(msg.chat.id, file)
end end
return jk return jk

View File

@ -38,19 +38,19 @@ function kickstarter_search:action(msg, config, matches)
local query = matches[1] local query = matches[1]
local text, image_url = kickstarter_search:search_it(query, slug) local text, image_url = kickstarter_search:search_it(query, slug)
if not text then if not text then
utilities.send_reply(self, msg, config.errors.connection) utilities.send_reply(msg, config.errors.connection)
return return
elseif text == 'NOTFOUND' then elseif text == 'NOTFOUND' then
utilities.send_reply(self, msg, config.errors.results) utilities.send_reply(msg, config.errors.results)
return return
end end
if image_url then if image_url then
utilities.send_typing(self, msg.chat.id, 'upload_photo') utilities.send_typing(msg.chat.id, 'upload_photo')
local file = download_to_file(image_url, query..'.png') local file = download_to_file(image_url, query..'.png')
utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id) utilities.send_photo(msg.chat.id, file, nil, msg.message_id)
end end
utilities.send_reply(self, msg, text, 'HTML') utilities.send_reply(msg, text, 'HTML')
end end
return kickstarter_search return kickstarter_search

View File

@ -23,19 +23,19 @@ end
function konachan:action(msg, config) function konachan:action(msg, config)
local input = utilities.input_from_msg(msg) local input = utilities.input_from_msg(msg)
if not input then if not input then
utilities.send_reply(self, msg, konachan.doc, true) utilities.send_reply(msg, konachan.doc, true)
return return
end end
local tag = string.gsub(input, " ", '+' ) local tag = string.gsub(input, " ", '+' )
local url = konachan:get_kc(tag) local url = konachan:get_kc(tag)
if not url then if not url then
utilities.send_reply(self, msg, config.errors.results) utilities.send_reply(msg, config.errors.results)
return return
end end
utilities.send_typing(self, msg.chat.id, 'upload_photo') utilities.send_typing(msg.chat.id, 'upload_photo')
local file = download_to_file(url) local file = download_to_file(url)
utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id) utilities.send_photo(msg.chat.id, file, nil, msg.message_id)
utilities.send_reply(self, msg, url) utilities.send_reply(msg, url)
end end
return konachan return konachan

View File

@ -23,19 +23,19 @@ end
function konachan_nsfw:action(msg, config) function konachan_nsfw:action(msg, config)
local input = utilities.input_from_msg(msg) local input = utilities.input_from_msg(msg)
if not input then if not input then
utilities.send_reply(self, msg, konachan_nsfw.doc, true) utilities.send_reply(msg, konachan_nsfw.doc, true)
return return
end end
local tag = string.gsub(input, " ", '+' ) local tag = string.gsub(input, " ", '+' )
local url = konachan_nsfw:get_kc(tag) local url = konachan_nsfw:get_kc(tag)
if not url then if not url then
utilities.send_reply(self, msg, config.errors.results) utilities.send_reply(msg, config.errors.results)
return return
end end
utilities.send_typing(self, msg.chat.id, 'upload_photo') utilities.send_typing(msg.chat.id, 'upload_photo')
local file = download_to_file(url) local file = download_to_file(url)
utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id) utilities.send_photo(msg.chat.id, file, nil, msg.message_id)
utilities.send_reply(self, msg, url) utilities.send_reply(msg, url)
end end
return konachan_nsfw return konachan_nsfw

View File

@ -44,20 +44,20 @@ function loc_manager:action(msg, config, matches)
local user_id = msg.from.id local user_id = msg.from.id
if matches[1] == 'set' then if matches[1] == 'set' then
utilities.send_reply(self, msg, loc_manager:set_location(user_id, matches[2]), true) utilities.send_reply(msg, loc_manager:set_location(user_id, matches[2]), true)
return return
elseif matches[1] == 'del' then elseif matches[1] == 'del' then
utilities.send_reply(self, msg, loc_manager:del_location(user_id), true) utilities.send_reply(msg, loc_manager:del_location(user_id), true)
return return
else else
local set_location = get_location(user_id) local set_location = get_location(user_id)
if not set_location then if not set_location then
utilities.send_reply(self, msg, '*Du hast keinen Ort gesetzt!*', true) utilities.send_reply(msg, '*Du hast keinen Ort gesetzt!*', true)
return return
else else
local coords = utilities.get_coords(set_location, config) local coords = utilities.get_coords(set_location, config)
utilities.send_location(self, msg.chat.id, coords.lat, coords.lon, msg.message_id) utilities.send_location(msg.chat.id, coords.lat, coords.lon, msg.message_id)
utilities.send_reply(self, msg, 'Gesetzter Wohnort: *'..set_location..'*', true) utilities.send_reply(msg, 'Gesetzter Wohnort: *'..set_location..'*', true)
return return
end end
end end

View File

@ -36,12 +36,12 @@ function lyrics:action(msg, config, matches)
if msg.reply_to_message and msg.reply_to_message.text then if msg.reply_to_message and msg.reply_to_message.text then
input = msg.reply_to_message.text input = msg.reply_to_message.text
else else
utilities.send_message(self, msg.chat.id, lyrics.doc, true, msg.message_id, true) utilities.send_message(msg.chat.id, lyrics.doc, true, msg.message_id, true)
return return
end end
end end
utilities.send_reply(self, msg, lyrics:getLyrics(input), true) utilities.send_reply(msg, lyrics:getLyrics(input), true)
end end
return lyrics return lyrics

View File

@ -15,7 +15,7 @@ function muschel:frag_die_muschel()
end end
function muschel:action(msg, config, matches) function muschel:action(msg, config, matches)
utilities.send_reply(self, msg, muschel:frag_die_muschel()) utilities.send_reply(msg, muschel:frag_die_muschel())
end end
return muschel return muschel

View File

@ -35,10 +35,10 @@ function mal_user:action(msg, config, matches)
local user = matches[1] local user = matches[1]
local text = mal_user:get_infos(user) local text = mal_user:get_infos(user)
if not text then if not text then
utilities.send_reply(self, msg, config.errors.results) utilities.send_reply(msg, config.errors.results)
return return
end end
utilities.send_reply(self, msg, text, 'HTML') utilities.send_reply(msg, text, 'HTML')
end end
return mal_user return mal_user

View File

@ -13,7 +13,7 @@ function me:action(msg, config)
return return
end end
utilities.send_message(self, msg.chat.id, msg.from.first_name..' '..input) utilities.send_message(msg.chat.id, msg.from.first_name..' '..input)
end end
return me return me

View File

@ -35,19 +35,19 @@ function media:action(msg, config, matches)
chat_action = 'upload_document' chat_action = 'upload_document'
end end
local file, last_modified, nocache = get_cached_file(url, nil, msg.chat.id, chat_action, self) local file, last_modified, nocache = get_cached_file(url, nil, msg.chat.id, chat_action)
if not file then return end if not file then return end
if ext == 'gif' then if ext == 'gif' then
result = utilities.send_document(self, receiver, file, nil, msg.message_id) result = utilities.send_document(receiver, file, nil, msg.message_id)
elseif ext == 'ogg' then elseif ext == 'ogg' then
result = utilities.send_voice(self, receiver, file, nil, msg.message_id) result = utilities.send_voice(receiver, file, nil, msg.message_id)
elseif mime_type == 'audio' then elseif mime_type == 'audio' then
result = utilities.send_audio(self, receiver, file, nil, msg.message_id) result = utilities.send_audio(receiver, file, nil, msg.message_id)
elseif mime_type == 'video' then elseif mime_type == 'video' then
result = utilities.send_video(self, receiver, file, nil, msg.message_id) result = utilities.send_video(receiver, file, nil, msg.message_id)
else else
result = utilities.send_document(self, receiver, file, nil, msg.message_id) result = utilities.send_document(receiver, file, nil, msg.message_id)
end end
if nocache then return end if nocache then return end

View File

@ -74,7 +74,7 @@ function mc_server:parseText(text, mc_server)
end end
function mc_server:action(msg, config, matches) function mc_server:action(msg, config, matches)
utilities.send_reply(self, msg, mc_server:parseText(msg.text, mc_server), true) utilities.send_reply(msg, mc_server:parseText(msg.text, mc_server), true)
end end
return mc_server return mc_server

View File

@ -16,14 +16,14 @@ function mc_skin:action(msg, config, matches)
if msg.reply_to_message and msg.reply_to_message.text then if msg.reply_to_message and msg.reply_to_message.text then
input = msg.reply_to_message.text input = msg.reply_to_message.text
else else
utilities.send_message(self, msg.chat.id, mc_skin.doc, true, msg.message_id, true) utilities.send_message(msg.chat.id, mc_skin.doc, true, msg.message_id, true)
return return
end end
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, input..'.png') local file = download_to_file(url, input..'.png')
utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id) utilities.send_photo(msg.chat.id, file, nil, msg.message_id)
end end
return mc_skin return mc_skin

View File

@ -28,14 +28,14 @@ function moe:action(msg, config, matches)
site_url = 'http://yagyuu.moe' site_url = 'http://yagyuu.moe'
end end
utilities.send_typing(self, msg.chat.id, 'upload_photo') utilities.send_typing(msg.chat.id, 'upload_photo')
local photo_url = moe:get_url(site_url) local photo_url = moe:get_url(site_url)
if not photo_url then if not photo_url then
utilities.send_reply(self, msg, config.errors.connection) utilities.send_reply(msg, config.errors.connection)
return return
end end
local file = download_to_file(photo_url) local file = download_to_file(photo_url)
utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id) utilities.send_photo(msg.chat.id, file, nil, msg.message_id)
end end
return moe return moe

View File

@ -205,31 +205,31 @@ function mal:action(msg, config, matches)
if matches[1] == 'anime' or matches[1] == 'mal' then if matches[1] == 'anime' or matches[1] == 'mal' then
local anime_info = mal:get_mal_info(query, 'anime') local anime_info = mal:get_mal_info(query, 'anime')
if anime_info == "HTTP-Fehler" then if anime_info == "HTTP-Fehler" then
utilities.send_reply(self, msg, 'Anime nicht gefunden!') utilities.send_reply(msg, 'Anime nicht gefunden!')
return return
else else
local text, image_url = mal:send_anime_data(anime_info) local text, image_url = mal:send_anime_data(anime_info)
if image_url then if image_url then
utilities.send_typing(self, msg.chat.id, 'upload_photo') utilities.send_typing(msg.chat.id, 'upload_photo')
local file = download_to_file(image_url) local file = download_to_file(image_url)
utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id) utilities.send_photo(msg.chat.id, file, nil, msg.message_id)
end end
utilities.send_reply(self, msg, text, true) utilities.send_reply(msg, text, true)
return return
end end
elseif matches[1] == 'manga' then elseif matches[1] == 'manga' then
local manga_info = mal:get_mal_info(query, 'manga') local manga_info = mal:get_mal_info(query, 'manga')
if manga_info == "HTTP-Fehler" then if manga_info == "HTTP-Fehler" then
utilities.send_reply(self, msg, 'Manga nicht gefunden!') utilities.send_reply(msg, 'Manga nicht gefunden!')
return return
else else
local text, image_url = mal:send_manga_data(manga_info) local text, image_url = mal:send_manga_data(manga_info)
if image_url then if image_url then
utilities.send_typing(self, msg.chat.id, 'upload_photo') utilities.send_typing(msg.chat.id, 'upload_photo')
local file = download_to_file(image_url) local file = download_to_file(image_url)
utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id) utilities.send_photo(msg.chat.id, file, nil, msg.message_id)
end end
utilities.send_reply(self, msg, text, true) utilities.send_reply(msg, text, true)
return return
end end
end end

View File

@ -48,10 +48,10 @@ function mfc:action(msg, config, matches)
local user = matches[1] local user = matches[1]
local text = mfc:get_infos(user) local text = mfc:get_infos(user)
if not text then if not text then
utilities.send_reply(self, msg, config.errors.results) utilities.send_reply(msg, config.errors.results)
return return
end end
utilities.send_reply(self, msg, text, 'HTML') utilities.send_reply(msg, text, 'HTML')
end end
return mfc return mfc

View File

@ -47,13 +47,13 @@ function nicovideo:action(msg, config, matches)
local id = matches[1] local id = matches[1]
local text, pic_url = nicovideo:get_video(id) local text, pic_url = nicovideo:get_video(id)
if not text then if not text then
utilities.send_reply(self, msg, config.errors.results) utilities.send_reply(msg, config.errors.results)
return return
end end
utilities.send_typing(self, msg.chat.id, 'upload_photo') utilities.send_typing(msg.chat.id, 'upload_photo')
local file = download_to_file(pic_url, 'nicovideo_thumb.png') local file = download_to_file(pic_url, 'nicovideo_thumb.png')
utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id) utilities.send_photo(msg.chat.id, file, nil, msg.message_id)
utilities.send_reply(self, msg, text, 'HTML') utilities.send_reply(msg, text, 'HTML')
end end
return nicovideo return nicovideo

View File

@ -23,7 +23,7 @@ function isWordFoundInString(word,input)
select(2,input:gsub('%W+' .. word .. '%W+','')) > 0 select(2,input:gsub('%W+' .. word .. '%W+','')) > 0
end end
function notify:pre_process(msg, self) function notify:pre_process(msg)
local notify_users = redis:smembers('notify:ls') local notify_users = redis:smembers('notify:ls')
-- I call this beautiful lady the "if soup" -- I call this beautiful lady the "if soup"
@ -44,7 +44,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, true) utilities.send_message(id, text, true)
end end
end end
end end
@ -57,7 +57,7 @@ end
function notify:action(msg, config, matches) function notify:action(msg, config, matches)
if not msg.from.username then if not msg.from.username then
utilities.send_reply(self, msg, 'Du hast keinen Usernamen und kannst daher dieses Feature nicht nutzen. Tut mir leid!' ) utilities.send_reply(msg, 'Du hast keinen Usernamen und kannst daher dieses Feature nicht nutzen. Tut mir leid!' )
return return
end end
@ -67,18 +67,18 @@ function notify:action(msg, config, matches)
if matches[1] == "del" then if matches[1] == "del" then
if not redis:sismember('notify:ls', username) then if not redis:sismember('notify:ls', username) then
utilities.send_reply(self, msg, 'Du wirst noch gar nicht benachrichtigt!') utilities.send_reply(msg, 'Du wirst noch gar nicht benachrichtigt!')
return return
end end
print('Setze notify redis hash '..hash..' auf false') print('Setze notify redis hash '..hash..' auf false')
redis:hset(hash, 'notify', false) redis:hset(hash, 'notify', false)
print('Lösche '..username..' von 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(msg, 'Du erhälst jetzt keine Benachrichtigungen mehr, wenn du angesprochen wirst.')
return return
else else
if redis:sismember('notify:ls', username) then if redis:sismember('notify:ls', username) then
utilities.send_reply(self, msg, 'Du wirst schon benachrichtigt!') utilities.send_reply(msg, 'Du wirst schon benachrichtigt!')
return return
end end
print('Setze notify in redis hash '..hash..' auf true') print('Setze notify in redis hash '..hash..' auf true')
@ -87,11 +87,11 @@ function notify:action(msg, config, matches)
redis:hset(hash, 'id', msg.from.id) redis:hset(hash, 'id', msg.from.id)
print('Adde '..username..' zu 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(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
utilities.send_reply(self, msg, 'Bitte schreibe mir [privat](http://telegram.me/' .. self.info.username .. '?start=notify), um den Vorgang abzuschließen.', true) utilities.send_reply(msg, 'Bitte schreibe mir [privat](http://telegram.me/' .. self.info.username .. '?start=notify), um den Vorgang abzuschließen.', true)
elseif msg.chat.type ~= 'private' then elseif msg.chat.type ~= 'private' then
utilities.send_reply(self, msg, 'Du erhälst jetzt Benachrichtigungen, wenn du angesprochen wirst, nutze `/notify del` zum Deaktivieren.', true) utilities.send_reply(msg, 'Du erhälst jetzt Benachrichtigungen, wenn du angesprochen wirst, nutze `/notify del` zum Deaktivieren.', true)
end end
end end
end end

View File

@ -26,10 +26,10 @@ function openingsmoe:action(msg, config, matches)
local opening = matches[1] local opening = matches[1]
local text = openingsmoe:get_opening(opening) local text = openingsmoe:get_opening(opening)
if not text then if not text then
utilities.send_reply(self, msg, config.errors.connection) utilities.send_reply(msg, config.errors.connection)
return return
end end
utilities.send_reply(self, msg, text, 'HTML') utilities.send_reply(msg, text, 'HTML')
end end
return openingsmoe return openingsmoe

View File

@ -26,10 +26,10 @@ function pagespeed_insights:get_pagespeed(test_url)
end end
function pagespeed_insights:action(msg, config, matches) function pagespeed_insights:action(msg, config, matches)
utilities.send_typing(self, msg.chat.id, 'typing') utilities.send_typing(msg.chat.id, 'typing')
local text = pagespeed_insights:get_pagespeed(matches[1]) local text = pagespeed_insights:get_pagespeed(matches[1])
if not text then utilities.send_reply(self, msg, config.errors.connection) return end if not text then utilities.send_reply(msg, config.errors.connection) return end
utilities.send_reply(self, msg, text, true) utilities.send_reply(msg, text, true)
end end
return pagespeed_insights return pagespeed_insights

View File

@ -33,10 +33,10 @@ function pasteee:action(msg, config, matches)
local text = matches[1] local text = matches[1]
local link, iserror = upload(text) local link, iserror = upload(text)
if iserror then if iserror then
utilities.send_reply(self, msg, link) utilities.send_reply(msg, link)
return return
end end
utilities.send_reply(self, msg, '[Text auf Paste.ee ansehen]('..link..')', true) utilities.send_reply(msg, '[Text auf Paste.ee ansehen]('..link..')', true)
end end
return pasteee return pasteee

View File

@ -23,11 +23,11 @@ function patterns:action(msg)
end end
) )
if res == false then if res == false then
utilities.send_reply(self, msg, 'Falsches Pattern!') utilities.send_reply(msg, 'Falsches Pattern!')
else else
output = output:sub(1, 4000) output = output:sub(1, 4000)
output = '*Du meintest wohl*:\n"'..utilities.md_escape(utilities.trim(output))..'"' output = '*Du meintest wohl*:\n"'..utilities.md_escape(utilities.trim(output))..'"'
utilities.send_reply(self, msg.reply_to_message, output, true) utilities.send_reply(msg.reply_to_message, output, true)
end end
end end

View File

@ -101,13 +101,13 @@ function pixabay:action(msg, config, matches)
end end
if url == 'NOPIX' then if url == 'NOPIX' then
utilities.send_reply(self, msg, config.errors.results) utilities.send_reply(msg, config.errors.results)
return return
else else
utilities.send_typing(self, msg.chat.id, 'upload_photo') utilities.send_typing(msg.chat.id, 'upload_photo')
local file = download_to_file(url) local file = download_to_file(url)
local text = '"'..tags..'" von '..user local text = '"'..tags..'" von '..user
utilities.send_photo(self, msg.chat.id, file, text, msg.message_id, '{"inline_keyboard":[[{"text":"Seite aufrufen","url":"'..page_url..'"},{"text":"Volles Bild (Login notwendig)","url":"'..full_url..'"}]]}') utilities.send_photo(msg.chat.id, file, text, msg.message_id, '{"inline_keyboard":[[{"text":"Seite aufrufen","url":"'..page_url..'"},{"text":"Volles Bild (Login notwendig)","url":"'..full_url..'"}]]}')
return return
end end
end end

View File

@ -50,7 +50,7 @@ function play_store:action(msg, config, matches)
if data == nil then if data == nil then
return return
else else
utilities.send_reply(self, msg, play_store:send_playstore_data(data), true) utilities.send_reply(msg, play_store:send_playstore_data(data), true)
return return
end end
end end

View File

@ -157,26 +157,26 @@ end
function plex:action(msg, config) function plex:action(msg, config)
local input = utilities.input_from_msg(msg) local input = utilities.input_from_msg(msg)
if not input then if not input then
utilities.send_reply(self, msg. plex.doc, true) utilities.send_reply(msg. plex.doc, true)
return return
end end
local query = string.gsub(URL.escape(input), '&', '+') local query = string.gsub(URL.escape(input), '&', '+')
local text, pic = plex:get_plex(query) local text, pic = plex:get_plex(query)
if not text then if not text then
utilities.send_reply(self, msg, config.errors.results) utilities.send_reply(msg, config.errors.results)
return return
elseif text == 'NOTOK' then elseif text == 'NOTOK' then
utilities.send_reply(self, msg, config.errors.connection) utilities.send_reply(msg, config.errors.connection)
return return
end end
if pic then if pic then
utilities.send_typing(self, receiver, 'upload_photo') utilities.send_typing(receiver, 'upload_photo')
local file = download_to_file(pic, 'plex.png') local file = download_to_file(pic, 'plex.png')
utilities.send_photo(self, msg.chat.id, file) utilities.send_photo(msg.chat.id, file)
end end
utilities.send_reply(self, msg, text, 'HTML') utilities.send_reply(msg, text, 'HTML')
end end
return plex return plex

View File

@ -162,13 +162,13 @@ end
function plugin_manager:action(msg, config, matches) function plugin_manager:action(msg, config, matches)
if msg.from.id ~= config.admin then if msg.from.id ~= config.admin then
utilities.send_reply(self, msg, config.errors.sudo) utilities.send_reply(msg, config.errors.sudo)
return return
end end
-- Show the available plugins -- Show the available plugins
if matches[1] == '/plugins' then if matches[1] == '/plugins' then
utilities.send_reply(self, msg, plugin_manager:list_plugins()) utilities.send_reply(msg, plugin_manager:list_plugins())
return return
end end
@ -178,11 +178,11 @@ function plugin_manager:action(msg, config, matches)
if matches[4] then if matches[4] then
local id = matches[4] local id = matches[4]
print("enable "..plugin..' on chat#id'..id) print("enable "..plugin..' on chat#id'..id)
utilities.send_reply(self, msg, plugin_manager:reenable_plugin_on_chat(id, plugin)) utilities.send_reply(msg, plugin_manager:reenable_plugin_on_chat(id, plugin))
return return
else else
print("enable "..plugin..' on this chat') print("enable "..plugin..' on this chat')
utilities.send_reply(self, msg, plugin_manager:reenable_plugin_on_chat(msg, plugin)) utilities.send_reply(msg, plugin_manager:reenable_plugin_on_chat(msg, plugin))
return return
end end
end end
@ -191,7 +191,7 @@ function plugin_manager:action(msg, config, matches)
if matches[1] == 'enable' then if matches[1] == 'enable' then
local plugin_name = matches[2] local plugin_name = matches[2]
print("enable: "..matches[2]) print("enable: "..matches[2])
utilities.send_reply(self, msg, plugin_manager:enable_plugin(self, config, plugin_name)) utilities.send_reply(msg, plugin_manager:enable_plugin(self, config, plugin_name))
return return
end end
@ -201,11 +201,11 @@ function plugin_manager:action(msg, config, matches)
if matches[4] then if matches[4] then
local id = matches[4] local id = matches[4]
print("disable "..plugin..' on chat#id'..id) print("disable "..plugin..' on chat#id'..id)
utilities.send_reply(self, msg, plugin_manager:disable_plugin_on_chat(id, plugin)) utilities.send_reply(msg, plugin_manager:disable_plugin_on_chat(id, plugin))
return return
else else
print("disable "..plugin..' on this chat') print("disable "..plugin..' on this chat')
utilities.send_reply(self, msg, plugin_manager:disable_plugin_on_chat(msg, plugin)) utilities.send_reply(msg, plugin_manager:disable_plugin_on_chat(msg, plugin))
return return
end end
end end
@ -213,13 +213,13 @@ function plugin_manager:action(msg, config, matches)
-- Disable a plugin -- Disable a plugin
if matches[1] == 'disable' then if matches[1] == 'disable' then
print("disable: "..matches[2]) print("disable: "..matches[2])
utilities.send_reply(self, msg, plugin_manager:disable_plugin(self, config, matches[2])) utilities.send_reply(msg, plugin_manager:disable_plugin(self, config, matches[2]))
return return
end end
-- Reload all the plugins! -- Reload all the plugins!
if matches[1] == 'reload' then if matches[1] == 'reload' then
utilities.send_reply(self, msg, plugin_manager:reload_plugins(self, config)) utilities.send_reply(msg, plugin_manager:reload_plugins(self, config))
return return
end end
end end

View File

@ -102,40 +102,40 @@ function pocket:action(msg, config, matches)
if matches[1] == 'set' then if matches[1] == 'set' then
local access_token = matches[2] local access_token = matches[2]
utilities.send_reply(self, msg, pocket:set_pocket_access_token(hash, access_token), true) utilities.send_reply(msg, pocket:set_pocket_access_token(hash, access_token), true)
local message_id = redis:hget(hash, 'pocket_login_msg') local message_id = redis:hget(hash, 'pocket_login_msg')
utilities.edit_message(self, msg.chat.id, message_id, '*Anmeldung abgeschlossen!*', true, true) utilities.edit_message(msg.chat.id, message_id, '*Anmeldung abgeschlossen!*', true, true)
redis:hdel(hash, 'pocket_login_msg') redis:hdel(hash, 'pocket_login_msg')
return return
end end
if not access_token then if not access_token then
local result = utilities.send_reply(self, msg, '*Bitte authentifiziere dich zuerst, indem du dich anmeldest.*', true, '{"inline_keyboard":[[{"text":"Bei Pocket anmelden","url":"https://brawlbot.tk/apis/callback/pocket/connect.php"}]]}') local result = utilities.send_reply(msg, '*Bitte authentifiziere dich zuerst, indem du dich anmeldest.*', true, '{"inline_keyboard":[[{"text":"Bei Pocket anmelden","url":"https://brawlbot.tk/apis/callback/pocket/connect.php"}]]}')
redis:hset(hash, 'pocket_login_msg', result.result.message_id) redis:hset(hash, 'pocket_login_msg', result.result.message_id)
return return
end end
if matches[1] == 'unauth' then if matches[1] == 'unauth' then
redis:hdel(hash, 'pocket') redis:hdel(hash, 'pocket')
utilities.send_reply(self, msg, 'Erfolgreich ausgeloggt! Du kannst den Zugriff [in deinen Einstellungen](https://getpocket.com/connected_applications) endgültig entziehen.', true) utilities.send_reply(msg, 'Erfolgreich ausgeloggt! Du kannst den Zugriff [in deinen Einstellungen](https://getpocket.com/connected_applications) endgültig entziehen.', true)
return return
end end
if matches[1] == 'add' then if matches[1] == 'add' then
utilities.send_reply(self, msg, pocket:add_pocket_item(access_token, matches[2])) utilities.send_reply(msg, pocket:add_pocket_item(access_token, matches[2]))
return return
end end
if matches[1] == 'archive' or matches[1] == 'delete' or matches[1] == 'readd' or matches[1] == 'favorite' or matches[1] == 'unfavorite' then if matches[1] == 'archive' or matches[1] == 'delete' or matches[1] == 'readd' or matches[1] == 'favorite' or matches[1] == 'unfavorite' then
utilities.send_reply(self, msg, pocket:modify_pocket_item(access_token, matches[1], matches[2])) utilities.send_reply(msg, pocket:modify_pocket_item(access_token, matches[1], matches[2]))
return return
end end
if msg.chat.type == 'chat' or msg.chat.type == 'supergroup' then if msg.chat.type == 'chat' or msg.chat.type == 'supergroup' then
utilities.send_reply(self, msg, 'Ausgeben deiner privaten Pocket-Liste in einem öffentlichen Chat wird feige verweigert. Bitte schreibe mich privat an!', true) utilities.send_reply(msg, 'Ausgeben deiner privaten Pocket-Liste in einem öffentlichen Chat wird feige verweigert. Bitte schreibe mich privat an!', true)
return return
else else
utilities.send_reply(self, msg, pocket:list_pocket_items(access_token)) utilities.send_reply(msg, pocket:list_pocket_items(access_token))
return return
end end
end end

View File

@ -13,14 +13,14 @@ end
function pokedex:action(msg, config) function pokedex:action(msg, config)
bindings.sendChatAction(self, { chat_id = msg.chat.id, action = 'typing' } ) bindings.sendChatAction({ chat_id = msg.chat.id, action = 'typing' } )
local input = utilities.input(msg.text_lower) local input = utilities.input(msg.text_lower)
if not input then if not input then
if msg.reply_to_message and msg.reply_to_message.text then if msg.reply_to_message and msg.reply_to_message.text then
input = msg.reply_to_message.text input = msg.reply_to_message.text
else else
utilities.send_message(self, msg.chat.id, pokedex.doc, true, msg.message_id, true) utilities.send_message(msg.chat.id, pokedex.doc, true, msg.message_id, true)
return return
end end
end end
@ -30,7 +30,7 @@ function pokedex:action(msg, config)
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(msg, config.errors.connection)
return return
end end
@ -39,7 +39,7 @@ function pokedex:action(msg, config)
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(msg, config.errors.connection)
return return
end end
@ -59,7 +59,7 @@ function pokedex:action(msg, config)
local output = '*' .. dex_jdat.name .. '*\n#' .. dex_jdat.national_id .. ' | ' .. poke_type .. '\n_' .. desc_jdat.description:gsub('POKMON', 'Pokémon'):gsub('Pokmon', 'Pokémon') .. '_' local output = '*' .. dex_jdat.name .. '*\n#' .. dex_jdat.national_id .. ' | ' .. poke_type .. '\n_' .. desc_jdat.description:gsub('POKMON', 'Pokémon'):gsub('Pokmon', 'Pokémon') .. '_'
utilities.send_message(self, msg.chat.id, output, true, nil, true) utilities.send_message(msg.chat.id, output, true, nil, true)
end end

View File

@ -9,14 +9,14 @@ end
porndoge.command = 'pdoge' porndoge.command = 'pdoge'
function porndoge:action(msg, config) function porndoge:action(msg, config)
utilities.send_typing(self, msg.chat.id, 'upload_photo') utilities.send_typing(msg.chat.id, 'upload_photo')
local url = 'https://porndoge.herokuapp.com/' local url = 'https://porndoge.herokuapp.com/'
local file = download_to_file(url, 'porndoge.png') local file = download_to_file(url, 'porndoge.png')
if not file then if not file then
utilities.send_reply(self, msg, config.errors.connection) utilities.send_reply(msg, config.errors.connection)
return return
end end
utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id) utilities.send_photo(msg.chat.id, file, nil, msg.message_id)
end end
return porndoge return porndoge

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