cosgrove 0.0.1rc6 → 0.0.1rc7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 05453b219cb1f71296497b09fe94e064fcd3cae3
4
- data.tar.gz: 36cadbb07df06d436d21fa5d47d69268669f4025
3
+ metadata.gz: 5843bf0c639c5f36039db3cd729c9dd081571dc4
4
+ data.tar.gz: ff7a430fe1013201e3ff4018d7c10cf8d4bc07f4
5
5
  SHA512:
6
- metadata.gz: 3a8b9fc23228ee5174d8cd0baab82f21df6b38da9de16ad8a0955ce8fb8320e2fcdf0a08a90fa84ffc309d282a17745b64507c75ca9708c6baf1f15edbded386
7
- data.tar.gz: 3d30aafad92e326ccaf725ea626d03e362dfa428b026311ba38b1e7454ab31cc00e7f2864529cac1193a9b24a818443ef09336527b4f5c1f994d797f955d1bf2
6
+ metadata.gz: c28bfcf611a16d891248b4abf5c1110c010a2f602d45adebc8c51ea6f8fb8b830a6734319c317b7ec4eb566e87d4601575969ec37d7bce1462a3afd05694b254
7
+ data.tar.gz: fa97afa5b24ec0e142cf423c936497878bf21b518a29b5488022527fb8a431205e1936e40e22862a8ac552db08d732b92f6fe8bad33470451dcfb99dfd064b28
@@ -17,7 +17,7 @@ GIT
17
17
  PATH
18
18
  remote: .
19
19
  specs:
20
- cosgrove (0.0.1rc6)
20
+ cosgrove (0.0.1rc7)
21
21
  activesupport (~> 5.1, >= 5.1.1)
22
22
  ai4r (~> 1.13, >= 1.13)
23
23
  discordrb (~> 3.2, >= 3.2.1)
@@ -16,6 +16,10 @@ module Cosgrove
16
16
  yml[:cosgrove][:upvote_weight]
17
17
  end
18
18
 
19
+ def cosgrove_disable_comment_voting
20
+ yml[:cosgrove][:disable_comment_voting].to_s == 'true'
21
+ end
22
+
19
23
  def steem_api_url
20
24
  chain[:steem_api_url]
21
25
  end
@@ -74,6 +78,20 @@ module Cosgrove
74
78
 
75
79
  weight || default_weight
76
80
  end
81
+
82
+ def channel_disable_comment_voting(channel_id)
83
+ rules = yml[:cosgrove][:upvote_rules][:channels]
84
+ default_disable_comment_voting = rules[:default][:disable_comment_voting].to_s == 'true' rescue false
85
+
86
+ keys = rules.keys - [:default]
87
+
88
+ disable_comment_voting = keys.map do |key|
89
+ rule = rules[key]
90
+ rule[:disable_comment_voting] if rule[:channel_id] == channel_id
91
+ end.compact.last
92
+
93
+ disable_comment_voting || default_disable_comment_voting
94
+ end
77
95
  private
78
96
  def chain
79
97
  @chain ||= yml[:chain]
@@ -49,6 +49,7 @@ module Cosgrove
49
49
 
50
50
  created ||= post.created
51
51
  cashout_time ||= post.cashout_time
52
+ root_post = post.parent_author == ''
52
53
 
53
54
  nope = if created > 1.minute.ago
54
55
  "Give it a second! It's going to SPACE! Can you give it a second to come back from space?"
@@ -71,6 +72,9 @@ module Cosgrove
71
72
  elsif muted.include? author_name
72
73
  puts "Won't vote because author muted."
73
74
  'Unable to vote.'
75
+ elsif !root_post && channel_disable_comment_voting(event.channel.id)
76
+ puts "Won't vote because comment voting is disabled."
77
+ 'Unable to vote.'
74
78
  elsif !registered
75
79
  'Unable to vote. Feature resticted to registered users.'
76
80
  elsif cb_account.novote?
@@ -1,4 +1,4 @@
1
1
  module Cosgrove
2
- VERSION = '0.0.1rc6'
2
+ VERSION = '0.0.1rc7'
3
3
  AGENT_ID = "cosgrove/#{VERSION}"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cosgrove
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1rc6
4
+ version: 0.0.1rc7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Martin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-27 00:00:00.000000000 Z
11
+ date: 2017-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler