Übernehme fehlende Änderungen

This commit is contained in:
Andreas Bielawski 2016-08-15 23:26:16 +02:00
parent dbf323a02a
commit b8ce686e11
2 changed files with 27 additions and 19 deletions

View File

@ -14,7 +14,7 @@ return {
cli_port = 4567,
-- The block of text returned by /start.
about_text = [[
Dies ist die BETA-Version von Mikubot v2.
Dies ist die BETA-Version von Brawlbot v2.
Sende /hilfe, um zu starten
]],
@ -24,6 +24,16 @@ Sende /hilfe, um zu starten
-- false = only whitelisted users can use inline querys
-- NOTE that it doesn't matter, if the chat is whitelisted! The USER must be whitelisted!
enable_inline_for_everyone = true,
-- Redis settings. Only edit if you know what you're doing.
redis = {
host = '127.0.0.1',
port = 6379,
use_socket = false, -- Set to true, if you need to connect over a socket
socket_path = 'unix:///home/path/to/your/redis/sock',
password = nil, -- Set, if you need a password to connect to redis
database = nil -- Set, if you want to select another database. Default is 0 (use no ""!)
},
errors = { -- Generic error messages used in various plugins.
generic = 'An unexpected error occurred.',
@ -51,4 +61,4 @@ Sende /hilfe, um zu starten
response = 'I don\'t know what to say to that.'
}
}
}

View File

@ -1,13 +1,6 @@
local Redis = require 'redis'
local FakeRedis = require 'fakeredis'
local params = {
host = os.getenv('REDIS_HOST') or '127.0.0.1',
port = tonumber(os.getenv('REDIS_PORT') or 6379)
}
local database = os.getenv('REDIS_DB')
local password = os.getenv('REDIS_PASSWORD')
local config = require('config')
-- Overwrite HGETALL
Redis.commands.hgetall = Redis.command('hgetall', {
@ -22,7 +15,15 @@ local redis = nil
-- Won't launch an error if fails
local ok = pcall(function()
redis = Redis.connect(params)
if config.redis.use_socket and config.redis.socket_path then
redis = Redis.connect(config.redis.socket_path)
else
local params = {
host = config.redis.host,
port = config.redis.port
}
redis = Redis.connect(params)
end
end)
if not ok then
@ -33,9 +34,6 @@ if not ok then
fake_func()
fake = FakeRedis.new()
print('\27[31mRedis addr: '..params.host..'\27[39m')
print('\27[31mRedis port: '..params.port..'\27[39m')
redis = setmetatable({fakeredis=true}, {
__index = function(a, b)
if b ~= 'data' and fake[b] then
@ -45,13 +43,13 @@ if not ok then
end })
else
if password then
redis:auth(password)
if config.redis.password then
redis:auth(config.redis.password)
end
if database then
redis:select(database)
if config.redis.database then
redis:select(config.redis.database)
end
end
return redis
return redis