CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
Net::IRC

 



Rivotti
User

Jul 3, 2001, 7:07 AM

Post #1 of 9 (2180 views)
Net::IRC Can't Post

Hi,

I´m doing a script that acces a channel on irc an acts like a bot. I want that the bot exits when a write a command. I can do this in the channel but I want to do it in a private window. Is this possible?

thanks in advance
Rivotti



abstracts
Novice

Jul 10, 2001, 10:39 AM

Post #2 of 9 (2166 views)
Re: Net::IRC [In reply to] Can't Post

Hello,

From the Net::IRC::Event manpage:

o public
The "public" event is triggered upon receipt of a
PRIVMSG message to an entire channel, which means that
someone on a channel with the client has said some-
thing aloud.

o msg
The "msg" event is triggered upon receipt of a PRIVMSG
message which is addressed to one or more clients,
which means that someone is sending the client a pri-
vate message. (Duh. :-)


So, all you need is add a handler to the msg event.

Code
$conn->add_handler('msg', \&on_msg); 
sub on_msg{
my ($self, $event) = @_;
my $line = $event->args();
$self->quit("Leaving, yes sir") if $line eq 'quit password';
}

Hope this helps,

Aziz,,,




Rivotti
User

Jul 10, 2001, 11:01 AM

Post #3 of 9 (2162 views)
Re: Net::IRC [In reply to] Can't Post

Hi Aziz,

Tanks but that I already know. I didn't explain right...
I know the event msg, what I was trying do to was this...

$conn->privmsg($nick, $message);

I was doing

$conn->privmsg($chan, $message);

that would sent a message to the channel not to the nick in pvt.

Thanks anyway
Rivotti

André Rivotti Casimiro
Web Designer/Programmer
CONTIFAX.COM
http://www.contifax.com


abstracts
Novice

Jul 10, 2001, 2:00 PM

Post #4 of 9 (2157 views)
Re: Net::IRC [In reply to] Can't Post

Hello again,

In IRC (according to the specs), there is only one command for sending a message: PRIVMSG. The client sends PRIVMSG, followed by a list of recipients, followed by a colon ":", followed by the message terminated by a CR, LF, or CRLF. The way the server knows whether it's a private message or a channel message is by the "#" sign as you know. #perl is a channel, so doing

Code
$conn->privmsg("#perl", "Hello all");

would send the message to the channel perl which

Code
$conn->privmsg("abstracts", "Hello Aziz");

would send a private message to the user with nick abstracts.

So, the command is the same whether it's for a private message or a channel message.

Did I answer your question?

Hope this helps,,,

Aziz,,,



Rivotti
User

Jul 11, 2001, 1:55 AM

Post #5 of 9 (2149 views)
Re: Net::IRC [In reply to] Can't Post

Hi....

It's seems that we are talking the same thing. I already knew about the diference of sending a message do the channel or to the nick. My explaining was a bit messy. Whem I posted the first note, I didn't Knew that.... anyway a thank you.

There's other things that you could help me:

when a use the notice event I using:

$conn->notice( $nick, $message);

I expected that it would work as the privmsg event. When I use this line whit privmsg it send the message to $nick in pvt. With the notice event the message apear's only to $nick but in the channel window.

Another thing... when using Mirc I can execute the command /echo. How can I do that with Net::IRC?

Thanks Aziz...
Rivotti


André Rivotti Casimiro
Web Designer/Programmer
CONTIFAX.COM
http://www.contifax.com


abstracts
Novice

Jul 11, 2001, 5:08 AM

Post #6 of 9 (2147 views)
Re: Net::IRC [In reply to] Can't Post

Hello again,
The place where a message is shown depends on the client implementations. mIRC shows all private messages in a window and channel messages in their respective windows. Other clients (ircII, BitchX, ...) have no windows at all so all messages come to the terminal. I believe mIRC sends notices to the active window (the window with the focus). There is nothing you can do from Net::IRC to force your notice to go a specific window on the other side.

So, notice will send a notice to the other user, you cannot force it to do anything else.

Aziz,,,




abstracts
Novice

Jul 11, 2001, 5:10 AM

Post #7 of 9 (2147 views)
Re: Net::IRC [In reply to] Can't Post

About the echo, in mIRC, echo just echos the text to the screen. I guess you just use perl's print for that.

Aziz,,,



Rivotti
User

Jul 17, 2001, 3:58 PM

Post #8 of 9 (2134 views)
Re: Net::IRC [In reply to] Can't Post

Hi Aziz,

thanks for the reply. By the way, do you know how to wait for some action for about 30 secs without stopping de program?
Example: I must give a answer in 30 seconds but I want the script to execute any handler action in the process. In the end of the 30 seconds the script will do something.

Thanks in Advance
Rivotti


André Rivotti Casimiro
Web Designer/Programmer
CONTIFAX.COM
http://www.contifax.com


abstracts
Novice

Jul 17, 2001, 4:55 PM

Post #9 of 9 (2131 views)
Re: Net::IRC [In reply to] Can't Post

Hello again,,,

To do your task, I believe you need to fork a child that sleeps for 30 seconds before dying. In the main program you'll get a signal on child's termination, and that's where "you'll do something".

Hope this helps,,,

Aziz,,,


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives