Accueil > > > 1 BOT POUR L'IRC AVEC SOCKET!
1 BOT POUR L'IRC AVEC SOCKET!
Information sur la source
Description
Le code d'un bot que j'ai codé rapidement, j'ai pas commenté mais je suis sur que vous allez comprendre(code simple), et puis si vous avec un probleme contacter moi a ggreg4@laposte.net ou sur #php (irc: chat1.voila.fr Pseudo: PsY4). sinon ne marche pas sous des serveurs du style de multimania pour cause de fonction désactivé. J'en est refait une meilleur version, pour ceux que ca intéraisse mailler moi! http://xtrem.tuxfamily.org/rfc1459fr.html <- les Protocoles irc en francais (ils peuvent toujours servir O_o )!
Source
- <?
- set_time_limit(0);
- $serv="chat1.voila.fr";
- echo "connect to $serv...<br>";
- $fp=fsockopen("$serv","6667");
- echo "Ident...<br>";
- fputs($fp,"user PsY4 UNIX ggreg4@laposte.net PHP_BOT\n");
- $mennick="ev-a[PsY4_BoT_PhP]";
- fputs($fp,"nick $mennick\n");
- sleep(1);
-
- while($new=fgets($fp,1024)){
- $new = str_replace("\r", "", $new);
- $new = str_replace("\n", "", $new);
-
- // :ServBoT!p@boss PRIVMSG #php :.ds #kaya salut
- $tab_temp0=explode(":",$new);
- $msg_void=$tab_temp0[0]; //ping
- $msg_info=$tab_temp0[1]; //ServBoT!p@boss PRIVMSG #php
- $msg_user=$tab_temp0[2]; //.ds #kaya salut ca va
- $msg_void1=$tab_temp0[3]; //.ds #kaya salut ca va
-
-
- // .ds #kaya salut
- $tab_temp1=explode(" ",$msg_user);
- $msg_user_param0=$tab_temp1[0]; //.ds
- $msg_user_param1=$tab_temp1[1]; //#kaya
- $nbtt=count($tab_temp1);
- $nbtt--;
- for($i=2;$i<=$nbtt;$i++){
- $msg_user_param2.=$tab_temp1[$i]." "; //salut ca va
- }
-
- // ServBoT!p@boss PRIVMSG #php
- $tab_temp2=explode("!",$msg_info);
- $msg_info_nick=$tab_temp2[0]; //ServBoT
-
- // ServBoT!p@boss PRIVMSG #php
- $tab_temp3=explode(" ",$msg_info);
- $msg_info_host=$tab_temp3[0]; //ServBoT!p@boss
- $msg_info_type=$tab_temp3[1]; //PRIVMSG
- $msg_info_target=$tab_temp3[2]; //#php
-
- // ServBoT!p@boss PRIVMSG #php
- $tab_temp4=explode("!",$msg_info_host);
- $msg_info_host_auth=$tab_temp4[1]; //p@boss
-
-
- echo "$new <br>";
-
- if(eregi("PING",$tab_temp0[0])){
- fputs($fp,"PONG $serv\n");
- echo "<font color=red>PING? PONG!</font><br>";
- }
- //Si le pseudo exsiste deja
- if($msg_info_type=="433"){
- $randnick++;
- $mennick.=$randnick;
- fputs($fp,"nick $mennick\n");
- }
-
- if($msg_info_type=="JOIN"){
- if($msgj==1){fputs($fp,"PRIVMSG $msg_user_param0 : Bienvenu $msg_info_nick sur $msg_user_param0\n"); }
- }
-
- if($msg_info_type=="PRIVMSG"){
- $timz=time();
- if(eregi(".jall",$msg_user_param0)){
- fputs($fp,"join #php\n");
- fputs($fp,"join #programmation\n");
- fputs($fp,"join #testing\n");
- }
- elseif(eregi(".time",$msg_user_param0) && $timeflood<=$timz){
- fputs($fp,"PRIVMSG $msg_info_target :Current time : ".date("Y-m-d h:i:s")."\n");
- $timeflood=time()+5;
- }
- elseif(eregi(".nick",$msg_user_param0) && $authing==$msg_info_host_auth){
- fputs($fp,"nick $msg_user_param1\n");
- $mennick=$msg_user_param1;
- }
- elseif(eregi(".msgj",$msg_user_param0) && $authing==$msg_info_host_auth){
- if($msgj==1){$msgj=0;fputs($fp,"PRIVMSG $msg_info_target :MSG Join off\n");}else{$msgj=1;fputs($fp,"PRIVMSG $msg_info_target :MSG join on\n");}
- }
- elseif(eregi(".ilist",$msg_user_param0)){
- fputs($fp,"PRIVMSG $msg_info_target :[-AUTH-] $authing\n");
- }
- elseif(eregi(".kill",$msg_user_param0) && $authing==$msg_info_host_auth){
- fputs($fp,"quit $msg_user_param1 $msg_user_param2\n");
- }
- elseif(eregi(".kchan",$msg_user_param0) && $authing==$msg_info_host_auth){
- fputs($fp,"part $msg_user_param1 $msg_user_param2\n");
- }
- elseif(eregi(".up",$msg_user_param0) && $authing==$msg_info_host_auth){
- fputs($fp,"MODE $msg_info_target +o $msg_user_param1\n");
- }
- elseif(eregi(".v",$msg_user_param0) && $authing==$msg_info_host_auth){
- fputs($fp,"MODE $msg_info_target +v $msg_user_param1\n");
- }
- elseif(eregi(".dv",$msg_user_param0) && $authing==$msg_info_host_auth){
- fputs($fp,"MODE $msg_info_target -v $msg_user_param1\n");
- }
- elseif(eregi(".inv",$msg_user_param0) && $authing==$msg_info_host_auth){
- fputs($fp,"invite $msg_user_param1 $msg_user_param2\n");
- }
- elseif(eregi(".down",$msg_user_param0) && $authing==$msg_info_host_auth){
- fputs($fp,"MODE $msg_info_target -o $msg_user_param1\n");
- }
- elseif(eregi(".fuck",$msg_user_param0) && $authing==$msg_info_host_auth){
- fputs($fp,"KICK $msg_info_target $msg_user_param1 :$msg_user_param2\n");
- }
- elseif(eregi(".hop",$msg_user_param0) && $authing==$msg_info_host_auth){
- fputs($fp,"part $msg_info_target\n");
- sleep(1);
- fputs($fp,"join $msg_info_target\n");
- }
- elseif(eregi(".ds",$msg_user_param0) && $authing==$msg_info_host_auth){
- fputs($fp,"PRIVMSG $msg_user_param1 :$msg_user_param2\n");
- }
- elseif(eregi(".join",$msg_user_param0) && $authing==$msg_info_host_auth){
- fputs($fp,"join $msg_user_param1\n");
- }
- elseif(eregi(".f",$msg_user_param0) && $authing==$msg_info_host_auth){
- fputs($fp,"$msg_user_param1 $msg_user_param2\n");
- }
- elseif(eregi("auth",$msg_user_param0)){
- if(eregi("admin",$msg_user_param1) && eregi("pass",$msg_user_param2)){
- fputs($fp,"PRIVMSG $msg_info_target :GooD Password!!!!\n");
- $authing=$msg_info_host_auth;
- }else{
- fputs($fp,"PRIVMSG $msg_info_target :Bad Password!!!!\n");
- }
- $aution=1;
- }
- elseif(eregi(".deident",$msg_user_param0) && $authing==$msg_info_host_auth){
- $authing="none";
- }
- elseif(eregi(".targetpv",$msg_user_param0) && $authing==$msg_info_host_auth){
- $targpv="$msg_user_param1";
- }
- elseif(eregi(".targetsal",$msg_user_param0) && $authing==$msg_info_host_auth){
- $targsal="$msg_user_param1";
- }
- elseif(eregi(".untargetpv",$msg_user_param0) && $authing==$msg_info_host_auth){
- unset($targpv);
- }
- elseif(eregi(".untargetsal",$msg_user_param0) && $authing==$msg_info_host_auth){
- unset($targsal);
- }
- elseif(eregi(".killsock",$msg_user_param0)){
- fputs($fp,"quit $msg_user_param1 $msg_user_param2\n");
- }
-
- if(!eregi("#",$msg_info_target) && isset($targpv) && $aution!=1){
- fputs($fp,"PRIVMSG $targpv :$msg_info_nick > $msg_user \n");
- }
- if(eregi("#",$msg_info_target) && isset($targsal) && $aution!=1){
- fputs($fp,"PRIVMSG $targsal :$msg_info_nick > $msg_user \n");
- }
- }
-
- unset($aution);
- unset($tab_temp0);
- unset($tab_temp1);
- unset($tab_temp2);
- unset($tab_temp3);
- unset($msg_user_param2);
- }
- ?>
<?
set_time_limit(0);
$serv="chat1.voila.fr";
echo "connect to $serv...<br>";
$fp=fsockopen("$serv","6667");
echo "Ident...<br>";
fputs($fp,"user PsY4 UNIX ggreg4@laposte.net PHP_BOT\n");
$mennick="ev-a[PsY4_BoT_PhP]";
fputs($fp,"nick $mennick\n");
sleep(1);
while($new=fgets($fp,1024)){
$new = str_replace("\r", "", $new);
$new = str_replace("\n", "", $new);
// :ServBoT!p@boss PRIVMSG #php :.ds #kaya salut
$tab_temp0=explode(":",$new);
$msg_void=$tab_temp0[0]; //ping
$msg_info=$tab_temp0[1]; //ServBoT!p@boss PRIVMSG #php
$msg_user=$tab_temp0[2]; //.ds #kaya salut ca va
$msg_void1=$tab_temp0[3]; //.ds #kaya salut ca va
// .ds #kaya salut
$tab_temp1=explode(" ",$msg_user);
$msg_user_param0=$tab_temp1[0]; //.ds
$msg_user_param1=$tab_temp1[1]; //#kaya
$nbtt=count($tab_temp1);
$nbtt--;
for($i=2;$i<=$nbtt;$i++){
$msg_user_param2.=$tab_temp1[$i]." "; //salut ca va
}
// ServBoT!p@boss PRIVMSG #php
$tab_temp2=explode("!",$msg_info);
$msg_info_nick=$tab_temp2[0]; //ServBoT
// ServBoT!p@boss PRIVMSG #php
$tab_temp3=explode(" ",$msg_info);
$msg_info_host=$tab_temp3[0]; //ServBoT!p@boss
$msg_info_type=$tab_temp3[1]; //PRIVMSG
$msg_info_target=$tab_temp3[2]; //#php
// ServBoT!p@boss PRIVMSG #php
$tab_temp4=explode("!",$msg_info_host);
$msg_info_host_auth=$tab_temp4[1]; //p@boss
echo "$new <br>";
if(eregi("PING",$tab_temp0[0])){
fputs($fp,"PONG $serv\n");
echo "<font color=red>PING? PONG!</font><br>";
}
//Si le pseudo exsiste deja
if($msg_info_type=="433"){
$randnick++;
$mennick.=$randnick;
fputs($fp,"nick $mennick\n");
}
if($msg_info_type=="JOIN"){
if($msgj==1){fputs($fp,"PRIVMSG $msg_user_param0 : Bienvenu $msg_info_nick sur $msg_user_param0\n"); }
}
if($msg_info_type=="PRIVMSG"){
$timz=time();
if(eregi(".jall",$msg_user_param0)){
fputs($fp,"join #php\n");
fputs($fp,"join #programmation\n");
fputs($fp,"join #testing\n");
}
elseif(eregi(".time",$msg_user_param0) && $timeflood<=$timz){
fputs($fp,"PRIVMSG $msg_info_target :Current time : ".date("Y-m-d h:i:s")."\n");
$timeflood=time()+5;
}
elseif(eregi(".nick",$msg_user_param0) && $authing==$msg_info_host_auth){
fputs($fp,"nick $msg_user_param1\n");
$mennick=$msg_user_param1;
}
elseif(eregi(".msgj",$msg_user_param0) && $authing==$msg_info_host_auth){
if($msgj==1){$msgj=0;fputs($fp,"PRIVMSG $msg_info_target :MSG Join off\n");}else{$msgj=1;fputs($fp,"PRIVMSG $msg_info_target :MSG join on\n");}
}
elseif(eregi(".ilist",$msg_user_param0)){
fputs($fp,"PRIVMSG $msg_info_target :[-AUTH-] $authing\n");
}
elseif(eregi(".kill",$msg_user_param0) && $authing==$msg_info_host_auth){
fputs($fp,"quit $msg_user_param1 $msg_user_param2\n");
}
elseif(eregi(".kchan",$msg_user_param0) && $authing==$msg_info_host_auth){
fputs($fp,"part $msg_user_param1 $msg_user_param2\n");
}
elseif(eregi(".up",$msg_user_param0) && $authing==$msg_info_host_auth){
fputs($fp,"MODE $msg_info_target +o $msg_user_param1\n");
}
elseif(eregi(".v",$msg_user_param0) && $authing==$msg_info_host_auth){
fputs($fp,"MODE $msg_info_target +v $msg_user_param1\n");
}
elseif(eregi(".dv",$msg_user_param0) && $authing==$msg_info_host_auth){
fputs($fp,"MODE $msg_info_target -v $msg_user_param1\n");
}
elseif(eregi(".inv",$msg_user_param0) && $authing==$msg_info_host_auth){
fputs($fp,"invite $msg_user_param1 $msg_user_param2\n");
}
elseif(eregi(".down",$msg_user_param0) && $authing==$msg_info_host_auth){
fputs($fp,"MODE $msg_info_target -o $msg_user_param1\n");
}
elseif(eregi(".fuck",$msg_user_param0) && $authing==$msg_info_host_auth){
fputs($fp,"KICK $msg_info_target $msg_user_param1 :$msg_user_param2\n");
}
elseif(eregi(".hop",$msg_user_param0) && $authing==$msg_info_host_auth){
fputs($fp,"part $msg_info_target\n");
sleep(1);
fputs($fp,"join $msg_info_target\n");
}
elseif(eregi(".ds",$msg_user_param0) && $authing==$msg_info_host_auth){
fputs($fp,"PRIVMSG $msg_user_param1 :$msg_user_param2\n");
}
elseif(eregi(".join",$msg_user_param0) && $authing==$msg_info_host_auth){
fputs($fp,"join $msg_user_param1\n");
}
elseif(eregi(".f",$msg_user_param0) && $authing==$msg_info_host_auth){
fputs($fp,"$msg_user_param1 $msg_user_param2\n");
}
elseif(eregi("auth",$msg_user_param0)){
if(eregi("admin",$msg_user_param1) && eregi("pass",$msg_user_param2)){
fputs($fp,"PRIVMSG $msg_info_target :GooD Password!!!!\n");
$authing=$msg_info_host_auth;
}else{
fputs($fp,"PRIVMSG $msg_info_target :Bad Password!!!!\n");
}
$aution=1;
}
elseif(eregi(".deident",$msg_user_param0) && $authing==$msg_info_host_auth){
$authing="none";
}
elseif(eregi(".targetpv",$msg_user_param0) && $authing==$msg_info_host_auth){
$targpv="$msg_user_param1";
}
elseif(eregi(".targetsal",$msg_user_param0) && $authing==$msg_info_host_auth){
$targsal="$msg_user_param1";
}
elseif(eregi(".untargetpv",$msg_user_param0) && $authing==$msg_info_host_auth){
unset($targpv);
}
elseif(eregi(".untargetsal",$msg_user_param0) && $authing==$msg_info_host_auth){
unset($targsal);
}
elseif(eregi(".killsock",$msg_user_param0)){
fputs($fp,"quit $msg_user_param1 $msg_user_param2\n");
}
if(!eregi("#",$msg_info_target) && isset($targpv) && $aution!=1){
fputs($fp,"PRIVMSG $targpv :$msg_info_nick > $msg_user \n");
}
if(eregi("#",$msg_info_target) && isset($targsal) && $aution!=1){
fputs($fp,"PRIVMSG $targsal :$msg_info_nick > $msg_user \n");
}
}
unset($aution);
unset($tab_temp0);
unset($tab_temp1);
unset($tab_temp2);
unset($tab_temp3);
unset($msg_user_param2);
}
?>
Conclusion
Note: Si vos commandes ne marche pas c'est peut etre à cose de vos couleurs!
Sinon: http://www.devforum.fr.fm (forum) http://xtrem.tuxfamily.org/posesource.php (échanger vos sources sur irc) http://www.liquid.fr.fm (site en construction)
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
socket connection irc help me plzz [ par yohannIII ]
bonjours je voudrais savoir comment me connecter a un server irc avec mot de pass requit et full name et adresse e-mail requis. merci d'avance. plus
Projet de bot irc [ par emilrom ]
Bonjour, Je cherche un bon codeur en tcl, C, php, python dans le but de crée un bot irc qui doit, par l'intermédiaire de socket, gérer
Les sockets php [ par PtitKev ]
Bonjour à toutes et a tous.Voila je test un bot socket en php. Je me suis rendu compte que les variables étaient propre a une page donc
socket [ par LaTatadu91 ]
salut,voila j'essaie de faire communiquer deux programmes un en PHP et l'autre en C et j'utilise pr cela les sockets de PHP avec le protocole TCP/IP..
socket non bloking [ par achil_ff ]
slt tt le monde svp pouvez vous m expliquer le principe des sockets non blokant bref je doi realiser une apllication PHP ki scanne les ports 25 ouvert
socket client (php) vers serveur (c++) [ par suleyman ]
bonjour, je suis debutant, je nai jamais programmer une socket et jaimerai avoir le code source ainsi que les commentaires dune socket client et serve
[Debutant] récupérer l'entête d'une page html [ par maniolar ]
Bonjour à tous voila j'aimerais realiser un outils comme celui-cihttp://www.webrankinfo.com/outils/header.php. Je voudrais juste récupé
irc : recuperation des user sur un chan [ par eragon77 ]
bonjour, voila tout est en dans le titre je cherche un script php en socket ou autre qui permet de recuperer les users d'un chan irc qui le marque su
sockets/php [ par agoumi ]
bonjour a tous! bon j'ai réaliser une socket serveur en php sous linux,mais lors de l'execution j'ai l'erreur suivant: Fatal error: Call to undefined
Chat en php [ par Ramboul ]
Salut,Je cherche un tchat en php pour mon site car j'ai déja un tchat mais il requiert d'avoir l'applet java.J'aimerai qu'il redeirige vers irc.quaken
|
Derniers Blogs
IMAGINE CUP 2012, MAKE A SIGN EN FINALEIMAGINE CUP 2012, MAKE A SIGN EN FINALE par junarnoalg
Voilà qui est fait, la nouvelle est officielle ! L'équipe belge "Make a Sign" va au pays des kangourous défendre son projet dans la catégorie Software Design. http://www.imaginecup.com/CompetitionsContent/Competition/WorldwideFinalists.aspx V...
Cliquez pour lire la suite de l'article par junarnoalg KINECT 1.5 IS OUT !KINECT 1.5 IS OUT ! par Vko
La version 1.5 du Kinect For Microsoft vient tout juste de sortir ! Plein de nouveautés: Tracking de squelette en Near Mode Détection en position assise Détection faciale avec un SDK dédié Documentation et des guideline (enfin) Un out...
Cliquez pour lire la suite de l'article par Vko LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) par richardc
Mise à jour des Web API du 14 Mai
Réservez dès maintenant votre journée du 20 juin pour le Windows Azure Dev Camp 2012 à Paris
Mise à jour de Team Foundation Service
MechCommander 2 sur Windows 8
Entity Framework 5 Release Candidate e...
Cliquez pour lire la suite de l'article par richardc REACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITERREACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITER par Groc
Une mauvaise utilisation de rx lors de l'écriture d'une couche d'accès à des services peut conduire à des cas embarassants avec des erreurs mal gérées, des appels qui ne partent lorsqu'ils le devraient, et même des résultats incorrects . le tout nuis...
Cliquez pour lire la suite de l'article par Groc SHAREPOINT BLOG SITE, PROBLèME D'ARCHIVESSHAREPOINT BLOG SITE, PROBLèME D'ARCHIVES par junarnoalg
Dernièrement, nous avons migré le site
myTIC
vers un nouveau serveur SharePoint 2010. Dans les contenus que nous vouloins récupérer, nous avions un certain nombre de blogs.
Nous avons utilisé les commandes Power...
Cliquez pour lire la suite de l'article par junarnoalg
Forum
RE : CODE RE : CODE par NHenry
Cliquez pour lire la suite par NHenry CODE CODE par i8bel
Cliquez pour lire la suite par i8bel
Logiciels
974 Application Server (12.2.4.0)974 APPLICATION SERVER (12.2.4.0)Développez de puissantes applications dans un environnement de 'cloud computing', clusterisé, séc... Cliquez pour télécharger 974 Application Server vPicture (1.4.2.1)VPICTURE (1.4.2.1)Avec vPicture, hébergez vos images facilement et rapidement.
vPicture est un utilitaire simple, ... Cliquez pour télécharger vPicture Easy-Planning (2.2.1.6)EASY-PLANNING (2.2.1.6)Easy-Planning permet de créer des plannings sous la représentation de diagrammes et est adapté au... Cliquez pour télécharger Easy-Planning COM-BACKUP (2.0)COM-BACKUP (2.0)
COM-BACKUP est un logiciel de sauvegarde qui permet de planifier les sauvegardes de vos dossiers ...
Cliquez pour télécharger COM-BACKUP mySongBook Player (1.0.0)MYSONGBOOK PLAYER (1.0.0)mySongBook Player est un logiciel gratuit permettant l'accès à une archive de tablatures/partitio... Cliquez pour télécharger mySongBook Player
|