lib/cinch/plugins/dicebag.rb
# Score checker for Dicebag rolls. Checks a given user/channel/score
#   against the current high score for that user.
# @param [String] nick Nickname of the user who rolled the score.
# @param [String] channel Name of the channel where the roll was made.
# @param [Fixnum] score The score from the bag.
# @return [String] If the new score is higher, returns an announcement
#   to that effect, otherwise returns a blank string.
Score checker for Dicebag rolls. Checks a given user/channel/score
against the current high score for that user.
Score checker for Dicebag rolls . Checks a given user / channel / score against the current high score for that user .
def score_check(nick, channel, score)
        nick = nick.downcase
        @storage.data[channel] ||= {}
        @storage.data[channel][nick] ||= { score: score, time: Time.now }
        old = @storage.data[channel][nick]
        return '' unless @storage.data[channel][nick][:score] < score
        @storage.data[channel][nick] = { score: score, time: Time.now }
        @storage.synced_save(@bot)
        "A new high score! Their old high roll was #{old[:score]}, " \
          "#{old[:time].ago.to_words}."
      end
def score_check ( nick , channel , score ) nick = nick . downcase @storage . data [ channel ] ||= { } @storage . data [ channel ] [ nick ] ||= { score : score , time : Time . now } old = @storage . data [ channel ] [ nick ] return '' unless @storage . data [ channel ] [ nick ] [ :score ] < score @storage . data [ channel ] [ nick ] = { score : score , time : Time . now } @storage . synced_save ( @bot ) "A new high score! Their old high roll was #{old[:score]}, " "#{old[:time].ago.to_words}." end
Score checker for Dicebag rolls.
Score checker for Dicebag rolls .
# If the chennel or nick are not already initialized, spin them up # Check and see if this is a higher score.
If the new score is higher, returns an announcement to that effect, otherwise returns a blank string.
If the new score is higher returns an announcement to that effect otherwise returns a blank string .
String
nick
<not_specific>
channel
<not_specific>
score
<not_specific>
<not_specific>
score The score from the bag.
score The score from the bag .