a channel spybot i have in ym, script :)
dialog spybot {
size -1 -1 200 180
title "Channel Spy"
Button "Connect", 1, 4 150 75 25, default ok
Button "Cancel", 2, 120 150 75 25, cancel
Text "Server:", 3, 4 1 50 20, default
Edit %spybot_server, 4, 4 15 190 20, default
Text "Port:", 5, 4 35 50 20, default
Edit %spybot_port, 6, 4 50 190 20, default
Text "Nick:", 7, 4 70 50 20, default
Edit %spybot_nick, 8, 4 85 190 20, default
Text "First channel to join:", 9, 4 105 200 20, default
Edit %spybot_channel, 10, 4 120 190 20, default
}
on *:dialog:spybot:sclick:1: {
%spybot_server = $did($dname, 4)
%spybot_port = $did($dname, 6)
%spybot_nick = $did($dname, 8)
%spybot_channel = $did($dname, 10)
sockclose spybot
sockopen spybot %spybot_server %spybot_port
window -e @ChannelSpy
}
menu @ChannelSpy {
Join Channel: /sockwrite -n spybot JOIN $input(Channel to join:, 1)
Part Channel: /sockwrite -n spybot PART $input(Channel to PART:, 1)
-
Quit: /sockwrite -n spybot QUIT : $+ $input(Reason:, 1) | /echo -a 14Channel Spy v1.0 Disconnected. | /timer 1 3 /window -c @ChannelSpy
-
Clear: /clear
}
menu status,menubar {
-
Channel Spy: /dialog -m spybot spybot
}
on *:input:@ChannelSpy: {
if ($mid($1, 1 , 1) != /) {
sockwrite -n spybot $1-
aline @ChannelSpy Just did " $+ $1- $+ "
}
}
on *:sockopen:spybot: {
timer 1 4 /sockwrite -n $sockname USER %spybot_nick Channel@spy.no none none
timer 1 4 /sockwrite -n $sockname NICK %spybot_nick
timer 1 5 /sockwrite -n $sockname JOIN %spybot_channel
}
on *:sockread:spybot: {
sockread %spy_temp
if ($window(@ChannelSpy).hwnd == $null) { window -e @ChannelSpy }
if ( $gettok(%spy_temp, 1, 32) == PING ) { sockwrite -n $sockname PONG $gettok(%spy_temp, 2, 32) | aline -h @ChannelSpy 7[14Recived PING7] 2From: $gettok(%spy_temp, 2, 58) | .halt }
if ( $gettok(%spy_temp, 2, 32) == PONG ) { aline -h @ChannelSpy 7[14Recived PONG7] 2From: $gettok(%spy_temp, 3, 32) | .halt }
if ( $gettok(%spy_temp, 2, 32) == PRIVMSG ) { aline -h @ChannelSpy $replace($gettok(%spy_temp, 1, 33), :, <) $+ @ $+ $gettok(%spy_temp, 3, 32) $+ > $gettok(%spy_temp, 2-, 58) | .halt }
if ( $gettok(%spy_temp, 2, 32) == JOIN ) { aline -h @ChannelSpy $replace($gettok(%spy_temp, 1, 33), :, 3) has joined $replace($gettok(%spy_temp, 3, 32), :, 3) | .halt }
if ( $gettok(%spy_temp, 2, 32) == PART ) { aline -h @ChannelSpy $replace($gettok(%spy_temp, 1, 33), :, 3) has left $replace($gettok(%spy_temp, 3, 32), :, 3) | .halt }
if ( $gettok(%spy_temp, 2, 32) == MODE ) { aline -h @ChannelSpy 3 $+ $gettok(%spy_temp, 3, 32) -> $replace($gettok(%spy_temp, 1, 33), :, 3) sets mode $gettok(%spy_temp, 4, 32) $gettok(%spy_temp, 5, 32) | .halt }
if ( $gettok(%spy_temp, 2, 32) == QUIT ) { aline -h @ChannelSpy $replace($gettok(%spy_temp, 1, 33), :, 2) has quit IRC ( $+ $gettok(%spy_temp, 2-, 58) $+ ) | .halt }
if ( $gettok(%spy_temp, 2, 32) == TOPIC ) { aline -h @ChannelSpy 3 $+ $gettok(%spy_temp, 3, 32) -> $replace($gettok(%spy_temp, 1, 33), :, 3) changes topic to $gettok(%spy_temp, 2-, 58) | .halt }
if ( $gettok(%spy_temp, 2, 32) == NICK ) { aline -h @ChannelSpy $replace($gettok(%spy_temp, 1, 33), :, 3) changed nick to $replace($gettok(%spy_temp, 3, 32), :, 3) | .halt }
if ( $gettok(%spy_temp, 2, 32) == NOTICE ) { aline -h @ChannelSpy $replace($gettok(%spy_temp, 1, 33), :, 5) $+ @ $+ $gettok(%spy_temp, 3, 32) -> $gettok(%spy_temp, 2-, 58) | .halt }
;:hva skjer a
aline -a @ChannelSpy %spy_temp
}
I must say that this was really poorly put together. The execution was noted but there are many improvements to be made. The timers in your sockopen event aren\'t nessary and rather then using a timer to join a channel use numeric raws ie: \" if ($gettok(%spy_tmp,2,32) == 376) || ($gettok(%spy_tmp,2,32) == 422) {\" put your join event there. As to your sockread event, its really sloppy and could use some trimming. also try using elseif statements rather then if statement after if statement.