xmppbot 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +2 -0
- data/README.rdoc +45 -40
- data/Rakefile +2 -2
- data/Rakefile.save +29 -0
- data/Rakefile.save.1 +29 -0
- data/lib/xmppbot/bot.rb +0 -1
- data/lib/xmppbot/message.rb +5 -1
- data/lib/xmppbot/presence.rb +1 -1
- metadata +6 -4
data/Manifest.txt
CHANGED
data/README.rdoc
CHANGED
@@ -2,73 +2,78 @@
|
|
2
2
|
|
3
3
|
== DESCRIPTION:
|
4
4
|
|
5
|
-
|
6
|
-
It's for those who want to build
|
5
|
+
This is a simple implementation on top of StropheRuby 'http://github.com/flamontagne/strophe_ruby/'.
|
6
|
+
It's for those who want to build xmpp bots quickly. It features only the essential :
|
7
7
|
- auto accept subscriptions
|
8
8
|
- callback for received messages
|
9
9
|
- callback for received presences
|
10
10
|
- a method to send messages and presences
|
11
11
|
- That's it
|
12
12
|
|
13
|
-
Warning : StropheRuby is
|
13
|
+
Warning : StropheRuby is quite experimental at the moment. It is definitely NOT ready for production!
|
14
14
|
|
15
15
|
== FEATURES/PROBLEMS:
|
16
16
|
|
17
|
-
- Only tested under Debian
|
18
|
-
-
|
19
|
-
|
17
|
+
- Only tested under Debian so far
|
18
|
+
- Does not work under windows
|
19
|
+
- No TLS support for now. It will work once TLS with OpenSSL is working in Strophe 'http://code.stanziq.com/strophe'
|
20
|
+
- Exiting the program can cause segmentation errors (not really problematic)
|
20
21
|
|
21
22
|
== SYNOPSIS:
|
22
23
|
|
23
|
-
How to use it :
|
24
|
-
|
25
24
|
require 'xmppbot'
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
|
26
|
+
class Johnny5 < XMPPBot::Bot
|
27
|
+
def connect
|
28
|
+
super do |status|
|
29
|
+
if status == XMPPBot::ConnectionEvents::CONNECT
|
30
|
+
announce_presence
|
31
|
+
register_callbacks
|
32
|
+
else
|
33
|
+
disconnect
|
34
|
+
end
|
35
|
+
end
|
29
36
|
end
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
else
|
35
|
-
stanza=XMPPBot::Message.new
|
36
|
-
stanza.to=msg.from
|
37
|
-
stanza.body="You said : #{msg.body}"
|
38
|
-
@bot.send(stanza)
|
37
|
+
|
38
|
+
def register_callbacks
|
39
|
+
on_presence_received do |pres|
|
40
|
+
puts "#{pres.from} is now #{pres.to_s}" unless pres.to_s.strip == ""
|
39
41
|
end
|
42
|
+
|
43
|
+
on_message_received do |msg|
|
44
|
+
if msg.body == "exit"
|
45
|
+
disconnect
|
46
|
+
else
|
47
|
+
stanza=XMPPBot::Message.new
|
48
|
+
stanza.to=msg.from
|
49
|
+
stanza.body="You said : #{msg.body}"
|
50
|
+
send(stanza)
|
51
|
+
end
|
52
|
+
end
|
40
53
|
end
|
41
54
|
end
|
42
55
|
|
43
|
-
|
44
|
-
@bot=
|
45
|
-
@bot.
|
46
|
-
@bot.
|
47
|
-
@bot.log_level = XMPPBot::Logging::DEBUG
|
56
|
+
@bot = Johnny5.new
|
57
|
+
@bot.jid = "cripes@jaim.at"
|
58
|
+
@bot.password = "cripes"
|
59
|
+
@bot.log_level = XMPPBot::Logging::INFO
|
48
60
|
@bot.auto_accept_subscriptions = true
|
49
61
|
|
50
|
-
@bot.connect
|
51
|
-
if status == XMPPBot::ConnectionEvents::CONNECT
|
52
|
-
@bot.announce_presence
|
53
|
-
register_callbacks
|
54
|
-
else
|
55
|
-
@bot.disconnect
|
56
|
-
end
|
57
|
-
end
|
62
|
+
@bot.connect
|
58
63
|
|
59
|
-
|
64
|
+
#We pause the execution of the current thread to prevent the program from exiting
|
65
|
+
Thread.stop
|
60
66
|
|
61
|
-
|
67
|
+
#Once the parsing thread exits, execution resumes here
|
68
|
+
puts "Connection terminated"
|
62
69
|
|
63
70
|
== INSTALL:
|
64
71
|
|
65
|
-
|
72
|
+
gem install xmppbot (it will install stropheruby as well)
|
66
73
|
|
67
74
|
== LICENSE:
|
68
75
|
|
69
|
-
(
|
70
|
-
|
71
|
-
Copyright (c) 2008 FIXME full name
|
76
|
+
Copyright (c) 2008 François Lamontagne
|
72
77
|
|
73
78
|
Permission is hereby granted, free of charge, to any person obtaining
|
74
79
|
a copy of this software and associated documentation files (the
|
@@ -87,4 +92,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
87
92
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
88
93
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
89
94
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
90
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
95
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
CHANGED
@@ -3,10 +3,10 @@
|
|
3
3
|
|
4
4
|
# Generate all the Rake tasks
|
5
5
|
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
6
|
-
$hoe = Hoe.new('xmppbot', '0.0.
|
6
|
+
$hoe = Hoe.new('xmppbot', '0.0.2') do |p|
|
7
7
|
p.developer('François Lamontagne', 'flamontagne@gmail.com')
|
8
8
|
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
9
|
-
p.post_install_message =
|
9
|
+
# p.post_install_message = File.open(File.dirname(__FILE__) + "/PostInstall.txt").read
|
10
10
|
p.rubyforge_name = p.name # TODO this is default value
|
11
11
|
p.extra_deps = [
|
12
12
|
['strophe_ruby','>= 0.0.1'],
|
data/Rakefile.save
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
%w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
|
2
|
+
#require File.dirname(__FILE__) + '/lib/xmppbot'
|
3
|
+
|
4
|
+
# Generate all the Rake tasks
|
5
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
6
|
+
$hoe = Hoe.new('xmppbot', '0.0.1') do |p|
|
7
|
+
p.developer('François Lamontagne', 'flamontagne@gmail.com')
|
8
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
9
|
+
p.post_install_message = 'PostInstall.txt' # TODO remove if
|
10
|
+
post-install message not required
|
11
|
+
p.rubyforge_name = p.name # TODO this is default value
|
12
|
+
p.extra_deps = [
|
13
|
+
['strophe_ruby','>= 0.0.1'],
|
14
|
+
]
|
15
|
+
p.extra_dev_deps = [
|
16
|
+
['newgem', ">= #{::Newgem::VERSION}"]
|
17
|
+
]
|
18
|
+
|
19
|
+
p.clean_globs |= %w[**/.DS_Store tmp *.log]
|
20
|
+
path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
|
21
|
+
p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
|
22
|
+
p.rsync_args = '-av --delete --ignore-errors'
|
23
|
+
end
|
24
|
+
|
25
|
+
require 'newgem/tasks' # load /tasks/*.rake
|
26
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
27
|
+
|
28
|
+
# TODO - want other tests/tasks run by default? Add them to the list
|
29
|
+
# task :default => [:spec, :features]
|
data/Rakefile.save.1
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
%w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
|
2
|
+
#require File.dirname(__FILE__) + '/lib/xmppbot'
|
3
|
+
|
4
|
+
# Generate all the Rake tasks
|
5
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
6
|
+
$hoe = Hoe.new('xmppbot', '0.0.1') do |p|
|
7
|
+
p.developer('François Lamontagne', 'flamontagne@gmail.com')
|
8
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
9
|
+
p.post_install_message =
|
10
|
+
# TODO remove if post-install message not required
|
11
|
+
p.rubyforge_name = p.name # TODO this is default value
|
12
|
+
p.extra_deps = [
|
13
|
+
['strophe_ruby','>= 0.0.1'],
|
14
|
+
]
|
15
|
+
p.extra_dev_deps = [
|
16
|
+
['newgem', ">= #{::Newgem::VERSION}"]
|
17
|
+
]
|
18
|
+
|
19
|
+
p.clean_globs |= %w[**/.DS_Store tmp *.log]
|
20
|
+
path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
|
21
|
+
p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
|
22
|
+
p.rsync_args = '-av --delete --ignore-errors'
|
23
|
+
end
|
24
|
+
|
25
|
+
require 'newgem/tasks' # load /tasks/*.rake
|
26
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
27
|
+
|
28
|
+
# TODO - want other tests/tasks run by default? Add them to the list
|
29
|
+
# task :default => [:spec, :features]
|
data/lib/xmppbot/bot.rb
CHANGED
data/lib/xmppbot/message.rb
CHANGED
@@ -39,7 +39,11 @@ module XMPPBot
|
|
39
39
|
|
40
40
|
def body=(str)
|
41
41
|
children = self.stanza.children
|
42
|
-
|
42
|
+
|
43
|
+
#Strangely enough, sending a "<" character to our stream will terminate it.
|
44
|
+
#I guess expat (the xml parser) should take care of encoding the
|
45
|
+
#special characters to ensure that the xml remains valid... but it doesn't do it.
|
46
|
+
str.gsub!(/[<>]/) {|s| s == "<" ? '<' : '>'}
|
43
47
|
if children
|
44
48
|
children.children.text = str
|
45
49
|
else
|
data/lib/xmppbot/presence.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xmppbot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Fran\xC3\xA7ois Lamontagne"
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: 1.8.0
|
44
44
|
version:
|
45
|
-
description: "
|
45
|
+
description: "This is a simple implementation on top of StropheRuby 'http://github.com/flamontagne/strophe_ruby/'. It's for those who want to build xmpp bots quickly. It features only the essential : - auto accept subscriptions - callback for received messages - callback for received presences - a method to send messages and presences - That's it Warning : StropheRuby is quite experimental at the moment. It is definitely NOT ready for production!"
|
46
46
|
email:
|
47
47
|
- flamontagne@gmail.com
|
48
48
|
executables: []
|
@@ -60,6 +60,8 @@ files:
|
|
60
60
|
- PostInstall.txt
|
61
61
|
- README.rdoc
|
62
62
|
- Rakefile
|
63
|
+
- Rakefile.save
|
64
|
+
- Rakefile.save.1
|
63
65
|
- lib/xmppbot.rb
|
64
66
|
- lib/xmppbot/bot.rb
|
65
67
|
- lib/xmppbot/message.rb
|
@@ -72,7 +74,7 @@ files:
|
|
72
74
|
- test/test_xmppbot.rb
|
73
75
|
has_rdoc: true
|
74
76
|
homepage:
|
75
|
-
post_install_message:
|
77
|
+
post_install_message:
|
76
78
|
rdoc_options:
|
77
79
|
- --main
|
78
80
|
- README.rdoc
|
@@ -96,7 +98,7 @@ rubyforge_project: xmppbot
|
|
96
98
|
rubygems_version: 1.3.1
|
97
99
|
signing_key:
|
98
100
|
specification_version: 2
|
99
|
-
summary:
|
101
|
+
summary: This is a simple implementation on top of StropheRuby 'http://github.com/flamontagne/strophe_ruby/'
|
100
102
|
test_files:
|
101
103
|
- test/test_helper.rb
|
102
104
|
- test/test_xmppbot.rb
|