2016-03-19 10:09:28 +00:00
|
|
|
require 'cinch'
|
|
|
|
require 'open-uri'
|
|
|
|
require_relative '../classes/Util.rb'
|
|
|
|
class BotTools
|
2021-05-30 01:46:57 +00:00
|
|
|
include Cinch::Plugin
|
|
|
|
include Hooks::ACLHook
|
|
|
|
include Util::PluginHelper
|
|
|
|
set :prefix, /^:/
|
|
|
|
@clist = %w{join part}
|
|
|
|
@@commands["join"] = ":join <channel> - join channel"
|
|
|
|
@@commands["part"] = ":part <channel> - part channel"
|
|
|
|
@@commands["stay"] = ":stay <channel> - join channel, and add it to autojoin for future sessions"
|
|
|
|
@@levelRequired = 10
|
2021-06-01 16:22:09 +00:00
|
|
|
match(/join (#?.+)/ , method: :join)
|
|
|
|
match(/part (#?.+)/ , method: :part)
|
|
|
|
match(/stay (#?.+)/ , method: :stay)
|
2016-03-19 10:09:28 +00:00
|
|
|
|
2021-05-30 01:46:57 +00:00
|
|
|
def join(m, chan)
|
|
|
|
chan = "##{chan}" if !chan.match(/^#/)
|
|
|
|
response = "#{m.user.nick}: "
|
|
|
|
if(!aclcheck(m))
|
|
|
|
response << Util::Util.instance.getExcuse() << " (you lack sufficient privs bruh)"
|
|
|
|
else
|
|
|
|
bot = m.bot
|
|
|
|
idx = bot.channels.any? { |x| x.name == chan }
|
|
|
|
if(!idx)
|
|
|
|
bot.join(chan)
|
|
|
|
response << "joined #{chan}"
|
|
|
|
else
|
|
|
|
response << "already in #{chan} hurr dee derp"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
m.reply response
|
|
|
|
end
|
|
|
|
def part(m, chan)
|
|
|
|
chan = "##{chan}" if !chan.match(/^#/)
|
|
|
|
response = "#{m.user.nick}: "
|
|
|
|
if(!aclcheck(m))
|
|
|
|
response << Util::Util.instance.getExcuse() << " (where dem privileges @ doe playboi???)"
|
|
|
|
else
|
|
|
|
bot = m.bot
|
|
|
|
idx = bot.channels.any? { |x| x.name == chan }
|
|
|
|
if(!idx)
|
|
|
|
response << "parting #{chan}"
|
|
|
|
bot.part(chan)
|
|
|
|
else
|
|
|
|
response << "not in #{chan} ya styoobid"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
m.reply(response)
|
|
|
|
end
|
|
|
|
|
|
|
|
def stay(m, chan)
|
created a gemfile to start keeping track of used gems, etc
created etc/art which houses all of my ansi art,
finished a basic implementation of Artism.rb, only missing
art.web currently but I will get to that soon
created classes/Meta.rb, which injects some helper methods into
Integer (eg, 10.minutes, 2.kilobytes, etc), because why not?
didn't want to have to use activesupport!
If it wasn't in the last one, I also updated Replace to include
the user prefix for their level of access (e.g. +o = @, +v = +)
2021-05-30 07:12:11 +00:00
|
|
|
debug "request to joinstay chan #{chan}"
|
2021-05-30 01:46:57 +00:00
|
|
|
chan = "##{chan}" if !chan.match(/^#/)
|
|
|
|
bot = m.bot
|
|
|
|
response = "#{m.user.nick}: "
|
|
|
|
if(!aclcheck(m))
|
|
|
|
response << Util::Util.instance.getExcuse() << " (lol privilege checc, niec try bruh)"
|
|
|
|
else
|
|
|
|
if(bot.config.channels.any? { |c| chan == c })
|
|
|
|
response << "bruh im already autojoining there anyway. wtf lol"
|
|
|
|
else
|
|
|
|
response << "adding #{chan} to autojoin...."
|
created a gemfile to start keeping track of used gems, etc
created etc/art which houses all of my ansi art,
finished a basic implementation of Artism.rb, only missing
art.web currently but I will get to that soon
created classes/Meta.rb, which injects some helper methods into
Integer (eg, 10.minutes, 2.kilobytes, etc), because why not?
didn't want to have to use activesupport!
If it wasn't in the last one, I also updated Replace to include
the user prefix for their level of access (e.g. +o = @, +v = +)
2021-05-30 07:12:11 +00:00
|
|
|
server = Util::Util.instance.hton(bot)
|
|
|
|
debug "adding #{chan} to autojoin, server: #{server}"
|
|
|
|
Util::Util.instance.addautojoin(server,chan)
|
2021-05-30 01:46:57 +00:00
|
|
|
response << "\n and joining #{chan} now..."
|
|
|
|
bot.join(chan)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
m.reply response
|
|
|
|
end
|
2016-03-19 10:09:28 +00:00
|
|
|
end
|
|
|
|
|
2021-05-30 01:46:57 +00:00
|
|
|
|
|
|
|
|