From 6fbb04415c994298b48383e2c65b0631c110c9ab Mon Sep 17 00:00:00 2001 From: Marrub Date: Sat, 23 Feb 2019 23:45:25 -0500 Subject: [PATCH] fix errors with IRC --- source/servers/irc.rb | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/source/servers/irc.rb b/source/servers/irc.rb index 8ac014b..e4716e4 100644 --- a/source/servers/irc.rb +++ b/source/servers/irc.rb @@ -28,6 +28,8 @@ class Sv_IRC < Vrobot4::Server::Server end on :message do |evt| + return unless evt.channel + m = Vrobot4::Server::Message.new \ msg: evt.message, user: User.new(evt.user, evt.channel), @@ -41,6 +43,7 @@ class Sv_IRC < Vrobot4::Server::Server end @bot.loggers.level = :warn + @id = info["server"].downcase.sum end # (see Vrobot4::Server::Server#connect) @@ -54,6 +57,7 @@ class Sv_IRC < Vrobot4::Server::Server end protected + # (see Vrobot4::Server::Server#load_permissions) def load_permissions pinf @mprm = {chan: {}, role: {}, glob: {}} @@ -70,13 +74,18 @@ class Sv_IRC < Vrobot4::Server::Server end if pinf end + # Helper for channel permissions. class ChannelPerms 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 # 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 end private_constant :ChannelPerms @@ -90,7 +99,7 @@ class Sv_IRC < Vrobot4::Server::Server def initialize user, chan @real = user @name = user.nick - @id = user.nick.downcase.hash + @id = user.nick.downcase.sum if user.oper? then @roles = "Oohv" elsif chan.opped? user then @roles = "ohv" elsif chan.half_opped? user then @roles = "hv" @@ -107,7 +116,7 @@ class Sv_IRC < Vrobot4::Server::Server def initialize chan @real = chan @name = chan.name.downcase - @id = chan.name.downcase.hash + @id = chan.name.downcase.sum end end end