Bonjour,

J'ai un soucis avec mon Bot Perl qui se connecte au serveur IRC, et que ne répond à aucune commande en salon comme en privé.
Ex: Si je fais la commande !help pour avoir le Menu d'aide, je n'ai aucun retour.

Merci de préciser ce qu'il ne va pas dans le script Perl.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
 
 
#!/usr/local/bin/perl -w
# irc.pl
# A simple IRC robot.
# Usage: perl irc.pl
 
use strict;
use encoding "iso8859-1";
use Unicode::MapUTF8 qw(to_utf8 from_utf8 utf8_supported_charset);
 
#use ->   my $mess_  = to_utf8({ -string => $mess, -charset => 'iso8859-1' });
 
# We will use a raw socket to connect to the IRC server.
use IO::Socket;
use Time::HiRes qw{ setitimer tv_interval gettimeofday ITIMER_REAL };
use DBI();
 
# The server to connect to and our details.
my $sock; # socket handler
 
my $bot_nick   = "BotPerl";
 
my %mIRC = (
	    'bold'	=> "\cB",
	    'color'	=> "\cC",
	    'bell'	=> "\cG",
	    'reset'	=> "\cO",
	    'italic'	=> "\cT",
	    'reverse'	=> "\cV",
	    'underline' => "\c_",
	    'white'     => "\cC0",
	    'black'	=> "\cC1",
	    'blue'	=> "\cC2",
	    'green'	=> "\cC3",
	    'red'	=> "\cC4",
	    'brown'	=> "\cC5",
	    'purple'	=> "\cC6",
	    'orange'	=> "\cC7",
	    'yellow'	=> "\cC8",
	    'lt green'	=> "\cC9",
	    'cyan'	=> "\cC10",
	    'lt cyan'	=> "\cC11",
	    'lt blue'	=> "\cC12",
	    'pink'	=> "\cC13",
	    'grey'	=> "\cC14",
	    'lt grey'	=> "\cC15"
);
 
 
# --------------------------------------------------------------------------- #
 
my $input_nick;		# le pseudo de la personne
my $input_host;		# l'host de la personne
my $input_where;	# ou est ce que ca a été dis (salon ou query)
my $input_line;		# la ligne complete venant de l'utilisateur du bot
my $input_cmd;		# la commande !command
my $input_phrase;	# ce qu'il y a apres le nom de la commande (!cmd <phrase>)
my $output_where;       # where to send data
 
 
# --------------------------------------------------------------------------- #
 
use constant NOTHING                                       => 0;
use constant CHANSERV_CHECK_STAFF_AXX                      => 1;
use constant CHANSERV_CHECK_CHAN_AXX                       => 2;
 
my $notice_process_action	     = NOTHING;
my $chanserv_check_axx_chan	     = "";
my @chanserv_check_axx_chan_list = ();
 
# --------------------------------------------------------------------------- #
 
use constant TRUE            => 1;
use constant FALSE           => 0;
 
use constant EGAL            => 1;
use constant NOT_EGAL        => 0;
 
use constant RETURN_OK	     => 0;
use constant RETURN_KO	     => 1;
 
 
# --------------------------------------------------------------------------- #
use constant NO_LEVEL           => 0;
use constant LEVEL_TEST         => 10;
use constant LEVEL_GAMER        => 20;
use constant LEVEL_HELPER       => 30;
use constant LEVEL_ANIM         => 40;
use constant LEVEL_ANIMPLUS     => 45;
use constant LEVEL_OPZONE       => 50;
use constant LEVEL_ADMINZONE    => 55;
use constant LEVEL_COCHEF       => 60;
use constant LEVEL_CHANOP       => 65;
use constant LEVEL_CHEFZONE     => 70;
use constant LEVEL_ADMIN        => 80;
use constant LEVEL_PLOP         => 90;
 
 
###############################################################################
#				IRC STUFF				      #
###############################################################################
 
sub command() {
  my $mess = shift(@_);
  #$mess = to_utf8({ -string => $mess, -charset => 'iso8859-1' });
  print "< $mess\n";
  print $sock "$mess\r\n";
}
 
