begin process at 2010 03 18 10:06:38
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Tutoriaux

 > SOCKBOT (SNIPPET)

SOCKBOT (SNIPPET)


 Information sur la source

Note :
9,33 / 10 - par 3 personnes
9,33 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :Tutoriaux Niveau :Débutant Date de création :12/01/2004 Vu :3 027

Auteur : tofu

Ecrire un message privé
Commentaire sur cette source (8)
Ajouter un commentaire et/ou une note

 Description

Toujours dans ma ligné de petits snippets, voici un "Sockbot" robot en sockets se connectant sur un serveur irc. Les commandes principales sont placées dans un dialog et les informations de connection sont enregistrées dans des hashtables. Comme le titre l'énonce, ceci est un snippet donc libre à vous de le modifier (améliorer!! :p) et heu comme dhabitude, comme le code est coupé lors du post sur ce site, je vous fourni une url où vous trouverez la code non coupé:
http://membres.lycos.fr/xdbconcept/scripti ng/socker.txt
Ainsi qu'un screen de ce que donne le dialog:
http://membres.lycos.fr/xdbconcept/script ing/socker.PNG

Source

  • menu * {
  • Sockbot:/socker
  • }
  • alias socker dialog -m socker socker
  • dialog socker {
  • title "Sockbot"
  • size -1 -1 135 85
  • option dbu
  • tab "Connection", 1,2 1 130 80
  • tab "Commandes", 2,3 1 130 80
  • tab "About", 3,3 1 130 80
  • text "Server:", 4, 10 19 25 10, tab 1
  • text "Nick:", 5, 10 30 27 10, tab 1
  • edit "" 6,47 19 80 10, autohs limit 900 tab 1
  • edit "" 7,47 30 60 10, autohs limit 900 tab 1
  • text "Port:" 8,10 41 25 10, tab 1
  • edit "" 9, 47 41 40 10, autohs limit 900 tab 1
  • button "Connecter", 10,10 52 50 10, flat tab 1
  • button "Déconnecter", 11,75 52 50 10, flat tab 1
  • button "Fermer", 12, 50 65 35 10, flat cancel tab 1
  • text "Robot en sockets by tofu\\" 13,5 20 90 8, tab 3 nowrap disable
  • text "Remerciements à kenji pour l'identifieur $_sockerr" 14, 5 30 120 8, tab 3 nowrap disable
  • text "Contacts:" 15,5 40 30 8, tab 3 nowrap disable
  • link "FreKi@eXagon.org" 16, 5 50 50 8, tab 3
  • link "http://www.Xdb-Project.ft.tc" 17, 5 60 80 8, tab 3
  • button "Join", 18, 5 20 20 10, flat tab 2
  • button "Part", 19, 30 20 20 10, flat tab 2
  • button "Hop", 20, 55 20 20 10, flat tab 2
  • button "Msg", 21, 80 20 20 10, flat tab 2
  • button "Notice", 22, 105 20 20 10, flat tab 2
  • button "Kick", 23, 5 35 20 10, flat tab 2
  • button "Nick", 24, 30 35 20 10, flat tab 2
  • button "Voice", 25, 55 35 20 10, flat tab 2
  • button "Devoice", 26, 79 35 23 10, flat tab 2
  • button "Op", 27, 105 35 20 10, flat tab 2
  • button "Deop", 28, 5 50 20 10, flat tab 2
  • button "Whois", 29, 30 50 20 10, flat tab 2
  • }
  • on *:DIALOG:socker:*:*:{
  • if ($devent == init) { if (!$hget(socker)) { hmake socker } }
  • if ($devent == close) { if ($hget(socker)) { hfree socker } }
  • if ($devent == edit) {
  • if ($did == 6) { hadd socker server $did($dname,6) }
  • if ($did == 7) { hadd socker nick $did($dname,7) }
  • if ($did == 9) { hadd socker port $did($dname,9) }
  • }
  • if ($devent == sclick) {
  • if ($did == 10) { sockbot | window -ake @Socker }
  • if ($did == 11) { sockwrite -n socker QUIT $+(Socker,$chr(160),v0.1,$chr(160),by,$chr(160),tofu\\) }
  • if ($did == 16) { run mailto:FreKi@eXagon.org }
  • if ($did == 17) { run iexplore http://www.xdb-project.fr.tc }
  • if ($did == 18) { sockwrite -n socker join $?="Entrez un canal:(n'oubliez pas le #)" $+ $crlf }
  • if ($did == 19) { sockwrite -n socker part $?="Entrez un canal:(n'oubliez pas le #)" $+ $crlf }
  • if ($did == 20) { sockwrite -n socker part $?="Entrez un canal:(n'oubliez pas le #)" | sockwrite -n socker join $! }
  • if ($did == 21) { sockwrite -n socker privmsg $?="Entrez un canal:(n'oubliez pas le #)" : $+ $?="Entrez le phrase à dire:" $+ $crlf }
  • if ($did == 22) { sockwrite -n socker notice $?="Entrez un pseudo" : $?="Entrez la phrase à dire" $+ $crlf }
  • if ($did == 23) { sockwrite socker kick $?="Entrez un canal:(n'oubliez pas le #)" $?="Entrez un pseudo:" : $+ $?="Entrez une raison: (Vous pouvez laisser vierge si aucune raison)" $+ $crlf }
  • if ($did == 24) { sockwrite -n socker nick $?="Entrez un pseudo:" $+ $crlf }
  • if ($did == 25) { sockwrite -n socker mode $?="Entrez un canal:(n'oubliez pas le #)" +v $?="Entrez un pseudo:" $+ $crlf }
  • if ($did == 26) { sockwrite -n socker mode $?="Entrez un canal:(n'oubliez pas le #)" -v $?="Entrez un pseudo:" $+ $crlf }
  • if ($did == 27) { sockwrite -n socker mode $?="Entrez un canal:(n'oubliez pas le #)" +o $?="Entrez un pseudo:" $+ $crlf }
  • if ($did == 28) { sockwrite -n socker mode $?="Entrez un canal:(n'oubliez pas le #)" -o $?="Entrez un pseudo:" $+ $crlf }
  • if ($did == 29) { sockwrite -n socker whois $?="Entrez un pseudo" $+ $crlf }
  • }
  • }
  • alias sockbot { sockclose socker | sockopen socker $hget(socker,server) $hget(socker,port) }
  • on *:sockopen:socker:{
  • if ($sockerr) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Erreur),$c(4,$b($chr(41)))) $_sockerr($sockerr) | return }
  • sockwrite -n socker NICK $hget(socker,nick)
  • sockwrite -n socker USER Socker Socker Socker :Socker v0.1 by tofu\}
  • on *:sockread:socker:{
  • var %x
  • sockread %x
  • tokenize 32 %x
  • if ($gettok(%x,1,32) == PING) { sockwrite -n socker PONG $gettok(%x,2,32) | halt }
  • if ($gettok(%x,2,32) == :Closing) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Fermeture),$c(4,$b($chr(41)))) $4- | halt }
  • if ($gettok(%x,1,32) == NOTICE) && ($gettok(%x,2,32) == AUTH) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $remove($3,:) $4- | halt }
  • if ($gettok(%x,2,32) == PRIVMSG) && ($gettok(%x,4,32) == :VERSION) { sockwrite -nt socker NOTICE $remove($gettok(%x,1,$asc(!)),:) :VERSION Socker v0.1 by tofu\\ }
  • if ($gettok(%x,2,32) == TOPIC) { echo @Socker $+($c(3,$b($chr(40))),$c(3,/Topic),$c(3,$b($chr(41)))) $+($c(12,$b($chr(40))),$u($remove($gettok(%x,3,32),:)),$c(12,$b($chr(41)))) $+($c(12,$b($chr(40))),$c(4,$remove($gettok(%x,1,32),:)),$c(12,$b($chr(41)))) $c(0,$remove($4,:)) $c(0,$5-) | halt }
  • if ($gettok(%x,2,32) == JOIN) { echo @Socker $+($c(3,$b($chr(40))),$c(3,/Join),$c(3,$b($chr(41)))) $+($c(12,$b($chr(40))),$u($remove($gettok(%x,3,32),:)),$c(12,$b($chr(41)))) $+($c(12,$b($chr(40))),$c(4,$remove($gettok(%x,1,32),:)),$c(12,$b($chr(41)))) $c(0,$remove($4,:)) $c(0,$5-) | halt }
  • if ($gettok(%x,2,32) == MODE) { echo @Socker $+($c(7,$b($chr(40))),$c(7,/Mode),$c(7,$b($chr(41)))) $+($c(12,$b($chr(40))),$u($remove($gettok(%x,3,32),:)),$c(12,$b($chr(41)))) $+($c(12,$b($chr(40))),$c(4,$remove($gettok(%x,1,32),:)),$c(12,$b($chr(41)))) $c(0,$remove($4,:)) $c(0,$5-) | halt }
  • if ($gettok(%x,2,32) == PART) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Part),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$u($remove($gettok(%x,3,32),:)),$c(12,$b($chr(41)))) $+($c(12,$b($chr(40))),$c(4,$remove($gettok(%x,1,32),:)),$c(12,$b($chr(41)))) $c(0,$remove($4,:)) $c(0,$5-) | halt }
  • if ($gettok(%x,2,32) == PRIVMSG) { echo @Socker $+($c(3,$b($chr(40))),$c(3,/Pmsg),$c(3,$b($chr(41)))) $+($c(12,$b($chr(40))),$u($remove($gettok(%x,3,32),:)),$c(12,$b($chr(41)))) $+($c(12,$b($chr(40))),$c(4,$remove($gettok(%x,1,32),:)),$c(12,$b($chr(41)))) $c(0,$remove($4,:)) $c(0,$5-) | halt }
  • if ($gettok(%x,2,32) == NOTICE) { echo @Socker $+($c(7,$b($chr(40))),$c(7,/Notice),$c(7,$b($chr(41)))) $+($c(12,$b($chr(40))),$c(4,$remove($gettok(%x,1,32),:)),$c(12,$b($chr(41)))) $c(0,$remove($4,:) $5-) | halt }
  • if ($gettok(%x,2,32) == 001) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $remove($4,:) $5- | halt }
  • if ($gettok(%x,2,32) == 002) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $remove($4,:) $5- | halt }
  • if ($gettok(%x,2,32) == 003) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $remove($4,:) $5- | halt }
  • if ($gettok(%x,2,32) == 004) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $remove($4,:) $5- | halt }
  • if ($gettok(%x,2,32) == 005) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $remove($4,:) $5- | halt }
  • if ($gettok(%x,2,32) == 250) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $remove($4,:) $5- | halt }
  • if ($gettok(%x,2,32) == 251) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $remove($4,:) $5- | halt }
  • if ($gettok(%x,2,32) == 252) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $4 $remove($5,:) $6- | halt }
  • if ($gettok(%x,2,32) == 253) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $4 $remove($5,:) $6- | halt }
  • if ($gettok(%x,2,32) == 254) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $4 $remove($5,:) $6- | halt }
  • if ($gettok(%x,2,32) == 255) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $remove($4,:) $5- | halt }
  • if ($gettok(%x,2,32) == 265) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $remove($4,:) $5- | halt }
  • if ($gettok(%x,2,32) == 266) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $remove($4,:) $5- | halt }
  • if ($gettok(%x,2,32) == 267) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $remove($4,:) $5- | halt }
  • if ($gettok(%x,2,32) == 268) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $remove($4,:) $5- | halt }
  • if ($gettok(%x,2,32) == 304) { echo @Socker $+($c(12,$b($chr(40))),$c(12,/Infos),$c(12,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $remove($4,:) $5- | halt }
  • if ($gettok(%x,2,32) == 307) { echo @Socker $+($c(7,$b($chr(40))),$c(7,/Whois),$c(7,$b($chr(41)))) Register: $c(12,cet utilisateur est enregistré) | halt }
  • if ($gettok(%x,2,32) == 311) { echo @Socker $+($c(7,$b($chr(40))),$c(7,/Whois de $gettok(%x,4,32)),$c(7,$b($chr(41)))) | echo @Socker $+($c(7,$b($chr(40))),$c(7,/Whois),$c(7,$b($chr(41)))) Adresse: $+($c(12,$gettok(%x,4,32)),$c(12,!),$c(12,$gettok(%x,5,32)),$c(12,@),$c(12,$gettok(%x,6,32))) | echo @Socker $+($c(7,$b($chr(40))),$c(7,/Whois),$c(7,$b($chr(41)))) Nom Complet: $remove($c(12,$8),:) $c(12,$9-) | halt }
  • if ($gettok(%x,2,32) == 312) { echo @Socker $+($c(7,$b($chr(40))),$c(7,/Whois),$c(7,$b($chr(41)))) Server: $c(12,$5 $remove($6-,:)) | halt }
  • if ($gettok(%x,2,32) == 317) { echo @Socker $+($c(7,$b($chr(40))),$c(7,/Whois),$c(7,$b($chr(41)))) Idle: $c(12,$duration($5)) | halt }
  • if ($gettok(%x,2,32) == 318) { echo @Socker $+($c(7,$b($chr(40))),$c(7,/Whois de $gettok(%x,4,32)),$c(7,$b($chr(41)))) | halt }
  • if ($gettok(%x,2,32) == 319) { echo @Socker $+($c(7,$b($chr(40))),$c(7,/Whois),$c(7,$b($chr(41)))) Chans: $c(12,$remove($5,:) $6-) | halt }
  • if ($gettok(%x,2,32) == 320) { echo @Socker $+($c(7,$b($chr(40))),$c(7,/Whois),$c(7,$b($chr(41)))) Secure: $c(12,est sous une connection sécurisée) | halt }
  • if ($gettok(%x,2,32) == 353) { echo @Socker $+($c(7,$b($chr(40))),$c(7,/Names),$c(7,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $+($c(12,$b($chr(40))),$u($remove($gettok(%x,5,32),:)),$c(12,$b($chr(41)))) $remove($6,:) $7- | halt }
  • if ($gettok(%x,2,32) == 366) { halt }
  • if ($gettok(%x,2,32) == 375) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $remove($4,:) $5- | halt }
  • if ($gettok(%x,2,32) == 372) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $remove($4,:) $5- | halt }
  • if ($gettok(%x,2,32) == 376) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $remove($4,:) $5- | halt }
  • echo @Socker %x
  • }
  • on *:SOCKCLOSE:socker:{ echo @Socker $+($c(4,$b($chr(40))),$c(4,/Fermeture),$c(4,$b($chr(41)))) Socker déconnecté }
  • alias _sockerr {
  • if $$1 == 0 { return aucune erreur }
  • elseif $$1 == 1 { return impossible d'interpréter la requête à cause d'une erreur de format }
  • elseif $$1 == 2 { return impossible d'exécuter à cause d'une erreur interne du serveur }
  • elseif $$1 == 3 { return l'adresse soumise n'existe pas }
  • elseif $$1 == 4 { return type de la requête non supporté }
  • elseif $$1 == 5 { return demande refusée }
  • else { return erreur non documentée }
  • }
  • alias u { return $+($chr(31),$1,$chr(31)) }
  • alias b { return $+($chr(2),$1,$chr(2)) }
  • alias r { return $+($chr(22),$1,$chr(22)) }
  • alias c { return $+($+($chr(3),$1),$2,$chr(3)) }
menu * { 
  Sockbot:/socker
}
alias socker dialog -m socker socker
dialog socker {
  title "Sockbot"
  size -1 -1 135 85
  option dbu
  tab "Connection", 1,2 1 130 80
  tab "Commandes", 2,3 1 130 80
  tab "About", 3,3 1 130 80
  text "Server:", 4, 10 19 25 10, tab 1
  text "Nick:", 5, 10 30 27 10, tab 1
  edit "" 6,47 19 80 10, autohs limit 900 tab 1
  edit "" 7,47 30 60 10, autohs limit 900 tab 1
  text "Port:" 8,10 41 25 10, tab 1
  edit "" 9, 47 41 40 10, autohs limit 900 tab 1
  button "Connecter", 10,10 52 50 10, flat tab 1
  button "Déconnecter", 11,75 52 50 10, flat tab 1
  button "Fermer", 12, 50 65 35 10, flat cancel tab 1
  text "Robot en sockets by tofu\\" 13,5 20 90 8, tab 3 nowrap disable
  text "Remerciements à kenji pour l'identifieur $_sockerr" 14, 5 30 120 8, tab 3 nowrap disable
  text "Contacts:" 15,5 40 30 8, tab 3 nowrap disable
  link "FreKi@eXagon.org" 16, 5 50 50 8, tab 3
  link "http://www.Xdb-Project.ft.tc" 17, 5 60 80 8, tab 3
  button "Join", 18, 5 20 20 10, flat tab 2
  button "Part", 19, 30 20 20 10, flat tab 2
  button "Hop", 20, 55 20 20 10, flat tab 2
  button "Msg", 21, 80 20 20 10, flat tab 2
  button "Notice", 22, 105 20 20 10, flat tab 2
  button "Kick", 23, 5 35 20 10, flat tab 2
  button "Nick", 24, 30 35 20 10, flat tab 2
  button "Voice", 25, 55 35 20 10, flat tab 2
  button "Devoice", 26, 79 35 23 10, flat tab 2
  button "Op", 27, 105 35 20 10, flat tab 2
  button "Deop", 28, 5 50 20 10, flat tab 2
  button "Whois", 29, 30 50 20 10, flat tab 2
}

on *:DIALOG:socker:*:*:{
  if ($devent == init) { if (!$hget(socker)) { hmake socker } }
  if ($devent == close) { if ($hget(socker)) { hfree socker } }
  if ($devent == edit) {
    if ($did == 6) { hadd socker server $did($dname,6) }
    if ($did == 7) { hadd socker nick $did($dname,7) }
    if ($did == 9) { hadd socker port $did($dname,9) }
  }
  if ($devent == sclick) { 
    if ($did == 10) { sockbot | window -ake @Socker }
    if ($did == 11) { sockwrite -n socker QUIT $+(Socker,$chr(160),v0.1,$chr(160),by,$chr(160),tofu\\)  }
    if ($did == 16) { run mailto:FreKi@eXagon.org }
    if ($did == 17) { run iexplore http://www.xdb-project.fr.tc }
    if ($did == 18) { sockwrite -n socker join $?="Entrez un canal:(n'oubliez pas le #)" $+ $crlf }
    if ($did == 19) { sockwrite -n socker part $?="Entrez un canal:(n'oubliez pas le #)" $+ $crlf }
    if ($did == 20) { sockwrite -n socker part $?="Entrez un canal:(n'oubliez pas le #)" | sockwrite -n socker join $! }
    if ($did == 21) { sockwrite -n socker privmsg $?="Entrez un canal:(n'oubliez pas le #)" : $+ $?="Entrez le phrase à dire:" $+ $crlf }
    if ($did == 22) { sockwrite -n socker notice $?="Entrez un pseudo" : $?="Entrez la phrase à dire" $+ $crlf }
    if ($did == 23) { sockwrite socker kick $?="Entrez un canal:(n'oubliez pas le #)" $?="Entrez un pseudo:" : $+ $?="Entrez une raison: (Vous pouvez laisser vierge si aucune raison)" $+ $crlf }
    if ($did == 24) { sockwrite -n socker nick $?="Entrez un pseudo:" $+ $crlf }
    if ($did == 25) { sockwrite -n socker mode $?="Entrez un canal:(n'oubliez pas le #)" +v $?="Entrez un pseudo:" $+ $crlf }
    if ($did == 26) { sockwrite -n socker mode $?="Entrez un canal:(n'oubliez pas le #)" -v $?="Entrez un pseudo:" $+ $crlf }
    if ($did == 27) { sockwrite -n socker mode $?="Entrez un canal:(n'oubliez pas le #)" +o $?="Entrez un pseudo:" $+ $crlf }
    if ($did == 28) { sockwrite -n socker mode $?="Entrez un canal:(n'oubliez pas le #)" -o $?="Entrez un pseudo:" $+ $crlf }
    if ($did == 29) { sockwrite -n socker whois $?="Entrez un pseudo" $+ $crlf }
  }
}

alias sockbot { sockclose socker | sockopen socker $hget(socker,server) $hget(socker,port) }

on *:sockopen:socker:{
  if ($sockerr) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Erreur),$c(4,$b($chr(41)))) $_sockerr($sockerr) | return }
  sockwrite -n socker NICK $hget(socker,nick)
  sockwrite -n socker USER Socker Socker Socker :Socker v0.1 by tofu\}
on *:sockread:socker:{
  var %x
  sockread %x
  tokenize 32 %x
  if ($gettok(%x,1,32) == PING) { sockwrite -n socker PONG $gettok(%x,2,32) | halt }
  if ($gettok(%x,2,32) == :Closing) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Fermeture),$c(4,$b($chr(41)))) $4- | halt }
  if ($gettok(%x,1,32) == NOTICE) && ($gettok(%x,2,32) == AUTH) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $remove($3,:) $4- | halt }
  if ($gettok(%x,2,32) == PRIVMSG) && ($gettok(%x,4,32) == :VERSION) { sockwrite -nt socker NOTICE $remove($gettok(%x,1,$asc(!)),:) :VERSION Socker v0.1 by tofu\\ }
  if ($gettok(%x,2,32) == TOPIC) { echo @Socker $+($c(3,$b($chr(40))),$c(3,/Topic),$c(3,$b($chr(41)))) $+($c(12,$b($chr(40))),$u($remove($gettok(%x,3,32),:)),$c(12,$b($chr(41)))) $+($c(12,$b($chr(40))),$c(4,$remove($gettok(%x,1,32),:)),$c(12,$b($chr(41)))) $c(0,$remove($4,:)) $c(0,$5-) | halt }
  if ($gettok(%x,2,32) == JOIN) { echo @Socker $+($c(3,$b($chr(40))),$c(3,/Join),$c(3,$b($chr(41)))) $+($c(12,$b($chr(40))),$u($remove($gettok(%x,3,32),:)),$c(12,$b($chr(41)))) $+($c(12,$b($chr(40))),$c(4,$remove($gettok(%x,1,32),:)),$c(12,$b($chr(41)))) $c(0,$remove($4,:)) $c(0,$5-) | halt }
  if ($gettok(%x,2,32) == MODE) { echo @Socker $+($c(7,$b($chr(40))),$c(7,/Mode),$c(7,$b($chr(41)))) $+($c(12,$b($chr(40))),$u($remove($gettok(%x,3,32),:)),$c(12,$b($chr(41)))) $+($c(12,$b($chr(40))),$c(4,$remove($gettok(%x,1,32),:)),$c(12,$b($chr(41)))) $c(0,$remove($4,:)) $c(0,$5-) | halt }
  if ($gettok(%x,2,32) == PART) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Part),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$u($remove($gettok(%x,3,32),:)),$c(12,$b($chr(41)))) $+($c(12,$b($chr(40))),$c(4,$remove($gettok(%x,1,32),:)),$c(12,$b($chr(41)))) $c(0,$remove($4,:)) $c(0,$5-) | halt } 
  if ($gettok(%x,2,32) == PRIVMSG) { echo @Socker $+($c(3,$b($chr(40))),$c(3,/Pmsg),$c(3,$b($chr(41)))) $+($c(12,$b($chr(40))),$u($remove($gettok(%x,3,32),:)),$c(12,$b($chr(41)))) $+($c(12,$b($chr(40))),$c(4,$remove($gettok(%x,1,32),:)),$c(12,$b($chr(41)))) $c(0,$remove($4,:)) $c(0,$5-) | halt }
  if ($gettok(%x,2,32) == NOTICE) { echo @Socker  $+($c(7,$b($chr(40))),$c(7,/Notice),$c(7,$b($chr(41)))) $+($c(12,$b($chr(40))),$c(4,$remove($gettok(%x,1,32),:)),$c(12,$b($chr(41)))) $c(0,$remove($4,:) $5-)  | halt }
  if ($gettok(%x,2,32) == 001) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $remove($4,:) $5- | halt }
  if ($gettok(%x,2,32) == 002) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $remove($4,:) $5- | halt }
  if ($gettok(%x,2,32) == 003) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $remove($4,:) $5- | halt }
  if ($gettok(%x,2,32) == 004) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $remove($4,:) $5- | halt }
  if ($gettok(%x,2,32) == 005) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $remove($4,:) $5- | halt }
  if ($gettok(%x,2,32) == 250) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $remove($4,:) $5- | halt }
  if ($gettok(%x,2,32) == 251) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $remove($4,:) $5- | halt }
  if ($gettok(%x,2,32) == 252) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $4 $remove($5,:) $6- | halt }
  if ($gettok(%x,2,32) == 253) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $4 $remove($5,:) $6- | halt }
  if ($gettok(%x,2,32) == 254) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $4 $remove($5,:) $6- | halt }
  if ($gettok(%x,2,32) == 255) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $remove($4,:) $5- | halt }
  if ($gettok(%x,2,32) == 265) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $remove($4,:) $5- | halt }
  if ($gettok(%x,2,32) == 266) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $remove($4,:) $5- | halt }
  if ($gettok(%x,2,32) == 267) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $remove($4,:) $5- | halt }
  if ($gettok(%x,2,32) == 268) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $remove($4,:) $5- | halt }
  if ($gettok(%x,2,32) == 304) { echo @Socker $+($c(12,$b($chr(40))),$c(12,/Infos),$c(12,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $remove($4,:) $5- | halt }
  if ($gettok(%x,2,32) == 307) { echo @Socker $+($c(7,$b($chr(40))),$c(7,/Whois),$c(7,$b($chr(41)))) Register: $c(12,cet utilisateur est enregistré) | halt }
  if ($gettok(%x,2,32) == 311) { echo @Socker $+($c(7,$b($chr(40))),$c(7,/Whois de $gettok(%x,4,32)),$c(7,$b($chr(41)))) | echo @Socker $+($c(7,$b($chr(40))),$c(7,/Whois),$c(7,$b($chr(41)))) Adresse: $+($c(12,$gettok(%x,4,32)),$c(12,!),$c(12,$gettok(%x,5,32)),$c(12,@),$c(12,$gettok(%x,6,32))) | echo @Socker $+($c(7,$b($chr(40))),$c(7,/Whois),$c(7,$b($chr(41)))) Nom Complet: $remove($c(12,$8),:) $c(12,$9-) | halt }
  if ($gettok(%x,2,32) == 312) { echo @Socker $+($c(7,$b($chr(40))),$c(7,/Whois),$c(7,$b($chr(41)))) Server: $c(12,$5 $remove($6-,:)) | halt }
  if ($gettok(%x,2,32) == 317) { echo @Socker $+($c(7,$b($chr(40))),$c(7,/Whois),$c(7,$b($chr(41)))) Idle: $c(12,$duration($5)) | halt }
  if ($gettok(%x,2,32) == 318) { echo @Socker $+($c(7,$b($chr(40))),$c(7,/Whois de $gettok(%x,4,32)),$c(7,$b($chr(41)))) | halt }
  if ($gettok(%x,2,32) == 319) { echo @Socker $+($c(7,$b($chr(40))),$c(7,/Whois),$c(7,$b($chr(41)))) Chans: $c(12,$remove($5,:) $6-) | halt }
  if ($gettok(%x,2,32) == 320) { echo @Socker $+($c(7,$b($chr(40))),$c(7,/Whois),$c(7,$b($chr(41)))) Secure: $c(12,est sous une connection sécurisée) | halt }
  if ($gettok(%x,2,32) == 353) { echo @Socker $+($c(7,$b($chr(40))),$c(7,/Names),$c(7,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $+($c(12,$b($chr(40))),$u($remove($gettok(%x,5,32),:)),$c(12,$b($chr(41)))) $remove($6,:) $7- | halt }
  if ($gettok(%x,2,32) == 366) { halt }
  if ($gettok(%x,2,32) == 375) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $remove($4,:) $5- | halt }
  if ($gettok(%x,2,32) == 372) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $remove($4,:) $5- | halt }
  if ($gettok(%x,2,32) == 376) { echo @Socker $+($c(4,$b($chr(40))),$c(4,/Server),$c(4,$b($chr(41)))) $+($c(12,$b($chr(40))),$remove($gettok(%x,1,32),:),$c(12,$b($chr(41)))) $remove($4,:) $5- | halt }
  echo @Socker %x
}
on *:SOCKCLOSE:socker:{ echo @Socker $+($c(4,$b($chr(40))),$c(4,/Fermeture),$c(4,$b($chr(41)))) Socker déconnecté }

alias _sockerr {
  if $$1 == 0 { return aucune erreur }
  elseif $$1 == 1 { return impossible d'interpréter la requête à cause d'une erreur de format }
  elseif $$1 == 2 { return impossible d'exécuter à cause d'une erreur interne du serveur }
  elseif $$1 == 3 { return l'adresse soumise n'existe pas }
  elseif $$1 == 4 { return type de la requête non supporté }
  elseif $$1 == 5 { return demande refusée }
  else { return erreur non documentée }
}

alias u { return $+($chr(31),$1,$chr(31)) }
alias b { return $+($chr(2),$1,$chr(2)) }
alias r { return $+($chr(22),$1,$chr(22)) }
alias c { return $+($+($chr(3),$1),$2,$chr(3)) }


 Conclusion

En espérant que ce code aidera certains d'entre vous, pour de plus amples informations, vous avez mon mail dans le dialog ;)


 Sources du même auteur

MINI TUTO SUR L'OPTIMISATION
Source avec Zip Source avec une capture GESTION HTABLE
MASS MODES
Source avec Zip Source avec une capture MODÉRATION
NEWS K-OTIK.

 Sources de la même categorie

TOUT SAVOIR SUR L'ECRITURE EN COULEUR par SaD_AnG3L
Source avec Zip Source avec une capture [TUTORIAL] LECTEUR MP3 EN DIALOG par fjxokt
Source avec une capture "RESIZE" SANS DLL par IceTempest
MINI TUTO SUR L'OPTIMISATION par tofu
Source avec Zip TUTORIAL PICWIN, APPROFONDISSEMENT par KiNdErMaXi

Commentaires et avis

Commentaire de ReMi34 le 12/01/2004 20:36:46

On en a déjà parlé :)

Commentaire de ChAnG-Fu le 12/01/2004 21:24:31

Sympas pour la maitrise du socket mais il serai bienvenu un interface en @window par salon et par query avec des menu @bot#-* et menu @botq-* mais bon c tres chaud a faire....

Sinon je suis bien content de cette source :) les bot en socket son rare mais domage qu'on ne puisse inséré des modules ou programmer certaine fonction du bot

9/10 :)

Commentaire de tofu le 12/01/2004 21:40:19

l'interface en @win, je vais essayer je commence seulement à apprendre les @win.. et sinon les modules, je pense en intégrer aussi :)

Commentaire de ReMi34 le 13/01/2004 06:38:44

Par contre, ce que tu pourrais ajouter, c'est les commandes halfop et dehalfop. Sinon, c'est parfait : dialog à la bonne taille. Code : parfait.
Voilà je te mets 9/10 aussi :)

Commentaire de tofu le 13/01/2004 07:42:52

je compte rajouter ceci dès que j'ai le temps et selon mes capacités à les coder:
- modes pour les chans
- module de traduction
- module de news du site ircfr (ou sdb)
- changer l'interface pour la mettre en @win avec des menus et des fenêtres précise pour chaque action
- continuer la liste des raw faits
- module de news aléatoires (site d'informations internationales)

si vous avez d'autres idées ou besoins, je suis prenneur ;)

Commentaire de vesparo le 13/01/2004 12:59:18

très beau :) 8/10 les sockets sont cool et vla :D

Commentaire de DarKiNg virus le 14/01/2004 17:31:18

ohhhhh Ôo !!!!!!!
           \__/
            [_]  CHEZ BEAU LES CHOSES BIEN PI LA C'EST BO  !!!!!!! DONC C'EST BIEN

Commentaire de tofu le 14/01/2004 20:20:57

même si je crois ne pas tout à fait saisir la syntaxe de ta phrase DarKiNg virus, je te remercie de dire que c'est bien :o)

 Ajouter un commentaire




Nos sponsors


Appels d'offres

Sondage...

Comparez les prix


HTC Hero

Entre 550€ et 550€

CalendriCode

Mars 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728
293031    

Consulter la suite du CalendriCode

Photothèque

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,546 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales