descartes 0.7.8 → 0.8
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 +4 -4
- data/bin/descartes +10 -5
- data/lib/descartes/modules/files/pigro.json +19 -0
- data/lib/descartes/modules/files/pigro.txt +1 -1
- data/lib/descartes/modules/pigro.rb +47 -14
- data/lib/descartes/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 95f00d7baf615c6abd8b0054b5aa9867ec69b75e
|
|
4
|
+
data.tar.gz: fccadcee3c7c1a4509959eedf10f37e0a7b6f509
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1e4c84c9392f4b01d51f714e04891046df600c676809a16b482f575b581d3bd02cc7c1a89831cc5af7bc75e02cafa495186cc2ee9e91b0704a92623fad3b6746
|
|
7
|
+
data.tar.gz: b0fbad812364d96d88b7582ca740f88821cc08bb131078722ad82e86eb647c274ab79a30dc9078ebecd125000fb1830140aa5efdf6fa06bbece923e4ec84e699
|
data/bin/descartes
CHANGED
|
@@ -56,16 +56,21 @@ files = File.join File.dirname(__FILE__), '../lib/descartes/modules/files'
|
|
|
56
56
|
FileUtils.cp_r(files, options[:dotfiles]) unless File.directory? options[:dotfiles]
|
|
57
57
|
|
|
58
58
|
Dir["#{options[:dotfiles]}/**/*"].each { |file|
|
|
59
|
-
lib = Dir["#{files}/**/*"].select { |f| File.basename(f) == File.basename(file) }
|
|
60
|
-
next
|
|
61
|
-
next unless lib.
|
|
59
|
+
lib = Dir["#{files}/**/*"].select { |f| File.basename(f) == File.basename(file) }.first
|
|
60
|
+
next unless lib
|
|
61
|
+
next unless lib.end_with? '.txt'
|
|
62
62
|
|
|
63
|
-
if File.read(lib
|
|
64
|
-
FileUtils.cp lib
|
|
63
|
+
if File.read(lib) != File.read(file)
|
|
64
|
+
FileUtils.cp lib, options[:dotfiles]
|
|
65
65
|
puts "'#{file}' has been updated."
|
|
66
66
|
end
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
new_files = Dir["#{files}/**/*"].map { |f| File.basename(f) } - Dir["#{options[:dotfiles]}/**/*"].map { |f| File.basename(f) }
|
|
70
|
+
new_files.each { |new_file|
|
|
71
|
+
FileUtils.cp File.join(files, new_file), options[:dotfiles]
|
|
72
|
+
}
|
|
73
|
+
|
|
69
74
|
Cinch::Bot.new {
|
|
70
75
|
configure do |c|
|
|
71
76
|
c.nick = options[:nickname]
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"nicknames": [
|
|
4
|
+
{ "nickname": "RoxasShadowRS"},
|
|
5
|
+
{ "nickname": "RoxasShadow" },
|
|
6
|
+
],
|
|
7
|
+
"username" : "Roxas Shadow",
|
|
8
|
+
"password" : "Eheheheheh"
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
{
|
|
12
|
+
"nicknames": [
|
|
13
|
+
{ "nickname": "Helltilt" },
|
|
14
|
+
{ "nickname": "Hell-11" },
|
|
15
|
+
],
|
|
16
|
+
"username" : "Hell",
|
|
17
|
+
"password" : "Ohohohohoh"
|
|
18
|
+
},
|
|
19
|
+
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
pigro.omnivium.it
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
##
|
|
14
14
|
|
|
15
15
|
require 'assonnato'
|
|
16
|
+
require 'json'
|
|
16
17
|
|
|
17
18
|
class Descartes
|
|
18
19
|
class Pigro
|
|
@@ -30,10 +31,10 @@ class Descartes
|
|
|
30
31
|
options = { user: user.join }
|
|
31
32
|
end
|
|
32
33
|
|
|
33
|
-
host = get_host
|
|
34
|
-
shows = Assonnato
|
|
34
|
+
host = get_host
|
|
35
|
+
shows = Assonnato.new(host).show
|
|
35
36
|
|
|
36
|
-
series = shows.all
|
|
37
|
+
series = shows.all(:ongoing, options) + shows.all(:dropped, options) + shows.all(:finished, options)
|
|
37
38
|
|
|
38
39
|
if series.empty?
|
|
39
40
|
if options.has_key? :role
|
|
@@ -63,17 +64,17 @@ class Descartes
|
|
|
63
64
|
n_ep = (s.last == 'last' || s.last.numeric?) ? s.pop : nil
|
|
64
65
|
keyword = s.join
|
|
65
66
|
|
|
66
|
-
host = get_host
|
|
67
|
-
shows = Assonnato
|
|
68
|
-
episodes = Assonnato
|
|
67
|
+
host = get_host
|
|
68
|
+
shows = Assonnato.new(host).show
|
|
69
|
+
episodes = Assonnato.new(host).episode
|
|
69
70
|
|
|
70
|
-
series = shows.search
|
|
71
|
+
series = shows.search keyword
|
|
71
72
|
|
|
72
73
|
if series.empty?
|
|
73
74
|
m.reply 'Series not found.'
|
|
74
75
|
else
|
|
75
76
|
series.take(5).each { |s|
|
|
76
|
-
show = shows.get
|
|
77
|
+
show = shows.get(s.name).first
|
|
77
78
|
|
|
78
79
|
if n_ep.nil?
|
|
79
80
|
a = show.status.downcase.start_with?(?o) ? 'an' : ?a
|
|
@@ -92,7 +93,7 @@ class Descartes
|
|
|
92
93
|
}
|
|
93
94
|
}[0..-4]
|
|
94
95
|
elsif n_ep == 'last'
|
|
95
|
-
episode = episodes.last
|
|
96
|
+
episode = episodes.last(:ongoing).select { |ep| ep.show_name == s.name }.last
|
|
96
97
|
|
|
97
98
|
if episode
|
|
98
99
|
m.reply ("#{show.name.colorize} ##{episode.episode}".colorize + ' - ').tap { |staff|
|
|
@@ -121,7 +122,7 @@ class Descartes
|
|
|
121
122
|
m.reply "#{show.name.colorize} has no episodes yet."
|
|
122
123
|
end
|
|
123
124
|
else
|
|
124
|
-
episodes = episodes.get
|
|
125
|
+
episodes = episodes.get show.name, n_ep.to_i
|
|
125
126
|
|
|
126
127
|
if episodes.any?
|
|
127
128
|
episodes.each { |ep|
|
|
@@ -158,15 +159,47 @@ class Descartes
|
|
|
158
159
|
end
|
|
159
160
|
end
|
|
160
161
|
|
|
161
|
-
|
|
162
|
-
|
|
162
|
+
match /pigro (.+) - (.+) - (.+) - (.+)/, method: :edit_episode
|
|
163
|
+
def edit_episode(m, show, episode, field, status)
|
|
164
|
+
user = get_user m.user.nick
|
|
165
|
+
host = get_host
|
|
166
|
+
assonnato = Assonnato.new host
|
|
167
|
+
|
|
168
|
+
if user
|
|
169
|
+
login = assonnato.user.login user['username'], user['password']
|
|
170
|
+
if login['status'] == 'error'
|
|
171
|
+
m.reply login['message']
|
|
172
|
+
else
|
|
173
|
+
episode = assonnato.episode.edit show, episode.to_i, { field.to_sym => status.to_sym }
|
|
174
|
+
m.reply episode['message']
|
|
175
|
+
|
|
176
|
+
assonnato.user.logout
|
|
177
|
+
end
|
|
178
|
+
else
|
|
179
|
+
m.reply 'You are not recognized.'
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
def get_user(nickname)
|
|
184
|
+
file = File.join $options[:dotfiles], 'pigro.json'
|
|
185
|
+
|
|
186
|
+
if File.exists? file
|
|
187
|
+
users = JSON.parse File.read(file)
|
|
188
|
+
users.select { |user| user['nicknames'].first.values.include? nickname }.last
|
|
189
|
+
else
|
|
190
|
+
false
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
def get_host
|
|
195
|
+
file = File.join $options[:dotfiles], 'pigro.txt'
|
|
163
196
|
|
|
164
197
|
if File.exists? file
|
|
165
198
|
url = File.read(file).strip
|
|
166
199
|
return url unless url.empty?
|
|
167
|
-
end
|
|
200
|
+
end
|
|
168
201
|
|
|
169
|
-
'
|
|
202
|
+
'pigro.omnivium.it'
|
|
170
203
|
end
|
|
171
204
|
end
|
|
172
205
|
end
|
data/lib/descartes/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: descartes
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: '0.8'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Giovanni Capuano
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-03-
|
|
11
|
+
date: 2014-03-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: cinch
|
|
@@ -177,6 +177,7 @@ files:
|
|
|
177
177
|
- lib/descartes/modules/currency.rb
|
|
178
178
|
- lib/descartes/modules/dicteng.rb
|
|
179
179
|
- lib/descartes/modules/files/lastfm_api.yml
|
|
180
|
+
- lib/descartes/modules/files/pigro.json
|
|
180
181
|
- lib/descartes/modules/files/pigro.txt
|
|
181
182
|
- lib/descartes/modules/files/replies.txt
|
|
182
183
|
- lib/descartes/modules/files/sindaco.txt
|