rumpy 0.9.8 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +7 -5
- data/lib/rumpy.rb +5 -1
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -28,7 +28,9 @@ Our goal is 'DO NOT REINVENT THE WHEEL'.
|
|
28
28
|
@config_path :: Path to directory, containing all ruby config files
|
29
29
|
@main_model :: Symbol, that stands for main model. If your main model is, e.g. User, set @main_model to :user
|
30
30
|
@pid_file :: Optional variable, sets location of the file to which pid of detached process will be saved. If not set, it equals NameOfYourBotClass.downcase + '.pid'.
|
31
|
-
@
|
31
|
+
@err_file :: Optional variable, sets location of the file for errors. If not set, standard error stream will be used.
|
32
|
+
@bot_name :: Optional name of the bot. If not set, it will equal the name of bot's class.
|
33
|
+
@bot_version :: Optional version of the bot. If not set, it will equal 1.0.0.
|
32
34
|
* Write 3 methods:
|
33
35
|
backend_func() -> [[receiver, message]*] :: This optional method is running all the time in the loop. Returns array of pairs [receiver, message].
|
34
36
|
parser_func(msg) -> pars_result :: This method parses any incoming message and returs results.
|
@@ -37,10 +39,10 @@ Our goal is 'DO NOT REINVENT THE WHEEL'.
|
|
37
39
|
You can run your bot without detaching:
|
38
40
|
Rumpy.run YourBotClassName
|
39
41
|
Or with detaching:
|
40
|
-
To start your bot:
|
41
|
-
|
42
|
-
To stop it:
|
43
|
-
|
42
|
+
#To start your bot:
|
43
|
+
Rumpy.start YourBotClassName
|
44
|
+
#To stop it:
|
45
|
+
Rumpy.stop YourBotClassName
|
44
46
|
|
45
47
|
== Example
|
46
48
|
|
data/lib/rumpy.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'xmpp4r/client'
|
3
3
|
require 'xmpp4r/roster'
|
4
|
+
require 'xmpp4r/version'
|
4
5
|
require 'active_record'
|
5
6
|
require 'active_record/validations'
|
6
7
|
|
@@ -62,7 +63,8 @@ module Rumpy
|
|
62
63
|
clear_users
|
63
64
|
start_subscription_callback
|
64
65
|
start_message_callback
|
65
|
-
@client.send Jabber::Presence.new
|
66
|
+
@client.send Jabber::Presence.new.set_priority(@priority).set_status(@status)
|
67
|
+
Jabber::Version::SimpleResponder.new(@client, @bot_name || self.class.to_s, @bot_version || '1.0.0', RUBY_PLATFORM)
|
66
68
|
Thread.new do
|
67
69
|
begin
|
68
70
|
loop do
|
@@ -85,6 +87,8 @@ module Rumpy
|
|
85
87
|
xmppconfig = YAML::load_file @config_path + '/xmpp.yml'
|
86
88
|
@lang = YAML::load_file @config_path + '/lang.yml'
|
87
89
|
@jid = Jabber::JID.new xmppconfig['jid']
|
90
|
+
@priority = xmppconfig['priority']
|
91
|
+
@status = xmppconfig['status']
|
88
92
|
@password = xmppconfig['password']
|
89
93
|
@client = Jabber::Client.new @jid
|
90
94
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rumpy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 41
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 9
|
10
|
+
version: 0.9.9
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tsokurov A.G.
|