RE: A bit help with your module

12 views
Skip to first unread message

todd.e....@jpmorgan.com

unread,
Jan 9, 2008, 1:30:03 PM1/9/08
to yago....@gmail.com, perl-net-...@googlegroups.com

Thanks,

This has been added to the project to be fixed. We want to get testing working without use of a server and then we’ll proceed to correct this.

 

http://code.google..com/p/perl-net-jabber-bot/

 

 

 


From: Yago Jesus [mailto:yago....@gmail.com]
Sent: Tuesday, December 04, 2007 4:56 AM
To: Todd E Rinaldo
Subject: Re: A bit help with your module

 

Here are the subrutine InitJabber modified:

---------

sub InitJabber : PRIVATE {
    my $self = shift;
    my $obj_ID = $self->_get_obj_id() or return;

    DEBUG("new client object.");
    my $connection = new Net::Jabber::Client();
    $jabber_client{$obj_ID} = $connection;

    DEBUG("Set the call backs.");

    $connection->PresenceDB(); # Init presence DB.
    $connection->SetCallBacks( 'message'  => $self->callback_maker(\&ProcessJabberMessage)
                              ,'presence' => $self->callback_maker(\&JabberPresenceMessage)
                              ,'iq'       => $self->callback_maker(\&InIQ)
                              );

    DEBUG("Connect. hostname => $connection_hash{$obj_ID}{'server'} , port => $connection_hash{$obj_ID}{'port'}");
    my $status = $connection->Connect(hostname=>$connection_hash{$obj_ID}{'server'} , port=>$connection_hash{$obj_ID}{'port'}, connectiontype =>'tcpip', tls => '1', componentname => ' gmail.com');

    if(!defined $status) {
    print "ERROR:  Jabber server is down or connection was not allowed: $!\n";
    return;
    }

    print "Logging in... as user $connection_hash{$obj_ID}{'username'}/$connection_hash{$obj_ID}{'alias'}\n";
   
    my $sid = $connection->{SESSION}->{id};
    $connection->{STREAM}->{SIDS}->{$sid}->{hostname} = 'gmail.com';
   
    my @auth_result = $connection->AuthSend(username=>$connection_hash{$obj_ID}{'username'},
                                            password=>$connection_hash{$obj_ID}{'password'},
                                            resource=>$connection_hash{$obj_ID}{'alias'});

    if(!defined $auth_result[0] || $auth_result[0] ne "ok") {
    print "ERROR: Authorization failed:\n";
    foreach my $result (@auth_result) {
        print "$result\n";
    }
    return;
    }

    $connection_session_id{$obj_ID} = $connection->{SESSION}->{id};

    DEBUG("Sending presence to tell world that we are logged in");
    $connection->PresenceSend();
    $self->Process(5);

    DEBUG("Getting Roster to tell server to send presence info");
    $connection->RosterGet();
    $self->Process(5);

    foreach my $forum (keys %{$forums_and_responses{$obj_ID}}) {
        $self->JoinForum($forum);
    }

    $client_start_time{$obj_ID} = time; # Track when we came online.
    return 1;
}

-----

Note that, when you log in Gtalk, you must use 'nick' instead ni...@gmail.com as login.

Also, I would suggest to include in the example's section of cpan's page "$bot->Start();" to clarified how to run the bot.

Best regards

2007/12/3, todd.e....@jpmorgan.com <todd.e....@jpmorgan.com >:

Feel free to send it along.

 


From: Yago Jesus [mailto:yago....@gmail.com]
Sent: Monday, December 03, 2007 11:57 AM
To: Todd E Rinaldo
Subject: Re: A bit help with your module

 

Very thanks for your response.

I have modified (a bit) your bot.pm to work in Gtalk service (the problem is about SSL) If you want it, please tell me.

2007/12/3, todd.e....@jpmorgan.com <todd.e....@jpmorgan.com>:

Hi,

 

Sorry, there are no good examples yet. Our Houston.pm group will be working on this in January, so the documentation should get a lot better. Right now, all you should need to provide is

  1. connect information,
  2. what groups to join
  3. What subroutine to call when a new message comes in.
  4. What subroutine to call periodically to do checks, etc.

 

# Init Log4Perl

use Log::Log4perl qw(:easy); # See docs if you want to get debug output from the bot object.

use Net::Jabber::Bot;

 

