added cats!
minor fixes to a bunch of stuff
This commit is contained in:
parent
2e31f2f604
commit
2e01ceec71
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,3 +3,4 @@ loc/weeb.lua
|
|||||||
console.lua
|
console.lua
|
||||||
*.json
|
*.json
|
||||||
plugins/owm.lua
|
plugins/owm.lua
|
||||||
|
plugins/liberblock.lua
|
||||||
|
@ -2,6 +2,7 @@ return {
|
|||||||
bot_api_key = '',
|
bot_api_key = '',
|
||||||
lastfm_api_key = '',
|
lastfm_api_key = '',
|
||||||
biblia_api_key = '',
|
biblia_api_key = '',
|
||||||
|
thecatapi_key = '',
|
||||||
giphy_api_key = 'dc6zaTOxFJmzC',
|
giphy_api_key = 'dc6zaTOxFJmzC',
|
||||||
time_offset = 0,
|
time_offset = 0,
|
||||||
locale = dofile('loc/en.lua'),
|
locale = dofile('loc/en.lua'),
|
||||||
@ -23,6 +24,7 @@ return {
|
|||||||
'imdb.lua',
|
'imdb.lua',
|
||||||
'urbandictionary.lua',
|
'urbandictionary.lua',
|
||||||
'hackernews.lua',
|
'hackernews.lua',
|
||||||
|
'cats.lua',
|
||||||
'time.lua',
|
'time.lua',
|
||||||
'weather.lua',
|
'weather.lua',
|
||||||
'calc.lua',
|
'calc.lua',
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
-- 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.
|
-- 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 = {
|
local triggers = {
|
||||||
'^/blacklist'
|
'^/blacklist',
|
||||||
|
'^/listofcolor'
|
||||||
}
|
}
|
||||||
|
|
||||||
local action = function(msg)
|
local action = function(msg)
|
||||||
@ -23,10 +24,10 @@ local action = function(msg)
|
|||||||
|
|
||||||
if config.blacklist[id] then
|
if config.blacklist[id] then
|
||||||
config.blacklist[id] = nil
|
config.blacklist[id] = nil
|
||||||
send_msg(msg, 'User has been removed from the blacklist.')
|
send_message(msg.chat.id, 'User has been removed from the blacklist.')
|
||||||
else
|
else
|
||||||
config.blacklist[id] = true
|
config.blacklist[id] = true
|
||||||
send_msg(msg, 'User has been blacklisted.')
|
send_message(msg.chat.id, 'User has been blacklisted.')
|
||||||
end
|
end
|
||||||
|
|
||||||
save_data('blacklist.json', config.blacklist)
|
save_data('blacklist.json', config.blacklist)
|
||||||
|
@ -41,11 +41,15 @@ function PLUGIN.action(msg)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if url then
|
if url then
|
||||||
jstr, b = HTTPS.request(url)
|
jstr, res = HTTPS.request(url)
|
||||||
else
|
else
|
||||||
return send_msg(msg, config.locale.errors.results)
|
return send_msg(msg, config.locale.errors.results)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if res ~= 200 then
|
||||||
|
return send_msg(msg, config.locale.errors.connection)
|
||||||
|
end
|
||||||
|
|
||||||
jdat = JSON.decode(jstr)
|
jdat = JSON.decode(jstr)
|
||||||
local m = arg2 .. ' BTC = ' .. jdat['24h_avg']*arg2 ..' '.. arg1 .. '\n'
|
local m = arg2 .. ' BTC = ' .. jdat['24h_avg']*arg2 ..' '.. arg1 .. '\n'
|
||||||
m = m .. arg2 ..' '.. arg1 .. ' = ' .. string.format("%.8f", arg2/jdat['24h_avg']) .. ' BTC'
|
m = m .. arg2 ..' '.. arg1 .. ' = ' .. string.format("%.8f", arg2/jdat['24h_avg']) .. ' BTC'
|
||||||
|
33
plugins/cats.lua
Normal file
33
plugins/cats.lua
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
local doc = [[
|
||||||
|
/cat
|
||||||
|
Get a cat pic!
|
||||||
|
]]
|
||||||
|
|
||||||
|
local triggers = {
|
||||||
|
'^/cats?'
|
||||||
|
}
|
||||||
|
|
||||||
|
local action = function(msg)
|
||||||
|
|
||||||
|
local url = 'http://thecatapi.com/api/images/get?format=html&type=jpg'
|
||||||
|
if config.thecatapi_key then
|
||||||
|
url = url .. '&api_key=' .. config.thecatapi_key
|
||||||
|
end
|
||||||
|
|
||||||
|
local jstr, res = HTTP.request(url)
|
||||||
|
if res ~= 200 then
|
||||||
|
return send_msg(msg, config.locale.errors.connection)
|
||||||
|
end
|
||||||
|
|
||||||
|
jstr = jstr:match('<img src="(.*)">')
|
||||||
|
|
||||||
|
send_message(msg.chat.id, jstr, false, msg.message_id)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
doc = doc,
|
||||||
|
triggers = triggers,
|
||||||
|
action = action,
|
||||||
|
typing = true
|
||||||
|
}
|
@ -31,9 +31,10 @@ function PLUGIN.action(msg)
|
|||||||
|
|
||||||
-- Let's clean up the response a little. Capitalization & punctuation.
|
-- Let's clean up the response a little. Capitalization & punctuation.
|
||||||
filter = {
|
filter = {
|
||||||
['%aim%aimi'] = bot.first_name,
|
['%aimi?%aimi?'] = bot.first_name,
|
||||||
['^%s*(.-)%s*$'] = '%1',
|
['^%s*(.-)%s*$'] = '%1',
|
||||||
['^%l'] = string.upper
|
['^%l'] = string.upper,
|
||||||
|
['USER'] = msg.from.first_name
|
||||||
}
|
}
|
||||||
|
|
||||||
for k,v in pairs(filter) do
|
for k,v in pairs(filter) do
|
||||||
|
@ -1,8 +1,3 @@
|
|||||||
-- config.people is a table of IDs/nicknames the bot can address more familiarly
|
|
||||||
-- like so:
|
|
||||||
-- 13227902: "Drew"
|
|
||||||
|
|
||||||
|
|
||||||
local PLUGIN = {}
|
local PLUGIN = {}
|
||||||
|
|
||||||
PLUGIN.triggers = {
|
PLUGIN.triggers = {
|
||||||
@ -31,7 +26,7 @@ function PLUGIN.action(msg)
|
|||||||
for k,v in pairs(config.locale.interactions) do
|
for k,v in pairs(config.locale.interactions) do
|
||||||
for key,val in pairs(v) do
|
for key,val in pairs(v) do
|
||||||
if input:match(val..',? '..bot.first_name) then
|
if input:match(val..',? '..bot.first_name) then
|
||||||
return send_message(msg.chat.id, k:gsub('#NAME', nick))
|
return send_message(msg.chat.id, latcyr(k:gsub('#NAME', nick)))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -67,9 +67,16 @@ function PLUGIN.action(msg)
|
|||||||
|
|
||||||
local jdat = jdat.recenttracks.track[1] or jdat.recenttracks.track
|
local jdat = jdat.recenttracks.track[1] or jdat.recenttracks.track
|
||||||
|
|
||||||
local message = '🎵 ' .. input .. ' last listened to:\n'
|
local message = '🎵 ' .. msg.from.first_name .. ' last listened to:\n'
|
||||||
if jdat['@attr'] and jdat['@attr'].nowplaying then
|
if jdat['@attr'] and jdat['@attr'].nowplaying then
|
||||||
message = '🎵 ' .. input .. ' is listening to:\n'
|
message = '🎵 ' .. msg.from.first_name .. ' is listening to:\n'
|
||||||
|
end
|
||||||
|
|
||||||
|
local artist
|
||||||
|
if jdat.artist then
|
||||||
|
artist = jdat.artist['#text']
|
||||||
|
else
|
||||||
|
artist = 'Unknown'
|
||||||
end
|
end
|
||||||
|
|
||||||
local message = message .. jdat.name .. ' - ' .. jdat.artist['#text']
|
local message = message .. jdat.name .. ' - ' .. jdat.artist['#text']
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
-- So this plugin is an attempt to port @CIS_Bot's Liberbot moderation capabilities to the otouto base. By the time this code is public, @CIS_Bot will be running on pure otouto code. ¡Viva la Confederación!
|
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
|
|
||||||
This works using the settings in the "moderation" section of config.lua.
|
This works using the settings in the "moderation" section of config.lua.
|
||||||
@ -7,6 +5,8 @@ This works using the settings in the "moderation" section of config.lua.
|
|||||||
"data" will be the file name of where the moderation 'database' will be stored. The file will be created if it does not exist.
|
"data" will be the file name of where the moderation 'database' will be stored. The file will be created if it does not exist.
|
||||||
"admins" is a table of administrators for the Liberbot admin group. They will have the power to add groups and moderators to the database. The value can be a nickname for the admin, but it only needs to be true for it to work.
|
"admins" is a table of administrators for the Liberbot admin group. They will have the power to add groups and moderators to the database. The value can be a nickname for the admin, but it only needs to be true for it to work.
|
||||||
|
|
||||||
|
Your bot should have privacy mode disabled.
|
||||||
|
|
||||||
]]--
|
]]--
|
||||||
|
|
||||||
local help = {}
|
local help = {}
|
||||||
|
@ -100,23 +100,34 @@ function PLUGIN.action(msg)
|
|||||||
|
|
||||||
math.randomseed(os.time())
|
math.randomseed(os.time())
|
||||||
|
|
||||||
local slapper
|
local slapper, victim, sid, vid
|
||||||
local victim = get_input(msg.text)
|
|
||||||
|
victim = get_input(msg.text)
|
||||||
if victim then
|
if victim then
|
||||||
slapper = msg.from.first_name
|
slapper = msg.from.first_name
|
||||||
else
|
else
|
||||||
victim = msg.from.first_name
|
victim = msg.from.first_name
|
||||||
|
vid = msg.from.id
|
||||||
slapper = bot.first_name
|
slapper = bot.first_name
|
||||||
end
|
end
|
||||||
|
|
||||||
if msg.reply_to_message then
|
if msg.reply_to_message then
|
||||||
victim = msg.reply_to_message.from.first_name
|
victim = msg.reply_to_message.from.first_name
|
||||||
|
vid = msg.reply_to_message.from.id
|
||||||
slapper = msg.from.first_name
|
slapper = msg.from.first_name
|
||||||
|
sid = msg.from.id
|
||||||
if slapper == victim then
|
if slapper == victim then
|
||||||
slapper = bot.first_name
|
slapper = bot.first_name
|
||||||
|
sid = bot.id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
nicks = load_data('nicknames.json') -- Try to replace slapper/victim names with nicknames.
|
||||||
|
sid = tostring(sid)
|
||||||
|
vid = tostring(vid)
|
||||||
|
if nicks[sid] then slapper = nicks[sid] end
|
||||||
|
if nicks[vid] then victim = nicks[vid] end
|
||||||
|
|
||||||
local message = PLUGIN.getSlap(slapper, victim)
|
local message = PLUGIN.getSlap(slapper, victim)
|
||||||
send_message(msg.chat.id, latcyr(message))
|
send_message(msg.chat.id, latcyr(message))
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ function PLUGIN.action(msg)
|
|||||||
|
|
||||||
local fahrenheit = data.temp
|
local fahrenheit = data.temp
|
||||||
local celsius = string.format('%.0f', (fahrenheit - 32) * 5/9)
|
local celsius = string.format('%.0f', (fahrenheit - 32) * 5/9)
|
||||||
local message = celsius .. '°C | ' .. fahrenheit .. '°F, ' .. data.text
|
local message = celsius .. '°C | ' .. fahrenheit .. '°F, ' .. data.text .. '.'
|
||||||
|
|
||||||
send_msg(msg, message)
|
send_msg(msg, message)
|
||||||
|
|
||||||
|
@ -38,11 +38,23 @@ local action = function(msg)
|
|||||||
break -- Seriously, there's probably a way more elegant solution.
|
break -- Seriously, there's probably a way more elegant solution.
|
||||||
end
|
end
|
||||||
|
|
||||||
text = text:gsub('</?.>', '')
|
if not text then
|
||||||
|
return send_msg(msg, config.locale.errors.results)
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[ Uncomment this for more than one-paragraph summaries.
|
||||||
local l = text:find('<h2>')
|
local l = text:find('<h2>')
|
||||||
if l then
|
if l then
|
||||||
text = text:sub(1, l-2)
|
text = text:sub(1, l-2)
|
||||||
end
|
end
|
||||||
|
]]--
|
||||||
|
|
||||||
|
text = text:gsub('</?.->', '')
|
||||||
|
|
||||||
|
local l = text:find('\n') -- Comment this block for more than one-paragraph summaries.
|
||||||
|
if l then
|
||||||
|
text = text:sub(1, l-1)
|
||||||
|
end
|
||||||
|
|
||||||
text = text .. '\n' .. url
|
text = text .. '\n' .. url
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user