Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix karma adjustment bug and implement identity. #90

Merged
merged 1 commit into from

2 participants

@hyPiRion

(@amalloy beat me to the adjustment bug and I just rebased from there.)

(identity nickname) and $identity nickname will print the karma of the nickname specified with this commit.

@Raynes Raynes merged commit 1d0a2f5 into Raynes:master
@hyPiRion hyPiRion deleted the hyPiRion:fix-karma branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 23, 2013
  1. @hyPiRion
This page is out of date. Refresh to see the latest.
Showing with 14 additions and 11 deletions.
  1. +14 −11 src/lazybot/plugins/karma.clj
View
25 src/lazybot/plugins/karma.clj
@@ -55,24 +55,27 @@
new-karma (f karma)]
(change-karma snick new-karma com-m))))
+(def print-karma
+ (fn [{:keys [com bot channel args] :as com-m}]
+ (let [nick (first args)]
+ (send-message com-m
+ (if-let [karma (get-karma nick (:server @com) channel)]
+ (str nick " has karma " karma ".")
+ (str "I have no record for " nick "."))))))
+
(defplugin
(:hook :on-message
(fn [{:keys [message] :as com-m}]
- (let [[_ direction snick] (re-find #"^\((inc|dec) (.+)\)(\s*;.*)?$" message)]
+ (let [[_ direction snick] (re-find #"^\((inc|dec|identity) (.+)\)(\s*;.*)?$" message)]
(when snick
- ((karma-fn (case direction
- "inc" inc
- "dec" dec))
+ ((case direction
+ "inc" (karma-fn inc)
+ "dec" (karma-fn dec)
+ "identity" print-karma)
(merge com-m {:args [snick]}))))))
(:cmd
"Checks the karma of the person you specify."
- #{"karma"}
- (fn [{:keys [com bot channel args] :as com-m}]
- (let [nick (first args)]
- (send-message com-m
- (if-let [karma (get-karma nick (:server @com) channel)]
- (str nick " has karma " karma ".")
- (str "I have no record for " nick "."))))))
+ #{"karma" "identity"} print-karma)
(:cmd
"Increases the karma of the person you specify."
#{"inc"} (karma-fn inc))
Something went wrong with that request. Please try again.