cinch-yaml-score 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.md +34 -0
  2. data/lib/cinch/plugins/yamlscore.rb +11 -6
  3. metadata +2 -2
data/README.md CHANGED
@@ -1,3 +1,37 @@
1
1
  # Cinch YAML score plugin
2
2
 
3
3
  A Cinch plugin to count +1, scores are saved in yaml file for persistence.
4
+
5
+ ## Installation
6
+
7
+ First install the gem by running:
8
+
9
+ ```bash
10
+ gem install cinch-yaml-score
11
+ ```
12
+
13
+ Then load it in your bot:
14
+
15
+ ```ruby
16
+ require "cinch"
17
+ require "cinch/plugins/yamlscore"
18
+
19
+ bot = Cinch::Bot.new do
20
+ configure do |c|
21
+ c.plugins.plugins = [Cinch::Plugins::YamlScore]
22
+ # The following line is optional, if committed there will be no message.
23
+ c.plugins.options[Cinch::Plugins::YamlScore] = { warn_no_user_message: "User %s is not in the channel, who do you want to score?" }
24
+ end
25
+ end
26
+
27
+ bot.start
28
+ ```
29
+
30
+ ## Commands
31
+
32
+ ```irc
33
+ !scores
34
+ !score <user>
35
+ <user>[,:]? [+-]1
36
+ <user>[,:]? ?[+-]{2}
37
+ ```
@@ -1,6 +1,3 @@
1
- # source: https://github.com/telemachus/antinoos/blob/master/memo.rb
2
- # license: https://github.com/telemachus/antinoos/blob/master/LICENSE
3
-
4
1
  require 'yaml'
5
2
 
6
3
  module Cinch
@@ -31,7 +28,7 @@ module Cinch
31
28
  end
32
29
  end
33
30
 
34
- match(/(\S+) ([-+]1)/, use_prefix: false, use_suffix: false, method: :change)
31
+ match(/(\S+) ([-+]1)/, use_prefix: false, use_suffix: false, method: :change)
35
32
  match(/(\S+) ?([-+]{2})/, use_prefix: false, use_suffix: false, method: :change)
36
33
  def change(m, nick, score)
37
34
  if nick == m.user.nick
@@ -45,8 +42,16 @@ module Cinch
45
42
  @scores.delete(nick) if @scores[nick] == 0
46
43
  m.reply "#{m.user.nick}(#{@scores[m.user.nick]}) gave #{score} for #{nick}(#{@scores[nick]})."
47
44
  update_store
48
- else
49
- m.reply "User #{nick} is not in the channel, who do you want to score?"
45
+ elsif %w( , : ).include?(nick[-1]) && m.channel.has_user?(nick.slice(0..-2))
46
+ nick.slice!(-1)
47
+ score.sub!(/([+-]){2}/,'\11')
48
+ @scores[nick] ||= 0
49
+ @scores[nick] += score.to_i
50
+ @scores.delete(nick) if @scores[nick] == 0
51
+ m.reply "#{m.user.nick}(#{@scores[m.user.nick]}) gave #{score} for #{nick}(#{@scores[nick]})."
52
+ update_store
53
+ elsif config[:warn_no_user_message]
54
+ m.reply config[:warn_no_user_message] % nick
50
55
  end
51
56
  end
52
57
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cinch-yaml-score
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-27 00:00:00.000000000 Z
12
+ date: 2012-07-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cinch