Skip to content

Instantly share code, notes, and snippets.

@nathanctech
Created May 21, 2018 01:17
Show Gist options
  • Save nathanctech/e7f7d9ff35a890877de0fdb70b595ed0 to your computer and use it in GitHub Desktop.
Save nathanctech/e7f7d9ff35a890877de0fdb70b595ed0 to your computer and use it in GitHub Desktop.
;Clones
dialog c {
title "mIRC Clone"
size -1 -1 244 173
option dbu
box "Status", 1, 0 0 114 42
text "Connection Status", 2, 3 8 45 8
text "", 3, 52 8 57 8
text "Network", 4, 3 19 25 8
text "", 5, 52 19 57 8
text "Current Nick", 6, 3 30 45 8
text "", 7, 52 30 57 8
box "Basic Config", 8, 113 0 130 42
text "Nick", 9, 117 8 33 8
text "Server Path", 10, 117 19 33 8
text "Ident Info", 11, 117 30 33 8
edit "", 12, 154 7 50 10, limit 32
edit "", 13, 154 18 50 10, autohs
edit "", 14, 154 28 50 10, autohs
button "Connect", 15, 207 7 32 12
button "Disconnect", 16, 207 26 32 12
box "Messages", 17, 0 44 243 90
edit "", 18, 3 52 237 79, read multi autovs vsbar
box "Command Box", 19, 0 135 243 22
edit "", 20, 3 143 194 10, autohs
button "Send", 21, 202 142 37 12, ok
button "Close", 22, 206 160 37 12, cancel
text "Raw String", 23, 3 161 27 8
text "", 24, 34 161 169 8, nowrap
}
menu menubar,channel,status {
mIRC Clone:/dialog -m c c
}
On *:Dialog:c:*:*:{
if ($devent == init) {
if (%c.status) { did -a c 3 %c.status }
if (%c.network) { did -a c 5 %c.network | did -a c 13 %c.network }
if (%c.nick) { did -a c 7 %c.nick | did -a c 12 %c.nick }
if (%c.ident) { did -a c 14 %c.ident }
update
.timerautoud 0 1 update
}
if ($devent == sclick) {
if ($did == 15) {
if (!%c.network) || (!%c.nick) || (!%c.ident) { addl System Error: Not enough data to connect! | halt }
set %c.port $?="Port?"
$iif(%c.port == 6697,sockopen -e clone.connect %c.network %c.port,sockopen clone.connect %c.network %c.port)
addl [System] Please wait...establishing connection to host... $iif(%port == 6697,[SSL])
set %c.status Connecting...
update
did -b c 15
did -e c 16
}
if ($did == 16) {
set -u3 %c.dc 1
sockwrite -n clone.connect QUIT :mIRC Clone Script By Master $iif($sock(clone.connect).ssl == $true,[Using SSL])
addl [System] Sent disconnect signal!
set %c.status Disconnecting....
.timerforcedc 1 10 sockclose clone.connect
update
}
if ($did == 21) { sockwrite -n clone.connect $did(20).text | addl [System] Command sent --> $did(20).text | halt }
}
if ($devent == edit) {
if ($did == 12) { set %c.nick $did(12) }
if ($did == 13) { set %c.network $did(13) }
if ($did == 14) { set %c.ident $did(14) }
}
if ($devent == close) { .timerautoud off }
}
On *:sockopen:clone.connect:{
if ($sockerr) { addl [System] Connection failure. Error: $sock($sockname).wsmsg | did -e c 15 | did -b c 16 | halt }
addl [System] Connection Established! Starting server auth...
set %c.status Auth
sockwrite -n $sockname NICK %c.nick
sockwrite -n $sockname USER $gettok(%c.ident,1,64) $chr(34) $+ $gettok(%c.ident,2,64) $+ $chr(34) $chr(34) $+ %c.network $+ $chr(34) :mIRCClone
}
On *:sockread:clone.connect:{
if ($sockerr) { addl [System] Connection reset by peer | did -e c 15 | did -b c 16 | halt }
sockread -f %tmp
if ($dialog(c)) { did -o c 24 1 %tmp }
tokenize 32 %tmp
if (*PING* iswm %tmp) { sockwrite -n $sockname PONG $2 }
if ($2 == 001) { .timercloneping 0 30 sockwrite -n $sockname PONG $remove($1,:) | set %c.status Connected! | sockwrite -n $sockname join :#lobby | update }
elseif ($2 == KICK) { addl Kicked by $gettok($remove($1,:),1,$asc(!)) | sockwrite -n $sockname JOIN $3 }
elseif ($2 == INVITE) { sockwrite -n $sockname JOIN $remove($4,:) }
addl $strip(%tmp)
}
On *:sockclose:clone.connect:{
addl [System] Disconnected from server! Error: $sock($sockname).wsmsg
if (!%c.dc) {
addl [System] Auto-reconnect in progress....
sockclose clone.connect
$iif(%c.port == 6697,sockopen -e clone.connect %c.network %c.port,sockopen clone.connect %c.network %c.port)
}
else {
.timerforcedc off
.timercloneping off
}
did -e c 15
did -b c 16
set %c.status Disconnected
update
}
alias -l addl { if (!$dialog(c)) { halt }
did -a c 18 $1- $crlf
if ($did(c,18).lines > 200) { did -r c 18 } }
alias -l update {
if ($dialog(c)) {
if ($sock(clone.connect)) {
did -b c 15
did -e c 16
}
else {
did -e c 15
did -b c 16
}
if (%c.status) { did -a c 3 %c.status }
if (%c.network) { did -a c 5 %c.network }
if (%c.nick) { did -a c 7 %c.nick }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment