Class: AIM

Inherits:
Object
  • Object
show all
Defined in:
lib/aim.rb

Overview

Easily connect to AIM!

Defined Under Namespace

Classes: User

Class Method Summary collapse

Class Method Details

.get_user(username, password) ⇒ Object

returns an AIM::User, but does not login



52
53
54
# File 'lib/aim.rb', line 52

def get_user username, password
  AIM::User.new username, password
end

.login_as_user(username, password, &block) ⇒ Object

AIM.login_as_user( ‘username’, ‘password’ ) do

im_user :bob, 'hello bob!'

log_chatroom :some_chatroom, :output => 'some_chatroom.log'

when :im do |im|
  im_user im.user, "thanks for the IM, #{ im.user.name }"
end

end

when a block is passed, we’ll call everything passed in on the AIM::User created by #login_as_user, and we’ll user.wait!

without a block, we just return the AIM::User and you have to manually call user.wait! (which actually just waits)

this auto logs in too



35
36
37
38
39
40
41
42
43
44
# File 'lib/aim.rb', line 35

def  username, password, &block
  @block = block if block
  @user = get_user username, password
  @user.login!

  reload! # take the @user, clear all of the user's event subscriptions, and reload the block
  
  @user.wait!
  @user
end

.reload!Object



46
47
48
49
# File 'lib/aim.rb', line 46

def reload!
  @user.clear_events!
  @user.instance_eval &@block
end