tunecore-announcer 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/.idea/workspace.xml +58 -11
- data/Manifest.txt +1 -0
- data/bin/announcer +5 -1
- data/lib/tunecore-announcer.rb +2 -1
- data/lib/tunecore-announcer/command_dictionary.rb +22 -0
- data/lib/tunecore-announcer/xmpp_connection.rb +12 -11
- metadata +2 -1
- metadata.gz.sig +3 -2
data.tar.gz.sig
CHANGED
Binary file
|
data/.idea/workspace.xml
CHANGED
@@ -21,25 +21,43 @@
|
|
21
21
|
<file leaf-file-name="announcer" pinned="false" current="false" current-in-tab="false">
|
22
22
|
<entry file="file://$PROJECT_DIR$/bin/announcer">
|
23
23
|
<provider selected="true" editor-type-id="text-editor">
|
24
|
-
<state line="
|
24
|
+
<state line="69" column="71" selection-start="2011" selection-end="2011" vertical-scroll-proportion="0.0">
|
25
25
|
<folding />
|
26
26
|
</state>
|
27
27
|
</provider>
|
28
28
|
</entry>
|
29
29
|
</file>
|
30
|
-
<file leaf-file-name="tunecore-announcer.rb" pinned="false" current="
|
30
|
+
<file leaf-file-name="tunecore-announcer.rb" pinned="false" current="false" current-in-tab="false">
|
31
31
|
<entry file="file://$PROJECT_DIR$/lib/tunecore-announcer.rb">
|
32
32
|
<provider selected="true" editor-type-id="text-editor">
|
33
|
-
<state line="
|
33
|
+
<state line="14" column="0" selection-start="458" selection-end="458" vertical-scroll-proportion="0.0">
|
34
34
|
<folding />
|
35
35
|
</state>
|
36
36
|
</provider>
|
37
37
|
</entry>
|
38
38
|
</file>
|
39
|
-
<file leaf-file-name="
|
39
|
+
<file leaf-file-name="command_dictionary.rb" pinned="false" current="false" current-in-tab="false">
|
40
|
+
<entry file="file://$PROJECT_DIR$/lib/tunecore-announcer/command_dictionary.rb">
|
41
|
+
<provider selected="true" editor-type-id="text-editor">
|
42
|
+
<state line="0" column="71" selection-start="14" selection-end="14" vertical-scroll-proportion="0.0">
|
43
|
+
<folding />
|
44
|
+
</state>
|
45
|
+
</provider>
|
46
|
+
</entry>
|
47
|
+
</file>
|
48
|
+
<file leaf-file-name="xmpp_connection.rb" pinned="false" current="true" current-in-tab="true">
|
40
49
|
<entry file="file://$PROJECT_DIR$/lib/tunecore-announcer/xmpp_connection.rb">
|
41
50
|
<provider selected="true" editor-type-id="text-editor">
|
42
|
-
<state line="
|
51
|
+
<state line="37" column="6" selection-start="786" selection-end="786" vertical-scroll-proportion="0.23542601">
|
52
|
+
<folding />
|
53
|
+
</state>
|
54
|
+
</provider>
|
55
|
+
</entry>
|
56
|
+
</file>
|
57
|
+
<file leaf-file-name="example_dictionary.yml" pinned="false" current="false" current-in-tab="false">
|
58
|
+
<entry file="file://$PROJECT_DIR$/examples/example_dictionary.yml">
|
59
|
+
<provider selected="true" editor-type-id="text-editor">
|
60
|
+
<state line="4" column="34" selection-start="68" selection-end="68" vertical-scroll-proportion="0.0">
|
43
61
|
<folding />
|
44
62
|
</state>
|
45
63
|
</provider>
|
@@ -130,6 +148,20 @@
|
|
130
148
|
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
131
149
|
</PATH_ELEMENT>
|
132
150
|
</PATH>
|
151
|
+
<PATH>
|
152
|
+
<PATH_ELEMENT>
|
153
|
+
<option name="myItemId" value="tunecore-announcer" />
|
154
|
+
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
|
155
|
+
</PATH_ELEMENT>
|
156
|
+
<PATH_ELEMENT>
|
157
|
+
<option name="myItemId" value="tunecore-announcer" />
|
158
|
+
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
159
|
+
</PATH_ELEMENT>
|
160
|
+
<PATH_ELEMENT>
|
161
|
+
<option name="myItemId" value="examples" />
|
162
|
+
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
163
|
+
</PATH_ELEMENT>
|
164
|
+
</PATH>
|
133
165
|
<PATH>
|
134
166
|
<PATH_ELEMENT>
|
135
167
|
<option name="myItemId" value="tunecore-announcer" />
|
@@ -164,6 +196,7 @@
|
|
164
196
|
</navigator>
|
165
197
|
</component>
|
166
198
|
<component name="PropertiesComponent">
|
199
|
+
<property name="GoToClass.includeJavaFiles" value="false" />
|
167
200
|
<property name="options.splitter.details.proportions" value="0.2" />
|
168
201
|
<property name="options.splitter.main.proportions" value="0.3" />
|
169
202
|
<property name="options.searchVisible" value="true" />
|
@@ -270,7 +303,7 @@
|
|
270
303
|
</todo-panel>
|
271
304
|
</component>
|
272
305
|
<component name="ToolWindowManager">
|
273
|
-
<frame x="-
|
306
|
+
<frame x="-1872" y="199" width="1524" height="1043" extended-state="0" />
|
274
307
|
<editor active="true" />
|
275
308
|
<layout>
|
276
309
|
<window_info id="Web Preview" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="4" side_tool="false" />
|
@@ -352,23 +385,37 @@
|
|
352
385
|
</state>
|
353
386
|
</provider>
|
354
387
|
</entry>
|
355
|
-
<entry file="file://$PROJECT_DIR$/
|
388
|
+
<entry file="file://$PROJECT_DIR$/examples/example_dictionary.yml">
|
356
389
|
<provider selected="true" editor-type-id="text-editor">
|
357
|
-
<state line="
|
390
|
+
<state line="4" column="34" selection-start="68" selection-end="68" vertical-scroll-proportion="0.0">
|
391
|
+
<folding />
|
392
|
+
</state>
|
393
|
+
</provider>
|
394
|
+
</entry>
|
395
|
+
<entry file="file://$PROJECT_DIR$/lib/tunecore-announcer.rb">
|
396
|
+
<provider selected="true" editor-type-id="text-editor">
|
397
|
+
<state line="14" column="0" selection-start="458" selection-end="458" vertical-scroll-proportion="0.0">
|
398
|
+
<folding />
|
399
|
+
</state>
|
400
|
+
</provider>
|
401
|
+
</entry>
|
402
|
+
<entry file="file://$PROJECT_DIR$/lib/tunecore-announcer/command_dictionary.rb">
|
403
|
+
<provider selected="true" editor-type-id="text-editor">
|
404
|
+
<state line="0" column="71" selection-start="14" selection-end="14" vertical-scroll-proportion="0.0">
|
358
405
|
<folding />
|
359
406
|
</state>
|
360
407
|
</provider>
|
361
408
|
</entry>
|
362
409
|
<entry file="file://$PROJECT_DIR$/bin/announcer">
|
363
410
|
<provider selected="true" editor-type-id="text-editor">
|
364
|
-
<state line="
|
411
|
+
<state line="69" column="71" selection-start="2011" selection-end="2011" vertical-scroll-proportion="0.0">
|
365
412
|
<folding />
|
366
413
|
</state>
|
367
414
|
</provider>
|
368
415
|
</entry>
|
369
|
-
<entry file="file://$PROJECT_DIR$/lib/tunecore-announcer.rb">
|
416
|
+
<entry file="file://$PROJECT_DIR$/lib/tunecore-announcer/xmpp_connection.rb">
|
370
417
|
<provider selected="true" editor-type-id="text-editor">
|
371
|
-
<state line="
|
418
|
+
<state line="37" column="6" selection-start="786" selection-end="786" vertical-scroll-proportion="0.23542601">
|
372
419
|
<folding />
|
373
420
|
</state>
|
374
421
|
</provider>
|
data/Manifest.txt
CHANGED
data/bin/announcer
CHANGED
@@ -5,7 +5,7 @@ class AnnouncerLauncher
|
|
5
5
|
|
6
6
|
def self.parse_options(args)
|
7
7
|
|
8
|
-
mandatory_opts = %w(name_prefix jabber_server jabber_password admin_jids)
|
8
|
+
mandatory_opts = %w(name_prefix jabber_server jabber_password admin_jids dictionary_file)
|
9
9
|
|
10
10
|
options = OpenStruct.new
|
11
11
|
options.jabber_port = 5222
|
@@ -32,6 +32,10 @@ class AnnouncerLauncher
|
|
32
32
|
options.admin_jids = admin_jids
|
33
33
|
end
|
34
34
|
|
35
|
+
opts.on("-d", "--dictionary=DICTIONARY_FILE", "A YAML file containing definitions for the commands you want to accept via Jabber") do |dictionary_file|
|
36
|
+
options.dictionary_file = dictionary_file
|
37
|
+
end
|
38
|
+
|
35
39
|
opts.separator ""
|
36
40
|
opts.separator "Optional arguments:"
|
37
41
|
|
data/lib/tunecore-announcer.rb
CHANGED
@@ -2,7 +2,7 @@ $:.unshift(File.dirname(__FILE__)) unless
|
|
2
2
|
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
3
|
|
4
4
|
module TunecoreAnnouncer
|
5
|
-
VERSION = '0.0
|
5
|
+
VERSION = '0.1.0'
|
6
6
|
|
7
7
|
require "optparse"
|
8
8
|
require 'ostruct'
|
@@ -11,4 +11,5 @@ module TunecoreAnnouncer
|
|
11
11
|
require 'tunecore-announcer/utils'
|
12
12
|
require 'tunecore-announcer/logger'
|
13
13
|
require 'tunecore-announcer/xmpp_connection'
|
14
|
+
require 'tunecore-announcer/command_dictionary'
|
14
15
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
class TunecoreAnnouncer::CommandDictionary
|
4
|
+
|
5
|
+
attr_reader :dictionary
|
6
|
+
|
7
|
+
def initialize(yaml_filename)
|
8
|
+
@logger = TunecoreAnnouncer::Logger.instance
|
9
|
+
load_dictionary(yaml_filename)
|
10
|
+
end
|
11
|
+
|
12
|
+
def load_dictionary(yaml_filename)
|
13
|
+
@logger.info "Loading command dictionary: #{yaml_filename}"
|
14
|
+
@dictionary = YAML.load_file(yaml_filename)
|
15
|
+
@logger.debug @dictionary.inspect
|
16
|
+
end
|
17
|
+
|
18
|
+
def lookup(message)
|
19
|
+
@dictionary[message]
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -23,6 +23,7 @@ class TunecoreAnnouncer::XmppConnection
|
|
23
23
|
|
24
24
|
register
|
25
25
|
@logger.info "Connected to XMPP server"
|
26
|
+
load_dictionary
|
26
27
|
#@jabber.add(admin_jids)
|
27
28
|
add_admins
|
28
29
|
#@logger.debug "Added #{admin_jid} to roster"
|
@@ -34,7 +35,7 @@ class TunecoreAnnouncer::XmppConnection
|
|
34
35
|
|
35
36
|
|
36
37
|
def disconnect
|
37
|
-
admins "Shutting down ... Sayonara!"
|
38
|
+
#admins "Shutting down ... Sayonara!"
|
38
39
|
deregister
|
39
40
|
@jabber.disconnect
|
40
41
|
@listener_thread.join
|
@@ -69,6 +70,10 @@ private
|
|
69
70
|
end
|
70
71
|
end
|
71
72
|
|
73
|
+
def load_dictionary
|
74
|
+
@dictionary = TunecoreAnnouncer::CommandDictionary.new(@options.dictionary_file)
|
75
|
+
end
|
76
|
+
|
72
77
|
def deregister
|
73
78
|
@logger.debug "Removing registration"
|
74
79
|
client = @jabber.client
|
@@ -92,16 +97,12 @@ private
|
|
92
97
|
|
93
98
|
def process_incoming(message)
|
94
99
|
@logger.debug "Jabber msg from #{message.from}: #{message.body}"
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
@jabber.deliver(message.from, `hostname`)
|
102
|
-
else
|
103
|
-
@jabber.deliver(message.from, "Sorry, I don't know #{message.body}")
|
104
|
-
end
|
100
|
+
command = @dictionary.lookup(message.body)
|
101
|
+
@jabber.deliver(message.from, "I don't know #{message.body}") and return if command.nil?
|
102
|
+
@logger.debug "Running command: #{command}"
|
103
|
+
output = `#{command}`
|
104
|
+
@logger.debug "Replying with #{output}"
|
105
|
+
@jabber.deliver(message.from, output)
|
105
106
|
end
|
106
107
|
|
107
108
|
def set_vcard
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tunecore-announcer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Kane
|
@@ -81,6 +81,7 @@ files:
|
|
81
81
|
- Rakefile
|
82
82
|
- bin/announcer
|
83
83
|
- lib/tunecore-announcer.rb
|
84
|
+
- lib/tunecore-announcer/command_dictionary.rb
|
84
85
|
- lib/tunecore-announcer/logger.rb
|
85
86
|
- lib/tunecore-announcer/utils.rb
|
86
87
|
- lib/tunecore-announcer/xmpp_connection.rb
|
metadata.gz.sig
CHANGED
@@ -1,2 +1,3 @@
|
|
1
|
-
��
|
2
|
-
|
1
|
+
��0�$J�M-�w��o���
|
2
|
+
j�Wb����M�d�.n[~2mN?J��a+Y��/$B寧kƯ�- �hPu
|
3
|
+
ů����.h�q�Z�k"��x��=��>u�3ڿ#DO�W���5Ǝk��P^X��0�QDzQ��I���*g9�߂���
|