blacklist now in json file
various bugfixes
This commit is contained in:
41
plugins/blacklist.lua
Normal file
41
plugins/blacklist.lua
Normal file
@ -0,0 +1,41 @@
|
||||
-- Admins can blacklist a user from utilizing this bot. Use via reply or with an ID as an argument. Un-blacklist a user with the same command.
|
||||
|
||||
local triggers = {
|
||||
'^/blacklist'
|
||||
}
|
||||
|
||||
local action = function(msg)
|
||||
|
||||
if not config.admins[msg.from.id] then
|
||||
return send_msg(msg, 'Permission denied.')
|
||||
end
|
||||
|
||||
local input = get_input(msg.text)
|
||||
if not input then
|
||||
if msg.reply_to_message then
|
||||
input = msg.reply_to_message.from.id
|
||||
else
|
||||
return send_msg(msg, 'Must be used via reply or by specifying a user\'s ID.')
|
||||
end
|
||||
end
|
||||
|
||||
local id = tostring(input)
|
||||
|
||||
if config.blacklist[id] then
|
||||
config.blacklist[id] = nil
|
||||
send_msg(msg, 'User has been removed from the blacklist.')
|
||||
else
|
||||
config.blacklist[id] = true
|
||||
send_msg(msg, 'User has been blacklisted.')
|
||||
end
|
||||
|
||||
save_data('blacklist.json', config.blacklist)
|
||||
|
||||
end
|
||||
|
||||
return {
|
||||
doc = doc,
|
||||
triggers = triggers,
|
||||
action = action,
|
||||
no_typing = true
|
||||
}
|
@ -20,7 +20,7 @@ function PLUGIN.action(msg)
|
||||
local message, res = HTTP.request(url)
|
||||
|
||||
if res ~= 200 then
|
||||
return send_msg(msg, config.locale.errors.connection)
|
||||
return send_msg(msg, config.locale.errors.syntax)
|
||||
end
|
||||
|
||||
send_msg(msg, message)
|
||||
|
@ -21,7 +21,7 @@ function PLUGIN.action(msg)
|
||||
|
||||
local jdat = JSON.decode(jstr)
|
||||
|
||||
if string.match(jdat.res, '^I HAVE NO RESPONSE.') then
|
||||
if string.match(jdat.res, '^I HAVE NO RESPONSE.') or not jdat then
|
||||
jdat.res = "I don't know what to say to that."
|
||||
end
|
||||
|
||||
|
@ -36,10 +36,9 @@ local action = function(msg)
|
||||
return send_msg(msg, config.locale.errors.connection)
|
||||
end
|
||||
|
||||
local str = str:match('<span class=bld>.*</span>')
|
||||
local str = str:match('<span class=bld>(.*) %u+</span>')
|
||||
if not str then return send_msg(msg, config.locale.errors.results) end
|
||||
local str = str:sub(str:find('>')+1)
|
||||
result = str:sub(1, str:find(' ')-1)
|
||||
result = string.format('%.2f', str)
|
||||
|
||||
end
|
||||
|
||||
|
@ -198,18 +198,23 @@ demote.action = function(msg)
|
||||
return send_message(msg.chat.id, 'Group is not added.')
|
||||
end
|
||||
|
||||
if not msg.reply_to_message then
|
||||
return send_message(msg.chat.id, 'Demotions must be done via reply.')
|
||||
local input = get_input(msg.text)
|
||||
if not input then
|
||||
if msg.reply_to_message then
|
||||
input = msg.reply_to_message.from.id
|
||||
else
|
||||
return send_msg('Demotions must be done by reply or by specifying a moderator\'s ID.')
|
||||
end
|
||||
end
|
||||
|
||||
if not data[tostring(msg.chat.id)][tostring(msg.reply_to_message.from.id)] then
|
||||
return send_message(msg.chat.id, msg.reply_to_message.from.first_name..' is not a moderator.')
|
||||
if not data[tostring(msg.chat.id)][tostring(input)] then
|
||||
return send_message(msg.chat.id, input..' is not a moderator.')
|
||||
end
|
||||
|
||||
data[tostring(msg.chat.id)][tostring(msg.reply_to_message.from.id)] = nil
|
||||
data[tostring(msg.chat.id)][tostring(input)] = nil
|
||||
save_data(config.moderation.data, data)
|
||||
|
||||
send_message(msg.chat.id, msg.reply_to_message.from.first_name..' has been demoted.')
|
||||
send_message(msg.chat.id, input..' has been demoted.')
|
||||
|
||||
end
|
||||
|
||||
|
@ -25,6 +25,9 @@ function PLUGIN.action(msg)
|
||||
return send_msg(msg, config.locale.errors.connection)
|
||||
end
|
||||
local jdat = JSON.decode(jstr)
|
||||
if not jdat.query.results then
|
||||
return send_msg(msg, config.locale.errors.results)
|
||||
end
|
||||
local data = jdat.query.results.channel.item.condition
|
||||
|
||||
local fahrenheit = data.temp
|
||||
|
Reference in New Issue
Block a user