summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
Diffstat (limited to 'data')
-rw-r--r--data/rbot/plugins/excuse.rb2
-rw-r--r--data/rbot/plugins/points.rb (renamed from data/rbot/plugins/karma.rb)64
2 files changed, 40 insertions, 26 deletions
diff --git a/data/rbot/plugins/excuse.rb b/data/rbot/plugins/excuse.rb
index ad0e8334..61f38bd6 100644
--- a/data/rbot/plugins/excuse.rb
+++ b/data/rbot/plugins/excuse.rb
@@ -387,7 +387,7 @@ class ExcusePlugin < Plugin
"Dyslexics retyping hosts file on servers",
"The Internet is being scanned for viruses.",
"Your computer's union contract is set to expire at midnight.",
-"Bad user karma.",
+"Bad reputation.",
"/dev/clue was linked to /dev/null",
"Increased sunspot activity.",
"We already sent around a notice about that.",
diff --git a/data/rbot/plugins/karma.rb b/data/rbot/plugins/points.rb
index 93d21189..21157f3d 100644
--- a/data/rbot/plugins/karma.rb
+++ b/data/rbot/plugins/points.rb
@@ -1,4 +1,4 @@
-class KarmaPlugin < Plugin
+class PointsPlugin < Plugin
def initialize
super
@@ -14,50 +14,62 @@ class KarmaPlugin < Plugin
@registry.set_default(0)
# import if old file format found
- oldkarma = @bot.path 'karma.rbot'
- if File.exist? oldkarma
- log "importing old karma data"
- IO.foreach(oldkarma) do |line|
+ oldpoints = @bot.path 'points.rbot'
+ if File.exist? oldpoints
+ log "importing old points data"
+ IO.foreach(oldpoints) do |line|
if(line =~ /^(\S+)<=>([\d-]+)$/)
item = $1
- karma = $2.to_i
- @registry[item] = karma
+ points = $2.to_i
+ @registry[item] = points
end
end
- File.delete oldkarma
+ File.delete oldpoints
end
end
def stats(m, params)
if (@registry.length)
- max = @registry.values.max
- min = @registry.values.min
- best = @registry.to_hash.index(max)
- worst = @registry.to_hash.index(min)
+ max = @registry.values.max || "zero"
+ min = @registry.values.min || "zero"
+ best = @registry.to_hash.key(max) || "nobody"
+ worst = @registry.to_hash.key(min) || "nobody"
m.reply "#{@registry.length} items. Best: #{best} (#{max}); Worst: #{worst} (#{min})"
end
end
- def karma(m, params)
+ def dump(m, params)
+ if (@registry.length)
+ msg = "Points dump: "
+ msg << @registry.to_hash.sort_by { |k, v| v }.reverse.
+ map { |k,v| "#{k}: #{v}" }.
+ join(", ")
+ m.reply msg
+ else
+ m.reply "nobody has any points yet!"
+ end
+ end
+
+ def points(m, params)
thing = params[:key]
thing = m.sourcenick unless thing
thing = thing.to_s
- karma = @registry[thing]
- if(karma != 0)
- m.reply "karma for #{thing}: #{@registry[thing]}"
+ points = @registry[thing]
+ if(points != 0)
+ m.reply "points for #{thing}: #{@registry[thing]}"
else
- m.reply "#{thing} has neutral karma"
+ m.reply "#{thing} has zero points"
end
end
- def setkarma(m, params)
+ def setpoints(m, params)
thing = (params[:key] || m.sourcenick).to_s
@registry[thing] = params[:val].to_i
- karma(m, params)
+ points(m, params)
end
def help(plugin, topic="")
- "karma module: Listens to everyone's chat. <thing>++/<thing>-- => increase/decrease karma for <thing>, karma for <thing>? => show karma for <thing>, karmastats => show stats. Karma is a community rating system - only in-channel messages can affect karma and you cannot adjust your own."
+ "points module: Keeps track of internet points, infusing your pointless life with meaning. Listens to everyone's chat. <thing>++/<thing>-- => increase/decrease points for <thing>, points for <thing>? => show points for <thing>, pointstats => show best/worst, pointsdump => show everyone's points. Points are a community rating system - only in-channel messages can affect points and you cannot adjust your own."
end
def message(m)
@@ -96,15 +108,17 @@ class KarmaPlugin < Plugin
next if v == 0
@registry[k] += (v > 0 ? 1 : -1)
m.reply @bot.lang.get("thanks") if k == @bot.nick && v > 0
+ m.reply "#{k} now has #{@registry[k]} points!"
end
end
end
-plugin = KarmaPlugin.new
+plugin = PointsPlugin.new
plugin.default_auth( 'edit', false )
-plugin.map 'karmastats', :action => 'stats'
-plugin.map 'karma :key', :defaults => {:key => false}
-plugin.map 'setkarma :key :val', :defaults => {:key => false}, :requirements => {:val => /^-?\d+$/}, :auth_path => 'edit::set!'
-plugin.map 'karma for :key'
+plugin.map 'pointstats', :action => 'stats'
+plugin.map 'points :key', :defaults => {:key => false}
+plugin.map 'setpoints :key :val', :defaults => {:key => false}, :requirements => {:val => /^-?\d+$/}, :auth_path => 'edit::set!'
+plugin.map 'points for :key'
+plugin.map 'pointsdump', :action => 'dump'