Skip to content

Commit

Permalink
Make all users op on +o in plugin Anarchism
Browse files Browse the repository at this point in the history
  • Loading branch information
Emeraude committed Jan 15, 2018
1 parent f24ac43 commit cb1c93d
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions src/DashBot/plugins/anarchism.cr
Original file line number Diff line number Diff line change
@@ -1,15 +1,48 @@
module DashBot::Plugins::Anarchism
extend self
@@is_op = false
@@user_list = Array(Crirc::Protocol::User).new

def bind(bot)
bind_new_user bot
bind_on_op bot
end

def bind_new_user(bot)
bot.on("JOIN") do |msg, _|
chan = Crirc::Protocol::Chan.new msg.message.to_s
user = Crirc::Protocol::User.new msg.source.source_nick
bot.mode chan, "+o", user
if @@is_op
chan = Crirc::Protocol::Chan.new msg.message.to_s
user = Crirc::Protocol::User.new msg.source.source_nick
bot.mode chan, "+o", user
end
end
end

def bind_on_op(bot)
bot.on("MODE") do |msg, _|
if msg.arguments.to_s.match(/\#.* \+o #{bot.network.nick}\z/)
chan = Crirc::Protocol::Chan.new msg.arguments.to_s.split(" ")[0]
@@is_op = true
@@user_list = Array(Crirc::Protocol::User).new
bot.names(chan)
elsif msg.arguments.to_s.match(/\#.* \-o #{bot.network.nick}\z/)
@@is_op = false
end
end

bot.on("353") do |msg, _|
msg.message.to_s.split(" ").each do |nick|
@@user_list.push Crirc::Protocol::User.new nick.lstrip("@+")
end
end

bot.on("366") do |msg, _|
if @@is_op
@@user_list.each do |user|
chan = Crirc::Protocol::Chan.new "#ratonade"
bot.mode chan, "+o", user
end
end
end
end
end

0 comments on commit cb1c93d

Please sign in to comment.