# --------------------------------------------------------------------------- #
 
sub msg() {
  my $target = shift(@_);
  my $mess   = shift(@_);
 
  &command("PRIVMSG $target $mess");
}
 
# --------------------------------------------------------------------------- #
 
sub notice() {
  my $target = shift(@_);
  my $mess   = shift(@_);
 
  &command("NOTICE $target $mess");
}
 
# --------------------------------------------------------------------------- #
 
sub msg_reply() {
  my $mess = shift(@_);
  &msg($output_where, $mess);
}
 
# --------------------------------------------------------------------------- #
 
sub notice_reply() {
  my $mess = shift(@_);
  &notice($input_nick, $mess);
}
 
# --------------------------------------------------------------------------- #
 
sub reply () {
  my $mess = shift(@_);
  if ($output_where =~ /\#/) { &msg ($output_where, $mess); }
  else                       { &msg ($input_nick, $mess);   }
}
 
# --------------------------------------------------------------------------- #
 
sub pv_reply () {
  my $mess = shift(@_);
  &msg ($input_nick, $mess);
}
 
# --------------------------------------------------------------------------- #
# The server to connect to and our details.
my $server = "irc.***.org";
my $nick = "BotPer";
my $login = "BotPer";
my $bot_pass = "Pass";
 
# The channel which the bot will join.
my $channel = "#***";
 
 
# Connect to the IRC server.
  $sock = new IO::Socket::INET(PeerAddr => $server,
			       PeerPort => 6667,
			       Proto => 'tcp') or die "Can't connect\n";
 
 
# Log on to the server.
print $sock "NICK $nick\r\n";
print $sock "USER $login 8 * :22 M Madrid\r\n";
 
# Read lines from the server until it tells us we have connected.
while (my $input = <$sock>) {
   # Check the numerical responses from the server.
    if ($input =~ /004/) {
      # We are now logged in.
      last;
    }
    elsif ($input =~ /433/) {
      die "Nickname is already in use.";
    }
  }
 
  &msg ("NickServ", "identify $bot_pass");
  &command ("oper BotPer Pass");
  &msg ("OperServ", "set superadmin on");
  &msg ("HostServ", "on");
# fin de connect ()
# --------------------------------------------------------------------------- #
 
sub join_all() {
  # Join all official channels.
  # &command("nm sajoff");
  &command ("SAJOIN $bot_nick #bureau");
  &command ("SAJOIN $bot_nick #services");
  &command ("SAJOIN $bot_nick #staff");
  &command ("SAJOIN $bot_nick #formation");
  &command ("SAJOIN $bot_nick #staff+"); 
  &command ("SAJOIN $bot_nick #control"); 
 
}
&join_all();
# Join the channel.
print $sock "JOIN $channel\r\n";
 
# Keep reading lines from the server.
while (my $input = <$sock>) {
    chop $input;
    if ($input =~ /^PING(.*)$/i) {
        # We must respond to PINGs to avoid being disconnected.
        print $sock "PONG $1\r\n";
    }
    else {
      my %function = (
	"privmsg"  => \&process_privmsg,
	"notice"   => \&process_notice,
	"join"     => \&process_join,
	"quit"     => \&process_quit,
	"nick"     => \&process_nick
      );
 
      # Print the raw line received by the bot.
      print "> $input\n";
      $_ = $input;
      m/^:[^ ]+ ([^ ]+) /;
      my $input_irc_cmd = $1;
      if (exists $function{ $input_irc_cmd }) {
	&{ $function{ $input_irc_cmd } } ($input);
        # Print the raw line received by the bot.
        print "$input\n";
    }
}
}
 
# --------------------------------------------------------------------------- #
 
# key = cmd
# value = function, level
my %priv_function = (
    # -- ANIM ------------------------------------------------------------ #
    "hello"	   => { func	    => \&hello,
			level       => LEVEL_ANIM,
			in_priv     => 1,
			where_cond  => "(#bureau|#staff)"
		      },
    "demission"	   => { func	    => \&demission,
			level       => LEVEL_ANIM,
			in_priv     => 0,
			where_cond  => "#staff"
		      },
    "site"	   => { func	    => \&site,
			level       => LEVEL_ANIM,
			in_priv     => 1,
			where_cond  => "(#olympe|#staff|#control)"
		      },
    "help"	   => { func	    => \&help,
			level       => LEVEL_ANIM,
			in_priv     => 1,
			where_cond  => "(#olympe|#staff|#control)"
		      },
    "points"	   => { func	    => \&points,
			level       => LEVEL_ANIM,
			in_priv     => 1,
			where_cond  => "#staff"
		      },
    "vacances"	   => { func	    => \&vacances,
			level       => LEVEL_ANIM,
			in_priv     => 1,
			where_cond  => "(#staff|#control)"
		      },
    "retour"	   => { func	    => \&retour,
			level       => LEVEL_ANIM,
			in_priv     => 1,
			where_cond  => "#staff"
		      },
    "moi"	   => { func	    => \&moi,
			level       => LEVEL_ANIM,
			in_priv     => 1,
			where_cond  => "#staff"
		      },
    "message"	   => { func	    => \&message,
			level       => LEVEL_ANIM,
			in_priv     => 1,
			where_cond  => "(#staff|#control)"
		      },
    "news"	   => { func	    => \&update_stats_news,
			level       => LEVEL_ANIM,
			in_priv     => 0,
			where_cond  => "#staff"
		      },
    "staff"	   => { func	    => \&update_stats_staff,
			level       => LEVEL_ANIM,
			in_priv     => 0,
			where_cond  => "#staff"
		      },
    # -- OPLOCAL ----------------------------------------------------------- #
    "test"         => { func        => \&test,
			level       => LEVEL_ANIM,
			in_priv     => 1,
			where_cond  => "(#staff|#control)"
		      },
    # -- OPZONE ---------------------------------------------------------- #
 
    # -- ADMINZONE ---------------------------------------------------------- #
    "potentiels"   => { func	    => \&potentiels,
			level       => LEVEL_ADMINZONE,
			in_priv     => 1,
			where_cond  => "#control"
		      },
    "pot"          => { func	    => \&potentiels,
			level       => LEVEL_ADMINZONE,
			in_priv     => 1,
			where_cond  => "|#control"
		      },
    "badrecrues"   => { func	    => \&badrecrues,
			level       => LEVEL_ADMINZONE,
			in_priv     => 0,
			where_cond  => "#staff+"
		      },
    "bad"          => { func	    => \&badrecrues,
			level       => LEVEL_ADMINZONE,
			in_priv     => 0,
			where_cond  => "#staff+"
		      },
    "anims"	   => { func	    => \&anims,
			level       => LEVEL_ADMINZONE,
			in_priv     => 1,
			where_cond  => "#staff+"
		      },
    "joinme"	   => { func	    => \&joinme,
			level       => LEVEL_ADMINZONE,
			in_priv     => 1,
			where_cond  => "#staff+"
		      },
    "find"         => { func        => \&find,
			level	    => LEVEL_ADMINZONE,
			in_priv     => 1,
			where_cond  => "#staff+"
		      },
 
    # -- COCHEF ---------------------------------------------------------- #
 
    # -- CHANOP ---------------------------------------------------------- #
    "getcode"	   => { func	    => \&code,
			level       => LEVEL_CHANOP,
			in_priv     => 0,
			where_cond  => "#staff+"
		      },
    "say"	   => { func	    => \&say,
			level       => LEVEL_CHANOP,
			in_priv     => 1,
			where_cond  => "#staff+"
		      },
    "rsay"	   => { func	    => \&rsay,
			level       => LEVEL_CHANOP,
			in_priv     => 1,
			where_cond  => "#staff+"
		      },
    "salons"	   => { func	    => \&salons,
			level       => LEVEL_CHANOP,
			in_priv     => 1,
			where_cond  => "#staff+"
		      },
    "stats"        => { func        => \&stats,
			level	    => LEVEL_CHANOP,
			in_priv     => 1,
			where_cond  => "#staff+"
		      },
    "vote"	   => { func	    => \&vote,
			level       => LEVEL_CHANOP,
			in_priv     => 1,
			where_cond  => "#staff+"
		      },
    "blame"	   => { func	    => \&blame,
			level       => LEVEL_CHANOP,
			in_priv     => 0,
			where_cond  => "#staff+"
		      },
    "nkill"	   => { func	    => \&nkill,
			level       => LEVEL_CHANOP,
			in_priv     => 1,
			where_cond  => ".*"
		      },
    "ikill"	   => { func	    => \&ikill,
			level       => LEVEL_CHANOP,
			in_priv     => 1,
			where_cond  => ".*"
		      },
    "skill"	   => { func	    => \&skill,
			level       => LEVEL_CHANOP,
			in_priv     => 1,
			where_cond  => ".*"
		      },
    "sgline"	   => { func	    => \&sgline,
			level       => LEVEL_CHANOP,
			in_priv     => 1,
			where_cond  => ".*"
		      },
 
    # -- CHEFZONE ------------------------------------------------------- #
    "unblame"	   => { func	    => \&unblame,
			level       => LEVEL_CHEFZONE,
			in_priv     => 0,
			where_cond  => "#staff+"
		      },
    "bonus"	   => { func	    => \&bonus,
			level       => LEVEL_CHEFZONE,
			in_priv     => 0,
			where_cond  => "#staff+"
		      },
    "logs"	   => { func	    => \&logs,
			level       => LEVEL_CHEFZONE,
			in_priv     => 1,
			where_cond  => " "
		      },
    "check"	   => { func	    => \&check,
			level       => LEVEL_CHEFZONE,
			in_priv     => 1,
			where_cond  => "#staff+"
		      },
 
    "chan"      => { func        => \&chan,
      level       => LEVEL_CHEFZONE,
      in_priv     => 1,
      where_cond  => "#staff+"
          },
 
    # -- ADMIN ----------------------------------------------------------- #
    "recrut"       => { func        => \&recrut,
			level	    => LEVEL_ADMIN,
			in_priv     => 1,
			where_cond  => " "
		      },
    "sql"          => { func        => \&sql_query,
			level	    => LEVEL_ADMIN,
			in_priv     => 1,
			where_cond  =>"#staff+"
		      },
 
    # -- JOKE ------------------------------------------------------------ #
    "toi"	   => { func	    => \&toi,
			level       => LEVEL_ANIM,
			in_priv     => 1,
			where_cond  => "#staff"
		      },
    "lui"	   => { func	    => \&lui,
			level       => LEVEL_ANIM,
			in_priv     => 1,
			where_cond  => "#staff"
		      },
    "elle"	   => { func	    => \&elle,
			level       => LEVEL_ANIM,
			in_priv     => 1,
			where_cond  => "#staff"
		      },
    "vous"	   => { func	    => \&vous,
			level       => LEVEL_ANIM,
			in_priv     => 1,
			where_cond  => "#staff"
		      },
    "nous"	   => { func	    => \&nous,
			level       => LEVEL_ANIM,
			in_priv     => 1,
			where_cond  => "#staff"
		      },
    "ils"	   => { func	    => \&ils,
			level       => LEVEL_ANIM,
			in_priv     => 1,
			where_cond  => "#staff"
		      },
    "je"	   => { func	    => \&je,
			level       => LEVEL_ANIM,
			in_priv     => 1,
			where_cond  => "#staff"
		      },
    "tu"	   => { func	    => \&tu,
			level       => LEVEL_ANIM,
			in_priv     => 1,
			where_cond  => "#staff"
		      },
    "il"	   => { func	    => \&il,
			level       => LEVEL_ANIM,
			in_priv     => 1,
			where_cond  => "#staff"
		      }
 
);
 
sub process_privmsg() {
  my $input = shift(@_);
 
  $_ = $input;
  ($input_nick, $input_host, $input_where, $input_line) = m/:(.+?)\!.+?@(.+?) privmsg ([^:]+) :(.*)/;
 
  if ($input_where !~ /^$bot_nick$/i) {
    if ($input_line =~ /^ *\!([^ ]+) *(.*)$/) {
      $input_cmd    = $1;
      $input_phrase = $2;
      $output_where = $input_where;
      if (exists $priv_function{ $input_cmd }) {
	if (&get_level($input_host) >= $priv_function{ $input_cmd }->{ level }
	    && $input_where =~ /$priv_function{ $input_cmd }->{ where_cond }/i ) {
	  my $res = &{ $priv_function{$input_cmd}->{ func } };
	  if ($res >= 0) {
	    &logs_add($input_cmd.' '.$input_phrase, ($res == 0 ? 'good' : 'bad'));
	  }
	}
      }
    }
  } else { # in private
    if ($input_line =~ /^ *([^ ]+) *(.*)$/) {
      $input_cmd    = $1;
      $input_phrase = $2;
      $output_where = $input_nick;
      if (exists $priv_function{$input_cmd}) {
	if (&get_level($input_host) >= $priv_function{$input_cmd}->{level}
	    && $priv_function{$input_cmd}->{in_priv} == 1) {
	  my $res = &{ $priv_function{$input_cmd}->{func} };
	  &logs_add($input_cmd.' '.$input_phrase, ($res == 0 ? 'good' : 'bad'));
	}
      }
    }
  }
}
 
# --------------------------------------------------------------------------- #
 
sub process_notice() {
  my $input = shift(@_);
  return 0 if ($notice_process_action == NOTHING);
  return 0 if ($input =~ /^:[^@]+ /);
  $_ = $input;
  ($input_nick, $input_host, $input_where, $input_line) = m/^:(.+?)\!.+?@(.+?) notice ([^:]+) : *(.*) *$/;
  $input_phrase = $input_line;
 
  if ($notice_process_action == CHANSERV_CHECK_STAFF_AXX) {
    # :ChanServ!service@***.org NOTICE plop`PowerBook :  259     3  mo_ly
    if ($input_nick eq "chanserv") {
      if ($input_phrase =~ / *[0-9]+ +([0-9]+) +([^ ]+) */) {
	my $axx_level = $1;
	my $nick      = $2;
	return 0 if ($axx_level > 5);
 
	my $dbh = DBI->connect('DBI:mysql:database=Zetein:host=localhost', 'BotPerl', 'Pass');
	my $sth = $dbh->prepare ("SELECT `status` FROM `anims` WHERE `anim` = ?");
	$sth->execute ($nick);
 
	if ($sth->rows != 0) {
	  my @res = $sth->fetchrow_array();
	  my $anim_level =  3;
	  $anim_level    = 4 if (   &status_comp ($res[ 0 ],  &get_status_code ('animh')) == EGAL
			         || &status_comp ($res[ 0 ],  &get_status_code ('anim+')) == EGAL);
 
	  if ($axx_level != $anim_level) {
	    &msg_reply (&KO().'. '.&mIRC_anim($nick).' ->'
			.&mIRC_color('red', &mIRC_bold('incorrect'))
			.' (level on chan = '.&mIRC_level($axx_level)
			.' != in database = '.&mIRC_level(&get_status_txt ($res[ 0 ])).')');
	  }
	} else {
	  &msg ('#beta', &KO().'. '.&mIRC_anim($nick).' (axx '.&mIRC_level($axx_level)
		.&str(') est pas enregistré dans le bot :('));
	}
      } elsif ($input_phrase =~ /^ *fin.+?liste/) {
	&msg_reply (&OK().'. Verif des status sur '.&mIRC_salon ($chanserv_check_axx_chan).' terminé.');
	$notice_process_action   = NOTHING;
	$chanserv_check_axx_chan = "";
      }
    }
  } elsif ($notice_process_action == CHANSERV_CHECK_CHAN_AXX) {
    # :ChanServ!service@***.org NOTICE plop`PowerBook :  259     3  mo_ly
    if ($input_nick eq "chanserv") {
      if ($input_phrase =~ / *[0-9]+ +([0-9]+) +([^ ]+) */) {
	my $axx_level = $1;
	my $nick      = $2;
	return 0 if ($axx_level > 5);
 
	my $dbh = DBI->connect('DBI:mysql:database=Zetein:host=localhost', 'BotPerl', 'Pass');
	my $sth = $dbh->prepare ("SELECT `level` FROM `access` LEFT JOIN `anims` "
				 ." ON `access`.`anim_id` = `anims`.`anim_id` "
				 ." WHERE `anim` = ? AND `salon` = ?");
	$sth->execute ($nick, $chanserv_check_axx_chan);
 
	if ($sth->rows != 0) {
	  my @res = $sth->fetchrow_array();
 
	  if ($axx_level != $res[ 0 ]) {
	    &msg_reply (&KO().'. '.&mIRC_salon ($chanserv_check_axx_chan)
			.' / '.&mIRC_anim($nick)
			.' (level on chan = '.&mIRC_level ($axx_level)
			.' != in Zetein = '.&mIRC_level ($res[ 0 ]).')');
	  }
	} else {
	  &msg_reply ( &KO().'. '.&mIRC_salon ($chanserv_check_axx_chan)
		       .' / '.&mIRC_anim($nick).' ('.&mIRC_color('red', 'pas anim !').' - axx '.&mIRC_level($axx_level)
		       .') ');
	}
      } elsif ($input_phrase =~ /^ *fin.+?liste/) {
	&msg_reply (&OK().'. Verif de '.&mIRC_salon ($chanserv_check_axx_chan).' terminé.');
	if (scalar @chanserv_check_axx_chan_list == 0) {
	  $notice_process_action   = NOTHING;
	  $chanserv_check_axx_chan = "";
	} else {
	  $chanserv_check_axx_chan = pop @chanserv_check_axx_chan_list;
	  &msg ("chanserv", "access $chanserv_check_axx_chan list");
	}
      }
    }
  }
}
 
# --------------------------------------------------------------------------- #
 
sub check_nick () {
  my $nick = shift (@_);
 
  my $dbh = DBI->connect('DBI:mysql:database=Zetein:host=localhost', 'BotPerl', 'Pass');
  my $sth = $dbh->prepare ("SELECT `anim` FROM `anims` WHERE ? LIKE CONCAT(`anim`, '%')");
  $sth->execute ($nick);
 
  if ($sth->rows == 0) { 
    &command("kick #staff $nick Ton pseudo n'est pas conforme ! Un animateur doit garder un pseudo qui a la meme base que son pseudo d'origine.");
    &command("nm mmode -h $nick");
    &command("nm mmode -v $nick");
    &command("nm mmode -o $nick");
    &command("nm chghost $nick shame.on.you");
    &command("notice $nick Pour revenir sur #staff, il faut que tu prennes ton pseudo anim et que tu fasses /hs on. Ensuite, tu pourras revenir.");
    $sth->finish ();
    $dbh->disconnect ();
    return RETURN_OK;
  }
 
  $sth->finish ();
  $dbh->disconnect ();
  return RETURN_KO;
}
 
sub process_join () {
  my $input = shift (@_);
  $_ = $input;
  ($input_nick, $input_host, $input_where) = m/^:(.+?)\!.+?@(.+?) join :(.+)$/i;
  if (lc ($input_where) eq "#staff") {
    if ((lc ($input_host) eq 'animation.***.org' || lc ($input_host) eq 'animplus.***.org' || lc ($input_host) eq 'opzone.***.org') &&
	&check_nick ($input_nick) == RETURN_OK) {
      &retour (1);
      &update_stats_seen ();
    }
  }
}
 
# --------------------------------------------------------------------------- #
 
sub process_nick () {
  my $input = shift (@_);
  my $new_nick;
 
  $_ = $input;
  ($input_nick, $input_host, $new_nick) = m/^:(.+?)\!.+?@(.+?) nick :(.+)$/i;
 
  if (lc ($input_host) eq 'animation.***.org' || lc ($input_host) eq 'animplus.***.org' || lc ($input_host) eq 'opzone.***.org') {
    &check_nick ($new_nick);
  }
}
 
# --------------------------------------------------------------------------- #
 
sub process_quit () {
  my $input = shift (@_);
  $_ = $input;
  ($input_nick, $input_host, $input_where) = m/^:(.+?)\!.+?@(.+?) quit :(.+)$/i;
  if (lc ($input_where) eq "#staff") {
    &update_stats_seen ();
  }
}
 
###############################################################################
#			           Mics STUFF				      #
###############################################################################
 
sub say() {
  if ($input_phrase =~ /^(\#[^ ]+) !*(.*)$/) {
    my ($salon, $mess) = ($1, $2);
    $_ = $mess;
    # for security purpuse (injection of raw lines)
    s/\r//;
    s/\n//;
    s/^\!+//;
    $mess = $_;
    &msg($salon, $mess);
  }
}
 
# --------------------------------------------------------------------------- #
 
sub rsay() {
  if ($input_phrase =~ /^(\#[^ ]+) !*(.*)$/) {
    my ($salon, $mess) = ($1, $2);
    $_ = $mess;
    # for security purpuse (injection of raw lines)
    s/\r//;
    s/\n//;
    s/^\!+//;
    $mess = $_;
    &msg($salon, mIRC_boss($mess));
  }
}
 
# --------------------------------------------------------------------------- #
 
sub hello () {
  &reply ("prout");
  return 0;
}
 
###############################################################################
#			           HELP STUFF				      #
###############################################################################
 
sub help() {
  if    ($input_phrase =~ /^ *$/i	    && &get_level ($input_host) >= $priv_function{ 'help'       }->{ level }	)	{ &help_help();		}
  elsif ($input_phrase =~ /^site *$/i	    && &get_level ($input_host) >= $priv_function{ 'site'       }->{ level }	)	{ &site_liste();	}
  elsif ($input_phrase =~ /^potentiels *$/i && &get_level ($input_host) >= $priv_function{ 'potentiels' }->{ level }	)	{ &potentiels_help();	}
  elsif ($input_phrase =~ /^badrecrues *$/i && &get_level ($input_host) >= $priv_function{ 'badrecrues' }->{ level }	)	{ &badrecrues_help();	}
  elsif ($input_phrase =~ /^anims *$/i	    && &get_level ($input_host) >= $priv_function{ 'anims'      }->{ level }	)	{ &anims_help();	}
  elsif ($input_phrase =~ /^blame *$/i	    && &get_level ($input_host) >= $priv_function{ 'blame'      }->{ level }	)	{ &blame_help();	}
  elsif ($input_phrase =~ /^unblame *$/i    && &get_level ($input_host) >= $priv_function{ 'unblame'    }->{ level }	)	{ &unblame_help();	}
  elsif ($input_phrase =~ /^bonus *$/i	    && &get_level ($input_host) >= $priv_function{ 'bonus'      }->{ level }	)	{ &bonus_help();	}
  elsif ($input_phrase =~ /^logs *$/i	    && &get_level ($input_host) >= $priv_function{ 'logs'       }->{ level }	)	{ &logs_help();		}
  elsif ($input_phrase =~ /^joinme *$/i	    && &get_level ($input_host) >= $priv_function{ 'joinme'     }->{ level }	)	{ &joinme_help();	}
  elsif ($input_phrase =~ /^vacances *$/i   && &get_level ($input_host) >= $priv_function{ 'vacances'   }->{ level }	)	{ &vacances_help();	}
  elsif ($input_phrase =~ /^message *$/i    && &get_level ($input_host) >= $priv_function{ 'message'    }->{ level }	)	{ &message_help();	}
  elsif ($input_phrase =~ /^test *$/i	    && &get_level ($input_host) >= $priv_function{ 'test'       }->{ level }	)	{ &test_help();	        }
  elsif ($input_phrase =~ /^stats *$/i	    && &get_level ($input_host) >= $priv_function{ 'stats'      }->{ level }	)	{ &stats_help();	}
  elsif ($input_phrase =~ /^salons *$/i	    && &get_level ($input_host) >= $priv_function{ 'salons'     }->{ level }	)	{ &salons_help();	}
  elsif ($input_phrase =~ /^sgline *$/i	    && &get_level ($input_host) >= $priv_function{ 'sgline'     }->{ level }	)	{ &sgline_help();	}
  elsif ($input_phrase =~ /^skill *$/i	    && &get_level ($input_host) >= $priv_function{ 'skill'      }->{ level }	)	{ &skill_help();	}
  elsif ($input_phrase =~ /^nkill *$/i	    && &get_level ($input_host) >= $priv_function{ 'nkill'      }->{ level }	)	{ &nkill_help();	}
  elsif ($input_phrase =~ /^ikill *$/i	    && &get_level ($input_host) >= $priv_function{ 'ikill'      }->{ level }	)	{ &ikill_help();	}
  elsif ($input_phrase =~ /^chan *$/i	    && &get_level ($input_host) >= $priv_function{ 'chan'       }->{ level }	)	{ &chan_help();	}
  else { return -1; }
  return 0;
}
 
# --------------------------------------------------------------------------- #
 
sub help_help() {
  if (&get_level($input_host) >= LEVEL_ANIM) {
    &notice_reply ("-                                  Help                                    -");
    &notice_reply ("- Level min  - Commande    - Descriptions                                  -");
    &notice_reply ("(   anim    ) !help <cmd>  - Voir l'help d'une commande");
    &notice_reply ("(   anim    ) !points      - Voir mes points");
    &notice_reply ("(   anim    ) !moi         - Voir mes informations");
    &notice_reply ("(   anim    ) !vacances    - Dire que je suis en vacances");
    &notice_reply ("(   anim    ) !retour      - Dire que je suis de retour de vacances");
    &notice_reply ("(   anim    ) !site        - Pour voir les différents site mis à disposition");
    &notice_reply ("(   anim    ) !message     - Envoyer un message anonyme aux ChanOp / ChefZone");
  }
  if (&get_level($input_host) >= LEVEL_ANIMPLUS) {
    &notice_reply ("(  OpLocal  ) !test        - Pour proposer un anim en test");
  }
  if (&get_level($input_host) >= LEVEL_ADMINZONE) {
    &notice_reply ("(  AdminZone - CoChef ) !potentiels  - Proposition d'anims pour les salons");
    &notice_reply ("(  AdminZone - CoChef  ) !badrecrues  - Gestion des badrecrues");
    &notice_reply ("(  AdminZone - CoChef  ) !anims       - Gestion des anims");
    &notice_reply ("(  AdminZone - CoChef  ) !joinme      - Liste de sajoin personnalisée");
  }
  if (&get_level($input_host) >= LEVEL_CHANOP) {
    &notice_reply ("(  ChanOp   ) !blame       - Ajouter des blames");
    &notice_reply ("(  ChanOp   ) !getcode    - Voir le code de l'anim.");
  }
  if (&get_level($input_host) >= LEVEL_CHEFZONE) {
    &notice_reply ("(  ChanOp   ) !unblame     - Remettre des points");
    &notice_reply ("( ChefZone ) !bonus       - Ajout de points a tous les anims");
    &notice_reply ("( ChefZone ) !logs        - Consulter les logs du bot");
    &notice_reply ("( ChefZone ) !chan        - Ajouter / effacer / lister des salons officiels dans Zetein");
      }
  &notice_reply (&mIRC_bold ('Note').' : Vous pouvez faire toutes les commandes de la forme /ze <cmd>. Par ex, /ze help.');
  &notice_reply (&mIRC_bold ('Note').' : Vous pouvez avoir de l\'aide sur une commande en faisant /ze help <cmd>. Par ex, /ze help message.');
  return 0;
}
 
 
###############################################################################
#				  MAIN					      #
###############################################################################
 
 
# let's go
&process_messages();