fix errors with IRC

master
an 2019-02-23 23:45:25 -05:00
parent dcb826dd7f
commit 6fbb04415c
1 changed files with 12 additions and 3 deletions

View File

@ -28,6 +28,8 @@ class Sv_IRC < Vrobot4::Server::Server
end end
on :message do |evt| on :message do |evt|
return unless evt.channel
m = Vrobot4::Server::Message.new \ m = Vrobot4::Server::Message.new \
msg: evt.message, msg: evt.message,
user: User.new(evt.user, evt.channel), user: User.new(evt.user, evt.channel),
@ -41,6 +43,7 @@ class Sv_IRC < Vrobot4::Server::Server
end end
@bot.loggers.level = :warn @bot.loggers.level = :warn
@id = info["server"].downcase.sum
end end
# (see Vrobot4::Server::Server#connect) # (see Vrobot4::Server::Server#connect)
@ -54,6 +57,7 @@ class Sv_IRC < Vrobot4::Server::Server
end end
protected protected
# (see Vrobot4::Server::Server#load_permissions) # (see Vrobot4::Server::Server#load_permissions)
def load_permissions pinf def load_permissions pinf
@mprm = {chan: {}, role: {}, glob: {}} @mprm = {chan: {}, role: {}, glob: {}}
@ -70,13 +74,18 @@ class Sv_IRC < Vrobot4::Server::Server
end if pinf end if pinf
end end
# Helper for channel permissions.
class ChannelPerms class ChannelPerms
def initialize() @cprm = {} end def initialize() @cprm = {} end
# Returns true if the channel is enabled, false otherwise. # @param chan [Sv_IRC::Channel] the channel for this permission
# @return [Boolean] true if the channel is enabled, false otherwise.
def [](chan) @cprm[chan.name] end def [](chan) @cprm[chan.name] end
# Sets a channel's permission on/off. # Sets a channel's permission on/off.
# @param name [String] the channel for this permission
# @param set [Boolean] if this permission should be set
# @return [void]
def []=(name, set) @cprm[name] = set end def []=(name, set) @cprm[name] = set end
end end
private_constant :ChannelPerms private_constant :ChannelPerms
@ -90,7 +99,7 @@ class Sv_IRC < Vrobot4::Server::Server
def initialize user, chan def initialize user, chan
@real = user @real = user
@name = user.nick @name = user.nick
@id = user.nick.downcase.hash @id = user.nick.downcase.sum
if user.oper? then @roles = "Oohv" if user.oper? then @roles = "Oohv"
elsif chan.opped? user then @roles = "ohv" elsif chan.opped? user then @roles = "ohv"
elsif chan.half_opped? user then @roles = "hv" elsif chan.half_opped? user then @roles = "hv"
@ -107,7 +116,7 @@ class Sv_IRC < Vrobot4::Server::Server
def initialize chan def initialize chan
@real = chan @real = chan
@name = chan.name.downcase @name = chan.name.downcase
@id = chan.name.downcase.hash @id = chan.name.downcase.sum
end end
end end
end end