cinch-reddit 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/cinch-reddit.gemspec +1 -1
- data/lib/cinch/plugins/reddit.rb +14 -2
- metadata +5 -5
data/cinch-reddit.gemspec
CHANGED
data/lib/cinch/plugins/reddit.rb
CHANGED
@@ -30,6 +30,18 @@ module Cinch
|
|
30
30
|
open(url, "User-Agent" => "reddit-irc-bot").read
|
31
31
|
end
|
32
32
|
|
33
|
+
# Pluralizes a string
|
34
|
+
# Simple and stupid, but it works
|
35
|
+
def pluralize(n, singular, plural=nil)
|
36
|
+
if n == 1
|
37
|
+
"1 #{singular}"
|
38
|
+
elsif plural
|
39
|
+
"%s %s" % [commify(n), plural]
|
40
|
+
else
|
41
|
+
"%s %ss" % [commify(n), singular]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
33
45
|
# Plugin code
|
34
46
|
|
35
47
|
# Karma Lookup
|
@@ -54,7 +66,7 @@ module Cinch
|
|
54
66
|
else
|
55
67
|
subMods = []
|
56
68
|
data.each { |mod| subMods << mod["name"] }
|
57
|
-
m.reply("%s has
|
69
|
+
m.reply("%s has %s: %s" % [Format(:bold, subreddit), pluralize( subMods.length, "moderator"), subMods[0..-2].join(", ") + ", and " + subMods[-1] ])
|
58
70
|
end
|
59
71
|
end
|
60
72
|
|
@@ -66,7 +78,7 @@ module Cinch
|
|
66
78
|
unless data
|
67
79
|
m.reply("%s doesn't appear to exist and therefore can't have subscribers" % subreddit)
|
68
80
|
else
|
69
|
-
m.reply("%s has %s
|
81
|
+
m.reply("%s has %s" % [Format(:bold, subreddit), pluralize(data, "reader")])
|
70
82
|
end
|
71
83
|
end
|
72
84
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cinch-reddit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-05-11 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cinch
|
16
|
-
requirement: &
|
16
|
+
requirement: &70335273805600 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70335273805600
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: json
|
27
|
-
requirement: &
|
27
|
+
requirement: &70335273805060 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70335273805060
|
36
36
|
description: ! " This is a simple reddit plugin for the excellent cinch irc bot
|
37
37
|
framework.\n It provides a few simple commands, !karma, !mods, and !readers.\n
|
38
38
|
\ See the github page for more details\n"
|