Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
No such thing as a small change
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
    0: #!/usr/bin/perl -w
    1: 
    2: use Net::IRC;
    3: use strict;
    4: 
    5: my $irc = new Net::IRC;
    6: 
    7: my $conn = $irc->newconn(	
    8: 
    9: 	Server 		=> shift || 'irc.azzurra.org',		
    10: 	Port		=> shift || '6667', 	
    11: 	Nick		=> 'Iper_',	
    12: 	Ircname		=> 'Only an IRC roBOT',	
    13: 	Username	=> 'Mr. Iper');
    14: 	$conn->{channel} = shift || '#prova' or die "Error: connection refused\n";
    15: 
    16: 
    17: my @sentences = (
    18: 
    19: "Grembiule nero e fiocco azzurro: per un bambino milanista il 1^ giorno di scuola è un trauma!",
    20: "Sai cos'è che odio nel primo giorno di scuola? Che è troppo lontano dall'ultimo!",
    21: "Ho l'orologio che va avanti di 3 ore, ma non sono mai riuscito ad aggiustarlo. Così da New York mi sono trasferito a Los Angeles!",
    22: "Se la conoscenza non viene messa in azione è peggio dell'ignoranza...",
    23: "Il significato di un uomo non va ricercato in ciò che egli raggiunge, ma in ciò che vorrebbe raggiungere.",
    24: "Possiamo essere grandi solo quanto le nostre occasioni.",
    25: "Carpe diem!",
    26: "I giovani cercano l'impossibile e , generazione dopo generazione, lo conseguono.",
    27: "Quando il gioco si fa duro, i duri entrano in gioco.",
    28: "Ci sono due modi per uscire da questo edificio, il primo e' passando per il tetto usando il pontile, il secondo e' in stato di arresto ... corri comunque un rischio sta a te decidere",
    29: "Ti ho mostrato la soglia, ora tocca a te attraversarla...",
    30: "What God taxi driver! - Che Dio t'assista!",
    31: "I tre anni più duri per Totti? Quelli della prima elementare!",
    32: "Totti: la fidanzata gli ha regalato un libro. Lui lo apre e legge: <<Sommario... Piacere, so' Francesco!>>.",
    33: "L'unico modo per non far conoscere agli altri i propri limiti, è di non oltrepassarli mai.",
    34: "Niente è impossibile: l'impossibile è solo poco più difficile del possibile...",
    35: "E' ricercando l'impossibile che l'uomo ha sempre realizzato il possibile. Coloro che si sono saggiamente limitati a cio' che appariva loro come possibile, non hanno mai avanzato di un solo passo. - Michail Bakunin (1814 - 1876)",
    36: "But make me the pleasure! - Ma fammi il piacere!",
    37: "But of what! - Ma di che!",
    38: "I'm tired dead! - Sono stanco morto!",
    39: "L'eterno mistero del mondo è la sua comprensibilità",
    40: "Cogito ergo sum",
    41: "Ratio in medio stat",
    42: "Fatti non foste viver come bruti ma per seguir virtute e canoscenza",
    43: "How many people can read hex if only you and dead people can read it?",
    44: "There are only 10 types of peole in the world, those who understand binary and those who don't",
    45: "If one fights me than he will become zero, I am the only one in a croud of zeroes. - AndreaGeddon (9000 (sta troppo avanti!) - +infinito (ed oltre!) )",
    46: 
    47: );
    48: 
    49: 
    50: sub on_connect {
    51: 
    52: 	my $conn = shift;
    53: 	$conn->join($conn->{channel});
    54: 	$conn->privmsg($conn->{channel}, "Ladies and gentlemen, giulia_1 is here!");
    55: 	$conn->{connected} = 1;
    56: }
    57: 
    58: sub on_join {
    59: 
    60: 	my ($conn, $event) = @_;
    61: 	my $nick = $event->{nick};
    62: 	if($nick ne 'Iper_') {($conn->privmsg($conn->{channel}, "Hi, $nick!"));}
    63: }	
    64: 
    65: sub on_invite {
    66: 
    67: 	my ($conn, $event) = @_;
    68: 	my $nick = $event->{nick};
    69: 	$conn->privmsg($nick, "$nick, tnx for inviting me on your chan but now I'm very busy. See you later.");
    70: }
    71: 
    72: sub on_part {
    73: 
    74: 	my ($conn, $event) = @_;
    75: 	my $nick = $event->{nick};
    76: 	$conn->privmsg($conn->{channel}, "Bye, $nick!");
    77: }
    78: 
    79:    
    80: 
    81: sub on_ping {
    82: 
    83:     my ($conn, $event) = @_;
    84:     my $nick = $event->nick;
    85:     $conn->ctcp_reply($nick, join (' ', ($event->args)));
    86:     print "*** CTCP PING request from $nick received\n";
    87: }
    88: 
    89: sub on_version {
    90: 
    91:     my ($conn, $event) = @_;
    92:     my $nick = $event->nick;
    93:     my $reply = "VERSION Binary os, Binary client, Athlon xp +infinite";
    94:     $conn->ctcp_reply($nick, $reply);
    95:     print "*** CTCP VERSION request from $nick received\n";
    96: }
    97: 
    98: sub on_source {
    99: 
    100:     my ($conn, $event) = @_;
    101:     my $nick = $event->nick;
    102:     my $reply = "SOURCE ./query giulia_1 (or giulia_0 if she's away) or type !source";
    103:     $conn->ctcp_reply($nick, $reply);
    104:     print "*** CTCP SOURCE request from $nick received\n";
    105: }
    106: 
    107: sub on_dcc {
    108: 
    109:     my ($conn, $event) = @_;
    110:     my $nick = $event->nick;
    111:     my $reply = "DCC no dcc, tnx";
    112:     $conn->ctcp_reply($nick, $reply);
    113:     $conn->privmsg($nick, "Hi $nick, I'm sorry but my client doesn't support dcc.");
    114:     print "*** CTCP DCC request from $nick received\n";
    115: }
    116: 
    117: sub on_msg {
    118: 
    119: 	my ($conn, $event) = @_;
    120:         my $nick = $event->nick;
    121:         my $text = $event->{args}[0];
    122: 
    123:  	if ($text =~ /^\!(.+)$/) {
    124: 
    125:         if ($text =~ "source") {
    126:         $conn->privmsg($nick, "$nick, I'm sending to you my source code ");
    127:         $conn->schedule(10, \&Net::IRC::Connection::new_send, $nick, "iper.pl");
    128:         print "*** Iper's source has been requested by $nick \n";}
    129: 
    130:         if ($text =~ "hi"){
    131:         $conn->privmsg($nick, "Hi, $nick!");}
    132: 
    133:         if ($text =~ "quote"){
    134:         $conn->privmsg($nick, &rand());}
    135:       
    136:         if ($text =~ "about"){
    137:         $conn->privmsg($nick, "Internet Perl Eccentric Robot, a Giulia's project ==> Mr. Iper r0x! published on perlmonks.org");}
    138: 
    139:         if ($text =~ "help") {
    140: 
    141:         $conn->privmsg($nick, "My commands are: !hi, !quote, !about !source, !zena (on msg) or !quote, !go_out and !source (on public). I also say <<Hi, nick!>> or <<Bye, nick!>> (on join & on part), I reply to ping, version, source, dcc and invite. If the language  used is bad I say <<Nick, moderate the language plese>> and before exiting I says <<Bye...>> to the channel ...I'm a great bot :)");}
    142: 
    143:         if ($text =~ "zena") {
    144: 
    145:         $conn->privmsg($conn->{channel}, chr(3)."12,4FORZA".chr(3)."4,12GENOA"); }
    146: 
    147:                               }        
    148: 
    149:         else {
    150: 
    151:         $conn->privmsg($event->{nick}, "Don't anybody /msg IperBot in this way, contact giulia_1 for more informations or type !help for the  commands' list");
    152: 
    153:             }
    154: 
    155: }
    156: 
    157: sub on_public {
    158: 
    159: 	my ($conn, $event) = @_;
    160:         my $nick = $event->nick;
    161:         my $text = $event->{args}[0];
    162:         my ($arg) = ($event->args);
    163: 
    164:  	if ($text =~ /^\!(.+)$/) {
    165: 
    166:         if ($text =~ "source") {
    167:         $conn->privmsg($nick, "$nick, I'm sending to you my source code ");
    168:         $conn->schedule(10, \&Net::IRC::Connection::new_send, $nick, "iper.pl");
    169:         print "*** Iper's source has been requested by $nick \n";}
    170: 
    171:         if ($text =~ "go_out") {
    172: 	$conn->privmsg($conn->{channel}, "Ok, $nick, I'm only a bot");
    173: 	$conn->quit("Quitted by $nick");
    174: 	exit 0;}
    175: 
    176:         if ($text =~ "quote"){
    177:         $conn->privmsg($conn->{channel}, &rand());}
    178: 
    179:                              }
    180: 
    181:         if ($arg =~ /azz/i){
    182: 	
    183:         $conn->privmsg($conn->{channel}, "$nick, moderate the language please!");
    184: 
    185:         }
    186: 
    187:    
    188:               }
    189: 
    190: sub on_leaving {
    191: 
    192: 	my ($conn, $event) = @_;
    193: 	$conn->privmsg($conn->{channel}, "Bye all! => RETN => C3 => 11000011");
    194: }        
    195: 
    196: sub rand {
    197: 
    198:        return $sentences[ rand scalar @sentences ];
    199: }
    200: 
    201: 
    202: $conn->add_handler('join', \&on_join);
    203: $conn->add_handler('invite', \&on_invite);
    204: $conn->add_handler('part', \&on_part);
    205: $conn->add_handler('cping', \&on_ping);
    206: $conn->add_handler('cversion', \&on_version);
    207: $conn->add_handler('csource', \&on_source);
    208: $conn->add_handler('cdcc', \&on_dcc);
    209: $conn->add_handler('msg',    \&on_msg);
    210: $conn->add_handler('public', \&on_public);
    211: $conn->add_handler('leaving', \&on_leaving);
    212: $conn->add_handler('376', \&on_connect);
    213: 
    214: $irc->start();
    215: 
    216: 
    217: # iper ==> Internet Perl Eccentric Robot coded by giulia_1\0 (giulia@olografix.org)
    

In reply to Iper ==> Internet Perl Eccentric Robot by giulia

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (10)
    As of 2014-04-19 01:16 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      April first is:







      Results (475 votes), past polls