my $bot = Net::Jabber::Bot->new({

                                 server => 'server_here'

                                , conference_server => 'conference_server'

                                , port => 'port'

                                , username => 'username'

                                , password => 'password'

                                , alias => $alias

                                , message_callback => \&new_bot_message   # Called if new messages arrive.

                                , background_activity => \&background_checks # What the bot does outside jabber.

                                , loop_sleep_time => $config_file_hash{'bot'}{'background_check_frequency'} # Minimum time before doing background function.

                                , process_timeout => $config_file_hash{'bot'}{'jabber_timeout'} # Time to wait for new jabber messages before doing background stuff

                                , forums_and_responses => \%forums_and_responses

                                , ignore_server_messages => $config_file_hash{'bot'}{'ignore_server_messages'}

                                , ignore_self_messages => $config_file_hash{'bot'}{'ignore_self_messages'}

                                                , out_messages_per_second => $config_file_hash{'JPMIM'}{'messages_per_second'}

                                , max_message_size => $max_message_size

                                , max_messages_per_hour => $max_messages_per_hour

                            });

 

sub new_bot_message {

    my %bot_message_hash = @_;

    my $bot_object   = $bot_message_hash{bot_object};

    my $reply_to     = $bot_message_hash{reply_to};

    my $message_type = $bot_message_hash{type};

}

 

sub background_checks {

 ; #do something here

}

 


From: Yago Jesus [mailto: yago....@gmail.com]
Sent: Monday, December 03, 2007 6:01 AM
To: Todd E Rinaldo
Subject: A bit help with your module

 

Hi, Im triying to implement a jabber-bot with your module, I have read the documentation but I wonder if there are some example-bot yet implemented to make more easy the beggining


This communication is for informational purposes only. It is not intended as an offer or solicitation for the purchase or sale of any financial instrument or as an official confirmation of any transaction. All market prices, data and other information are not warranted as to completeness or accuracy and are subject to change without notice. Any comments or statements made herein do not necessarily reflect those of JPMorgan Chase & Co., its subsidiaries and affiliates. This transmission may contain information that is privileged, confidential, legally privileged, and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. Although this transmission and any attachments are believed to be free of any virus or other defect that might affect any computer system into which it is received and opened, it is the responsibility of the recipient to ensure that it is virus free and no responsibility is accepted by JPMorgan Chase & Co., its subsidiaries and affiliates, as applicable, for any loss or damage arising in any way from its use. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. Please refer to http://www.jpmorgan.com/pages/disclosures for disclosures relating to UK legal entities.

 


This communication is for informational purposes only. It is not intended as an offer or solicitation for the purchase or sale of any financial instrument or as an official confirmation of any transaction. All market prices, data and other information are not warranted as to completeness or accuracy and are subject to change without notice. Any comments or statements made herein do not necessarily reflect those of JPMorgan Chase & Co., its subsidiaries and affiliates. This transmission may contain information that is privileged, confidential, legally privileged, and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. Although this transmission and any attachments are believed to be free of any virus or other defect that might affect any computer system into which it is received and opened, it is the responsibility of the recipient to ensure that it is virus free and no responsibility is accepted by JPMorgan Chase & Co., its subsidiaries and affiliates, as applicable, for any loss or damage arising in any way from its use. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. Please refer to http://www.jpmorgan.com/pages/disclosures for disclosures relating to UK legal entities.

 


Generally, this communication is for informational purposes only and it is not intended as an offer or solicitation for the purchase or sale of any financial instrument or as an official confirmation of any transaction. In the event you are receiving the offering materials attached below related to your interest in hedge funds or private equity, this communication may be intended as an offer or solicitation for the purchase or sale of such fund(s). All market prices, data and other information are not warranted as to completeness or accuracy and are subject to change without notice. Any comments or statements made herein do not necessarily reflect those of JPMorgan Chase & Co., its subsidiaries and affiliates. This transmission may contain information that is privileged, confidential, legally privileged, and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. Although this transmission and any attachments are believed to be free of any virus or other defect that might affect any computer system into which it is received and opened, it is the responsibility of the recipient to ensure that it is virus free and no responsibility is accepted by JPMorgan Chase & Co., its subsidiaries and affiliates, as applicable, for any loss or damage arising in any way from its use. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. Please refer to http://www.jpmorgan.com/pages/disclosures for disclosures relating to UK legal entities.

Reply all
Reply to author
Forward
0 new messages