Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Send private CB messages through XChat

by Beatnik (Parson)
on Apr 15, 2001 at 20:45 UTC ( #72672=CUFP: print w/replies, xml ) Need Help??

As a sequal on my previous CUFP, here's a way to reply to private messages... this chunk is ofcourse based on lhoward's node too... (no XML this time, sorry OeufMayo :) )
Update: Tweaked some Monestary related things... Thanks epoptai
#!/usr/bin/perl use LWP::UserAgent; use URI::URL; use HTTP::Cookies; IRC::register("Monk Messenger", "0.1", "", ""); IRC::print "\0035:: Loading Monk Messenger ::\003\n"; IRC::add_command_handler("msgmonk", "msg_monk"); sub msg_monk { my $message = @_[0]; $message = substr($message,0,255); ($user,$message) = split(/ /,$message,2); my $pm_user=''; # Monk alias my $pm_password=''; # Monk password my $WWWAgent = new LWP::UserAgent(); my $co=new HTTP::Cookies(file=>'./cookies.dat',autosave=>1,ignore_ +discard=>1); $WWWAgent->cookie_jar($co); my $url=new URI::URL ''; $url->query_form(op => "login",node_id => "16046",user => $pm_user +,passwd => $pm_password,expires=> "+10y"); my $WWWRequest = new HTTP::Request 'GET', $url->as_string() ; my $WWWResult = $WWWAgent->request($WWWRequest); die "Error logging in $WWWResult->code $WWWResult->message" if(!$W +WWResult->is_success); $url=new URI::URL ''; $url->query_form(op => 'message',node=>"16046", message=>"/msg $us +er $message"); $WWWRequest = new HTTP::Request 'GET', $url->as_string() ; $WWWResult = $WWWAgent->request($WWWRequest); die "Can't load Monk Messanger $WWWResult->code $WWWResult->messag +e" if(!$WWWResult->is_success); IRC::print "you said $message to $user\n"; 1; }
You can put this in your .xchat directory to get automatically loaded on startup...
How this works : /msgmonk <monk> <message> ,like in CB... (Something like "/msgmonk Beatnik hey dude your code sucks" will ofcourse work :-|)

... Quidquid perl dictum sit, altum viditur.

Replies are listed 'Best First'.
Re: Send private CB messages through XChat
by epoptai (Curate) on Apr 16, 2001 at 08:49 UTC
    Neat idea. A few FYIs:

    Requests to perlmonks can be made faster by asking for very small nodes. It's not necessary to use node 109 for login or homenode for /msg (or lastnode_id at all). If a node isn't supplied The Monastery Gates comes back (ouch). The smallest nodes at perlmonks are some empty XML nodes but I usually use the tiny XML xp nodelet at node_id=16046 since it'll probably be there in the future.

    If you have a saved cookie file login can be skipped, but either needs to use ignore_discard on the cookies:

    $co=new HTTP::Cookies(file=>'./cookie',autosave=>1,ignore_discard=>1);
    or set an expires param in the login query:
    $url->query_form( op => "login", node_id => "16046", expires=> "+10y" user => $pm_user, passwd => $pm_password );
    Also, the size limit on /msg is 255 bytes, so $message needs to be counted and truncated before the print to reflect overflow.
      Thanks, I tweaked it :)

      ... Quidquid perl dictum sit, altum viditur.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: CUFP [id://72672]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2020-10-26 13:19 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (251 votes). Check out past polls.