Форум АНТИЧАТ

Форум АНТИЧАТ (https://forum.antichat.xyz/index.php)
-   PHP, PERL, MySQL, JavaScript (https://forum.antichat.xyz/forumdisplay.php?f=37)
-   -   MSL SocketBot (https://forum.antichat.xyz/showthread.php?t=46060)

Isis 04.08.2007 21:29

MSL SocketBot
 
MSL SocketBot

Код:

alias s.con {
  if ($sock(scon)) return
  if (!$1) {
    echo -ta usage: /s.con irc.antichat.net [6667]
  }
  else {
    sockopen scon $1 $iif($2,$2,6667)
  }
}

¤ sockopen scon $1 $iif($2,$2,6667) - открываем связь, если порт не указан, то используем порт 6667

Код:

alias s.write {
  if (!$sock(scon)) return
  sockwrite -n scon $1-
}

¤ sockwrite -n scon $1 - Передает связи, и соответственно серверу команды.

Код:

on *:sockopen:scon:{
  s.write NICK bot
  s.write USER bot * * : bot
  .timer 1 4 s.write join #antichat
}

¤ s.write NICK bot - Ник бота
¤ s.write USER bot - Ident бота
¤ .timer 1 4 s.write join #antichat - Спустя 4 секунды заходим на канал

Код:

on *:sockread:scon:{
  while ($sock(scon).rq) {
    if ($sockbr == 0) return
    if ($1 == PING) s.write PONG $2-
  }
}

Отвечаем на пинги, понгом ;-)

Код:

; socketconnection

alias s.con {
  if ($sock(scon)) return
  if (!$1) {
    echo -ta usage: /s.con irc.antichat.net [6667]
  }
  else {
    sockopen scon $1 $iif($2,$2,6667)
  }
}

alias s.write {
  if (!$sock(scon)) return
  sockwrite -n scon $1-
}

on *:sockopen:scon:{
  s.write NICK take2
  s.write USER take2 * * : take2
  .timer 1 4 s.write join #antichat
}

on *:sockread:scon:{
  while ($sock(scon).rq) {
    if ($sockbr == 0) return
    if ($1 == PING) s.write PONG $2-
  }
}

(c) Enel
Translation has made Isis


Время: 02:03