Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

server/base: fix some bugs

  • Loading branch information...
commit 8335f7d1038ce98292b5faae4ab4372270e27203 1 parent 3305251
@meh authored
View
2  etc/failircd.yml
@@ -16,7 +16,7 @@ server:
operators:
- mask: "meh!*@*"
password: password
- flags: netadmin
+ flags: god
modules:
base:
View
4 lib/failirc/common/modes/mode.rb
@@ -51,8 +51,8 @@ def powers
result.flatten.compact.uniq
end
- def enabled?; !!@value; end
- def disabled?; !@value; end
+ def enabled?; !!@value; end
+ def disabled?; !enabled?; end
def enable!; @value = true; end
def disable!; @value = false; end
View
17 lib/failirc/server/modules/base.rb
@@ -22,7 +22,7 @@
require 'failirc/server/modules/base/responses'
require 'failirc/server/modules/base/extensions'
-require 'failirc/server/modules/base/flags'
+require 'failirc/server/modules/base/powers'
require 'failirc/server/modules/base/incoming'
require 'failirc/server/modules/base/servers'
require 'failirc/server/modules/base/clients'
@@ -710,12 +710,9 @@ def nick_is_ok? (thing, nick)
text = type
end
- case kind
- when :message
- kind = :PRIVMSG
-
- when :notice
- kind = :NOTICE
+ kind = case ~kind
+ when :message then :PRIVMSG
+ when :notice then :NOTICE
end
to.send ":#{mask} #{kind} #{name} :\x01#{text}\x01"
@@ -817,7 +814,7 @@ def nick_is_ok? (thing, nick)
channel.invited.delete(user.mask)
end
- thing.channels.add(channel)
+ thing.channels.add(~channel)
if user.channel.modes.anonymous?
mask = Mask.parse('anonymous!anonymous@anonymous.')
@@ -1058,7 +1055,7 @@ def nick_is_ok? (thing, nick)
users = 'anonymous'
else
users = channel.users.map {|(_, user)|
- if channel.modes.auditorium? && !user.is_level_enough?('%') && !thing.modes.ircop?
+ if channel.modes.auditorium? && !user.level.enough?('%') && !thing.modes.ircop?
if user.level
user.to_s
end
@@ -1073,7 +1070,7 @@ def nick_is_ok? (thing, nick)
users: users
end
- thing.send RPL_ENDOFNAMES, channel
+ thing.send RPL_ENDOFNAMES, channel.to_s
end
on :topic do |thing, string|
View
16 lib/failirc/server/modules/base/channel.rb
@@ -94,7 +94,7 @@ def users
users = Users.new(self)
@users.select {|_, user|
- user.is_level_enough?(@level)
+ user.level.enough?(@level)
}.each {|_, user|
user = user.clone
channel = self
@@ -146,22 +146,26 @@ def invited? (client, shallow=false)
return false
end
- def to_s
- @name
- end
-
def level?
@level
end
def level (level)
- return self unless User::Levels.has_value?(level)
+ return self unless User::Level::Modes.has_value?(level)
result = self.clone
result.level = level
result
end
+
+ def to_s
+ @name
+ end
+
+ def inspect
+ to_s
+ end
end
end; end; end
View
11 lib/failirc/server/modules/base/client.rb
@@ -24,17 +24,22 @@ module Client
ssl :Z,
must: :do_god
+ god ??,
+ must: :do_god,
+ inherits: :netadmin,
+ powers: [:do_god]
+
netadmin :N,
must: :give_netadmin,
inherits: :operator,
powers: [:give_netadmin, :give_ircop]
- operator :o,
+ ircop :o,
must: :give_ircop,
powers: [
:kill, :see_secrets,
- :give_channel_owner, :give_channel_admin, :channel_moderation,
- :change_user_modes, :change_client_modes
+ :give_channel_owner, :give_channel_admin, Powers::Channel::Moderation,
+ Powers::User::ChangeModes, Powers::Client::ChangeModes
]
}
View
53 lib/failirc/server/modules/base/powers.rb
@@ -0,0 +1,53 @@
+#--
+# Copyleft meh. [http://meh.paranoid.pk | meh@paranoici.org]
+#
+# This file is part of failirc.
+#
+# failirc is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# failirc is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with failirc. If not, see <http://www.gnu.org/licenses/>.
+#++
+
+module IRC; class Server; module Base
+
+module Powers
+ module Channel
+ ChangeModes = [
+ :change_topic_mode,
+ :change_no_external_messages_mode, :change_secret_mode,
+ :change_ssl_mode, :change_moderated_mode,
+ :change_invite_only_mode, :change_auditorium_mode,
+ :change_anonymous_mode, :change_limit_mode,
+ :change_redirect_mode, :change_no_knocks_mode,
+ :add_invitation, :channel_ban, :add_ban_exception,
+ :change_channel_password, :change_no_colors_mode,
+ :change_no_ctcps_mode, :change_no_nick_change_mode,
+ :change_no_kicks_mode, :change_strip_colors_mode,
+ :change_no_invites_mode, :change_private_mode,
+ ]
+
+ Moderation = [:invite, :kick, :change_topic, ChangeModes]
+ end
+
+ module User
+ ChangeModes = [
+ :give_channel_operator, :give_channel_halfop,
+ :give_voice
+ ]
+ end
+
+ module Client
+ ChangeModes = []
+ end
+end
+
+end; end; end
View
4 lib/failirc/server/modules/base/responses.rb
@@ -148,7 +148,7 @@ module IRC; class Server; module Base
# If the topic is set, RPL_TOPIC is sent back else RPL_NOTOPIC.
RPL_TOPIC = {
code: 332,
- text: '#{value.channel.name} :#{value.to_s}'
+ text: '#{value.channel.name} :#{value}'
}
# Returned by the server to indicate that the attempted INVITE message was successful and is being passed onto the end client.
@@ -194,7 +194,7 @@ module IRC; class Server; module Base
# The exception to this is when a NAMES message is sent with no parameters and all visible channels and contents are sent back in a series of RPL_NAMEREPLY messages with a RPL_ENDOFNAMES to mark the end.
RPL_ENDOFNAMES = {
code: 366,
- text: '#{value.to_s} :End of /NAMES list'
+ text: '#{value} :End of /NAMES list'
}
RPL_LINKS = {
View
13 lib/failirc/server/modules/base/user.rb
@@ -19,6 +19,7 @@
require 'failirc/server/modules/base/user/extensions'
require 'failirc/server/modules/base/user/level'
+require 'failirc/server/modules/base/user/can'
module IRC; class Server; module Base
@@ -40,7 +41,7 @@ class User
operator :o,
must: :give_channel_operator,
inherits: :halfop,
- powers: [:moderate_channel, :change_user_modes]
+ powers: [Powers::Channel::Moderation, Powers::User::ChangeModes]
halfop :h,
must: :give_channel_halfop,
@@ -54,9 +55,8 @@ class User
extend Forwardable
- attr_reader :client, :channel, :modes, :level
- def_delegators :@modes, :can
- undef_method :send
+ attr_reader :client, :channel, :modes, :level
+ undef_method :send
def initialize (client, channel)
@client = client
@@ -78,6 +78,11 @@ def method_missing (id, *args, &block)
end
end
+ memoize
+ def can
+ Can.new(self)
+ end
+
def to_s
return "#{level}#{nick}"
end
View
32 lib/failirc/server/modules/base/user/can.rb
@@ -0,0 +1,32 @@
+#--
+# Copyleft meh. [http://meh.paranoid.pk | meh@paranoici.org]
+#
+# This file is part of failirc.
+#
+# failirc is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# failirc is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with failirc. If not, see <http://www.gnu.org/licenses/>.
+#++
+
+module IRC; class Server; module Base; class User
+
+class Can < BasicObject
+ def initialize (user)
+ @user = user
+ end
+
+ def method_missing (*args, &block)
+ @user.modes.can.send(*args, &block) || @user.client.modes.can(*args, &block)
+ end
+end
+
+end; end; end; end
View
2  lib/failirc/server/modules/base/user/extensions.rb
@@ -19,6 +19,6 @@
class String
def is_level?
- IRC::Server::Base::User::Levels.has_value?(self) ? self : false
+ IRC::Server::Base::User::Level::Modes.has_value?(self) ? self : false
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.