bot improved
This commit is contained in:
		
							parent
							
								
									8f9405e245
								
							
						
					
					
						commit
						f51ed5b2fc
					
				
					 1 changed files with 26 additions and 1 deletions
				
			
		| 
						 | 
					@ -6,6 +6,8 @@ use AnyEvent::IRC::Client;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
my $c = AnyEvent->condvar;
 | 
					my $c = AnyEvent->condvar;
 | 
				
			||||||
my $cl = AnyEvent::IRC::Client->new;
 | 
					my $cl = AnyEvent::IRC::Client->new;
 | 
				
			||||||
 | 
					my $timer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$cl->reg_cb (connect => sub {
 | 
					$cl->reg_cb (connect => sub {
 | 
				
			||||||
		my ($con, $err) = @_;
 | 
							my ($con, $err) = @_;
 | 
				
			||||||
		if (defined $err) {
 | 
							if (defined $err) {
 | 
				
			||||||
| 
						 | 
					@ -13,8 +15,31 @@ $cl->reg_cb (connect => sub {
 | 
				
			||||||
			return;
 | 
								return;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					$cl->reg_cb (registered => sub { say "I'm in!"; });
 | 
				
			||||||
 | 
					$cl->reg_cb (disconnect => sub { say "I'm out!";  $c->broadcast });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					$cl->reg_cb (
 | 
				
			||||||
 | 
						sent => sub {
 | 
				
			||||||
 | 
							my ($con) = @_;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if ($_[2] eq 'PRIVMSG') {
 | 
				
			||||||
 | 
								print "Sent message!\n";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								$timer = AnyEvent->timer (
 | 
				
			||||||
 | 
									after => 1,
 | 
				
			||||||
 | 
									cb => sub {
 | 
				
			||||||
 | 
										undef $timer;
 | 
				
			||||||
 | 
										say "on est dans cb";
 | 
				
			||||||
 | 
										$con->disconnect ('done')
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$cl->connect ('irc.geeknode.org', 6667, { nick => '[bot]kanette' });
 | 
					$cl->connect ('irc.geeknode.org', 6667, { nick => '[bot]kanette' });
 | 
				
			||||||
$cl->send_srv ( PRIVMSG => 'karchnu', 'Hi there!');
 | 
					$cl->send_srv ( PRIVMSG => 'karchnu', 'Bot enabled : woot');
 | 
				
			||||||
$c->wait;
 | 
					$c->wait;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$cl->disconnect;
 | 
					$cl->disconnect;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue