Auto join multi-serveur

Contenu du snippet

Voici un auto-join très simple d'utilisation.

Caractéristiques :

- Fonctionne a partir du $network
- Channels stockés en hash-table
- Dialog pas encombrant et assez simple d'utilisation
- Petite aide intégrée

Source / Exemple :


dialog autojoin {
  title "Auto Join v1.3 Par MaX_62"
  size -1 -1 161 104
  option dbu
  text "Liste des serveurs :", 1, 6 8 49 8
  list 2, 5 17 71 54, size vsbar
  button "Ajouter", 3, 8 72 30 12
  text "Liste des channels :", 4, 86 8 49 8
  list 5, 85 17 71 54, size vsbar
  box "Serveurs", 6, 2 1 77 86
  box "Channels", 7, 82 1 77 86
  button "Effacer", 8, 42 72 30 12
  button "Ajouter", 9, 88 72 30 12
  button "Effacer", 10, 122 72 30 12
  button "Fermer", 11, 78 90 37 12, cancel
  button "Aide", 12, 117 90 37 12
  check "Activer l'autojoin", 13, 12 90 50 12
}
dialog -l add.serv {
  title "Ajouter un serveur"
  size -1 -1 89 36
  option dbu
  text "Network :", 1, 5 6 25 8
  edit "", 2, 31 5 52 10, autohs
  button "Ajouter", 3, 26 19 37 12, ok cancel
}
dialog -l add.chan {
  title "Ajouter un channel"
  size -1 -1 89 36
  option dbu
  text "Channel :", 1, 5 6 25 8
  edit "", 2, 31 5 52 10, autohs
  button "Ajouter", 3, 26 19 37 12, ok cancel
}
dialog -l help.autojoin {
  title "Auto Join Par MaX_62 ~ Aide"
  size -1 -1 130 69
  option dbu
  text "Cette add-on vous permettra de joindre les channels que vous souhaitez, dans le(s) serveurs que vous aurez spécifié.", 1, 3 3 125 22
  text "Pour connaître le network tapez //echo -a $network dans le serveur souhaité.", 2, 3 27 125 16
  text "Bon t'chat !", 3, 3 45 31 8
  button "Fermer", 4, 44 54 37 12, cancel
}
on *:DIALOG:*:*:*:{
  if ($dname == autojoin) {
    if ($devent == init) {
      refresh.list.serv 
      if (%etat.autojoin == on) { did -c autojoin 13 } 
    }
    elseif ($devent == sclick) {
      if ($did == 2) { set %actuserv $did(autojoin,2).seltext | lister.channels }
      elseif ($did == 3) { dialog $+(-,$iif($dialog(add.serv),v,m)) add.serv add.serv }
      elseif ($did == 8 && $did(autojoin,2).seltext) { hdel autojoin $ifmatch | refresh.list.serv }
      elseif ($did == 9) { dialog $+(-,$iif($dialog(add.chan),v,m)) add.chan add.chan }
      elseif ($did == 10 && $did(autojoin,5).sel) { hadd autojoin %actuserv $deltok($hget(autojoin,%actuserv),$ifmatch,32) | refresh.list.serv }
      elseif ($did == 12) { dialog $+(-,$iif($dialog(help.autojoin),v,m)) help.autojoin help.autojoin }
      elseif ($did == 13) { set %etat.autojoin $iif($did(autojoin,13).state,on,off) }
    }
  }
  elseif ($dname == add.serv && $devent == sclick && $did == 3 && $did(add.serv,2)) {
    if (!$hfind(autojoin,$ifmatch)) { hadd autojoin $did(add.serv,2) | hsave autojoin autojoin | refresh.list.serv }
    else { echo -a [AutoJoin] Ce serveur est déjà dans la liste }
  }
  elseif ($dname == add.chan && $devent == sclick && $did == 3 && $did(add.chan,2)) {
    hadd autojoin %actuserv $addtok($hget(autojoin,%actuserv),$ifmatch,32)
    hsave autojoin autojoin
    refresh.list.serv
  }
}
on *:START:{
  hmake autojoin
  $iif($exists(autojoin),hload,hsave) autojoin autojoin
}
on *:CONNECT:{
  if (%etat.autojoin == on && $hget(autojoin,$network)) {
    var %a 1
    while ($gettok($hget(autojoin,$network),%a,32)) { join $ifmatch | inc %a }
  }
}
on *:LOAD:{ 
  echo -a [AutoJoin] v1.3 par MaX_62 chargé ! Utilisation : /autojoin
  set %etat.autojoin on
}

alias -l refresh.list.serv {
  did -r autojoin 2,5
  var %a 1
  while ($hget(autojoin,%a).item) { did -a autojoin 2 $ifmatch | inc %a }
}
alias -l lister.channels {
  did -r autojoin 5
  var %a 1
  while ($gettok($hget(autojoin,%actuserv),%a,32)) { did -a autojoin 5 $ifmatch | inc %a }
}
alias autojoin dialog $+(-,$iif($dialog(autojoin),v,m)) autojoin autojoin

Conclusion :


Voila, c'est rien de compliqué, mais assez utile.
Si vous remarquez des bugs ou défauts, merci de me les dire :p

MaX_62

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.