Skip to content

Commit c5a0c5a

Browse files
committed
added %sbClient.WebSite & %sbClient.CheckWebSite vars & changed all url references to use them.
rewrote the update check code to use $urlget() re-enabled update checks on mIRC v7.56+
1 parent 4583c4f commit c5a0c5a

1 file changed

Lines changed: 26 additions & 28 deletions

File tree

sbClient.mrc

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
; added sbClient.GetAllNetChannels & sbClient.GetAllChannels, & replaced existing loops with calls to this.
119119
; changed some /scon calls to use -t1 to only send the message if connected.
120120
; reworked the logic when starting a local search when one is already underway.
121+
; rewrote the update check code to work with github
121122
;
122123

123124
alias sbClient.version return 2.26.2
@@ -147,8 +148,8 @@ dialog sbClient_options {
147148
button "Remove", 56, 183 96 45 45, tab 6
148149
button "Request search triggers", 61, 6 146 182 13, tab 6 flat
149150
check "No max results limit for local searches (not recommended)", 66, 10 24 200 8, tab 1
150-
check "Check for a new sbClient version on mIRC start", 71, 10 35 200 8, tab 1 disable
151-
button "Check now", 76, 177 35 54 8, tab 1 flat multi disable
151+
check "Check for a new sbClient version on mIRC start", 71, 10 35 167 8, tab 1
152+
button "Check now", 76, 177 35 54 10, tab 1 flat multi
152153

153154
check "Enable Version response", 110, 10 55 100 11, tab 1
154155

@@ -159,7 +160,7 @@ dialog sbClient_options {
159160

160161
box "sbClient", 81, 8 100 182 40, tab 1
161162
text "Here will be some kind of intro text as soon as I figure out what it will be", 86, 15 110 120 40, tab 1 multi
162-
link "www.dukelupus.com", 91, 68 150 80 8, tab 1
163+
link %sbClient.WebSite, 91, 68 150 150 8, tab 1
163164
check "Group @find results", 96, 10 46 81 8, tab 1
164165

165166
check "Enable Advanced Options", 700, 10 24 100 12, tab 7
@@ -179,6 +180,8 @@ on *:dialog:sbClient_options:init:0: {
179180
if (%sbClient.defreqmethod isnum 100-102) did -c sbClient_options $v1
180181
else did -c sbClient_options 100
181182
if (%sbClient.versionresponse) did -c $dname 110
183+
; version check only works on v7.56+
184+
if ($version < 7.56) did -b $dname 71,76
182185
}
183186
on *:dialog:sbClient_options:sclick:700: {
184187
did $iif($did(700).state,-e,-b) sbClient_options 701-704
@@ -197,7 +200,7 @@ on *:dialog:sbClient_options:sclick:56: {
197200
did -r sbClient_options 51
198201
didtok sbClient_options 51 44 %sbClient.channels
199202
}
200-
on *:dialog:sbClient_options:sclick:91: url -an http://www.dukelupus.com
203+
on *:dialog:sbClient_options:sclick:91: url -an %sbClient.WebSite
201204
on *:dialog:sbClient_options:sclick:76: sbClient.update
202205
on *:dialog:sbClient_options:sclick:96: set %sbClient.groupfind $did(96).state
203206
on *:dialog:sbClient_options:sclick:110: set %sbClient.versionresponse $did(110).state
@@ -268,7 +271,7 @@ ctcp *:TRIGGER:?: {
268271
}
269272
ctcp *:VERSION:?: {
270273
if (!%sbClient.versionresponse) return
271-
if ($network != DejaToons) .ctcpreply $nick VERSION 1,9<<sbClient>> version $sbClient.version by DukeLupus.1,15 Get it from 12,15http://www.dukelupus.com (Modified by Ook)
274+
if ($network != DejaToons) .ctcpreply $nick VERSION 1,9<<sbClient>> version $sbClient.version by DukeLupus.1,15 Get it from 12,15 $+ %sbClient.WebSite (Modified by Ook)
272275
}
273276
dialog sbClient_search {
274277
title "sbClient search dialog"
@@ -709,6 +712,8 @@ alias -l sbClient.CheckVars {
709712
if (!$var(%sbClient.defreqmethod,0)) set %sbClient.defreqmethod 100
710713
if (!$var(%sbClient.ResultsFileRegex,0)) set %sbClient.ResultsFileRegex /^Se(?:arch|ek)\w+?[_\s]results[_\s]for[_\s]/i
711714
if (!$var(%sbClient.ResultsTermsRegex,0)) set %sbClient.ResultsTermsRegex /^(Se(?:arch|ek)\w+?)[_\s]results[_\s]for[_\s](.*)$/i
715+
if (!$var(%sbClient.WebSite,0)) set %sbClient.WebSite https://github.com/mIRC-scripts/sbClient
716+
if (!$var(%sbClient.CheckWebSite,0)) set %sbClient.CheckWebSite https://raw.githubusercontent.com/mIRC-scripts/sbClient/refs/heads/master/sbClient.ver
712717
}
713718
on *:load: {
714719
if ($script != $script(1)) .load -rs1 $qt($script)
@@ -779,7 +784,6 @@ on *:filercvd:*results?for*: {
779784
sbClient.ColorNicks %window
780785
; this line sorts window contents by nick
781786
;window -bs %window
782-
;titlebar %window -|- SearchBot results for $qt($right($left($gettok(%r,2,1),-4),-1)) -|- Current channel is %sbClient.SearchChannel -|- rclick for options - r = request file - ctrl-r = req & delete - ctrl-z = find -|-
783787
set %sbClient.string $right($left($gettok(%r,2,1),-4),-1)
784788
titlebar %window -|- SearchBot results for $qt(%sbClient.string) -|- Current channel is %sbClient.SearchChannel -|- rclick for options - r = request file - ctrl-r = req & delete - ctrl-z = find -|-
785789
if (%sbClient.storetxt) {
@@ -856,6 +860,8 @@ on *:start: {
856860
if ($version < 7.46) {
857861
if (!$isalias(comchar)) .enable #sbclient_nocomchar
858862
}
863+
; v7.56 required for $urlget()
864+
if ($version < 7.56) set %sbClient.checkver 0
859865
;
860866
sbClient.CheckVars
861867
sbClient.Cleanup
@@ -889,30 +895,22 @@ alias sbClient.Cleanup {
889895
if (!$sbClient.remove(%f)) sbClient.error Unable to remove %f
890896
}
891897
}
898+
alias sbClient.update.finished {
899+
if ($urlget($1).state != ok) return
900+
var %b = $urlget($1).target
901+
if (!$bvar(%b,0)) return
902+
breplace %b 10 32 13 32
903+
var %t = $bvar(%b,1,100).text
904+
if (($gettok(%t,1,59) == sbClient) && ($gettok(%t,2,59) != $sbClient.version)) {
905+
sbClient.Display You should update sbClient. You are using version $sbClient.version $+ , but version $gettok(%t,2,59) is available from sbClient website at 12 $+ %sbClient.WebSite
906+
}
907+
elseif (($gettok(%t,1,59) == sbClient) && ($gettok(%t,2,59) == $sbClient.version)) {
908+
if ($dialog(sbClient_options)) sbClient.Display You have current version of sbClient
909+
}
910+
}
892911
alias sbClient.update {
893-
return
894-
; the update code is broken
895912
if (!$server) return
896-
sockopen sbClient dukelupus.com 80
897-
}
898-
on *:sockopen:sbClient: {
899-
.sockwrite -n $sockname GET /versions.txt HTTP/1.1
900-
.sockwrite -n $sockname Host: dukelupus.com $+ $crlf $+ $crlf
901-
}
902-
on *:sockread:sbClient: {
903-
if ($sockerr) { .sockclose sbClient | return }
904-
else {
905-
var %t
906-
sockread %t
907-
if (($gettok(%t,1,59) == sbClient) && ($gettok(%t,2,59) != $sbClient.version)) {
908-
sbClient.Display You should update sbClient. You are using version $sbClient.version $+ , but version $gettok(%t,2,59) is available from sbClient website at 12http://www.dukelupus.com
909-
.sockclose sbClient
910-
}
911-
elseif (($gettok(%t,1,59) == sbClient) && ($gettok(%t,2,59) == $sbClient.version)) {
912-
if ($dialog(sbClient_options)) sbClient.Display You have current version of sbClient
913-
.sockclose sbClient
914-
}
915-
}
913+
noop $urlget(%sbClient.CheckWebSite,bge,&sbClientUpdate,sbClient.update.finished)
916914
}
917915
alias F4 { dialog -am sbClient_search sbClient_search }
918916
on *:input:#: {

0 commit comments

Comments
 (0)