remi-aim 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/lib/aim.rb +19 -6
- data/lib/aim/net_toc.rb +6 -0
- metadata +2 -2
data/VERSION.yml
CHANGED
data/lib/aim.rb
CHANGED
@@ -18,7 +18,7 @@ class AIM
|
|
18
18
|
#
|
19
19
|
# log_chatroom :some_chatroom, :output => 'some_chatroom.log'
|
20
20
|
#
|
21
|
-
# when :
|
21
|
+
# when :im do |im|
|
22
22
|
# im_user im.user, "thanks for the IM, #{ im.user.name }"
|
23
23
|
# end
|
24
24
|
#
|
@@ -33,11 +33,19 @@ class AIM
|
|
33
33
|
# this auto logs in too
|
34
34
|
#
|
35
35
|
def login_as_user username, password, &block
|
36
|
-
|
37
|
-
user
|
38
|
-
user.
|
39
|
-
|
40
|
-
user
|
36
|
+
@block = block if block
|
37
|
+
@user = get_user username, password
|
38
|
+
@user.login!
|
39
|
+
|
40
|
+
reload! # take the @user, clear all of the user's event subscriptions, and reload the block
|
41
|
+
|
42
|
+
@user.wait!
|
43
|
+
@user
|
44
|
+
end
|
45
|
+
|
46
|
+
def reload!
|
47
|
+
@user.clear_events!
|
48
|
+
@user.instance_eval &@block
|
41
49
|
end
|
42
50
|
|
43
51
|
# returns an AIM::User, but does not login
|
@@ -59,6 +67,11 @@ class AIM
|
|
59
67
|
connection.connect
|
60
68
|
end
|
61
69
|
|
70
|
+
# undoes all event subscriptions
|
71
|
+
def clear_events!
|
72
|
+
connection.clear_callbacks!
|
73
|
+
end
|
74
|
+
|
62
75
|
# do something on an event
|
63
76
|
#
|
64
77
|
# user.when :im do |message, buddy|
|
data/lib/aim/net_toc.rb
CHANGED
@@ -531,7 +531,9 @@ module Net
|
|
531
531
|
puts "chat_in val => #{ val.inspect }"
|
532
532
|
room_id, screen_name, auto, *message = *val.split(":")
|
533
533
|
message = message.join(":")
|
534
|
+
message = message.gsub('<br>',"\n") # ... before getting rid of html
|
534
535
|
message = message.chomp.gsub(/<[^>]+>/,"") # get rid of html
|
536
|
+
message = message.gsub("\n",'<br />') # ... turn newlines back into br's
|
535
537
|
buddy = @buddy_list.buddy_named(screen_name)
|
536
538
|
room = @rooms[room_id] || room_id
|
537
539
|
auto_response = auto == "T"
|
@@ -567,6 +569,10 @@ module Net
|
|
567
569
|
def idle_time=(seconds)
|
568
570
|
@conn.toc_set_idle seconds
|
569
571
|
end
|
572
|
+
|
573
|
+
def clear_callbacks!
|
574
|
+
@callbacks = { }
|
575
|
+
end
|
570
576
|
|
571
577
|
# Waits for the event-handling thread for +limit+ seconds, or indefinitely if no argument is given. Use this to prevent your program from exiting prematurely.
|
572
578
|
# For example, the following script will exit right after connecting:
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: remi-aim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- remi
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-02-
|
12
|
+
date: 2009-02-24 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|