Skip to content
Browse files

Update Scorekeeper for DM 1.0, use the configured nick_regex rather t…

…han \w+
  • Loading branch information...
1 parent 68e850f commit 0ef2fe1ec095e8bd19841f0039499607972bb6fc @RISCfuture RISCfuture committed Jul 25, 2010
Showing with 8 additions and 22 deletions.
  1. +2 −2 leaves/scorekeeper/controller.rb
  2. +0 −17 leaves/scorekeeper/lib/datamapper_extensions.rb
  3. +6 −3 libs/stem.rb
View
4 leaves/scorekeeper/controller.rb
@@ -15,10 +15,10 @@ def about_command(stem, sender, reply_to, msg)
def points_command(stem, sender, reply_to, msg)
if msg.nil? or msg.empty? then
var :totals => totals(stem, reply_to)
- elsif msg =~ /^(\w+)\s+history\s*(.*)$/ then
+ elsif msg =~ /^(#{stem.nick_regex})\s+history\s*(.*)$/ then
parse_history stem, reply_to, $1, $2
render :history
- elsif msg =~ /^(\w+)\s+([\+\-]\d+)\s*(.*)$/ then
+ elsif msg =~ /^(#{nick_regex})\s+([\+\-]\d+)\s*(.*)$/ then
parse_change stem, reply_to, sender, $1, $2.to_i, $3
render :change
else
View
17 leaves/scorekeeper/lib/datamapper_extensions.rb
@@ -1,17 +0,0 @@
-DataMapper::Timestamp.class_eval do
- private
-
- #HACK Use the current repository, not the default one.
- #
- # Updates this method to use the currently-scoped repository rather than the
- # model's default repository.
-
- def set_timestamps
- return unless dirty? || new_record?
- TIMESTAMP_PROPERTIES.each do |name,(_type,proc)|
- if model.properties(repository.name).named?(name)
- model.properties(repository.name)[name].set(self, proc.call(self, model.properties(repository.name)[name])) unless attribute_dirty?(name)
- end
- end
- end
-end
View
9 libs/stem.rb
@@ -232,6 +232,9 @@ def self.param(name, opts={}) # :nodoc:
# new one, or GHOSTs the nick if possible. This block should return nil if
# you do not want another NICK attempt to be made.
attr :nick_generator
+ # The regular expression for valid nicks, as a string. By default it's equal
+ # to NICK_REGEX.
+ attr :nick_regex
# The Daemon instance that describes the IRC server this client is connected
# to.
attr :server_type
@@ -660,7 +663,7 @@ def channel?(str)
# Returns true if the string appears to be a nickname.
def nick?(str)
- str.match(@nick_regex) != nil
+ str.match(nick_regex) != nil
end
# Returns the nick this stem is using.
@@ -851,10 +854,10 @@ def receive(comm)
msg = $1
meths[:irc_server_error] = [ self, msg ]
return meths
- elsif comm =~ /^:(#{@nick_regex})!(\S+?)@(\S+?)\s+([A-Z]+)\s+(.*?)[\r\n]*$/ then
+ elsif comm =~ /^:(#{nick_regex})!(\S+?)@(\S+?)\s+([A-Z]+)\s+(.*?)[\r\n]*$/ then
sender = { :nick => $1, :user => $2, :host => $3 }
command, arg_str = $4, $5
- elsif comm =~ /^:(#{@nick_regex})\s+([A-Z]+)\s+(.*?)[\r\n]*$/ then
+ elsif comm =~ /^:(#{nick_regex})\s+([A-Z]+)\s+(.*?)[\r\n]*$/ then
sender = { :nick => $1 }
command, arg_str = $2, $3
elsif comm =~ /^:([^\s:]+?)\s+([A-Z]+)\s+(.*?)[\r\n]*$/ then

0 comments on commit 0ef2fe1

Please sign in to comment.
Something went wrong with that request. Please try again.