Skip to content

Commit 30b658a

Browse files
authored
Merge pull request #7 from OokEek/master
update code rewrite
2 parents f224eb3 + c5a0c5a commit 30b658a

2 files changed

Lines changed: 54 additions & 60 deletions

File tree

sbClient.mrc

Lines changed: 53 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,14 @@
114114
; added advanced options to dialog (atm this only allows setting the regex pattern)
115115
; 2.26.1
116116
; changes made to WhereIs bot accounted for.
117+
; 2.26.2
118+
; added sbClient.GetAllNetChannels & sbClient.GetAllChannels, & replaced existing loops with calls to this.
119+
; changed some /scon calls to use -t1 to only send the message if connected.
120+
; reworked the logic when starting a local search when one is already underway.
121+
; rewrote the update check code to work with github
117122
;
118123

119-
alias sbClient.version return 2.26.1
124+
alias sbClient.version return 2.26.2
120125

121126
; Ook: added shortcut for dll
122127
alias sbClientdll return $dll($scriptdirsbClient.dll,$1,$2-)
@@ -143,8 +148,8 @@ dialog sbClient_options {
143148
button "Remove", 56, 183 96 45 45, tab 6
144149
button "Request search triggers", 61, 6 146 182 13, tab 6 flat
145150
check "No max results limit for local searches (not recommended)", 66, 10 24 200 8, tab 1
146-
check "Check for a new sbClient version on mIRC start", 71, 10 35 200 8, tab 1 disable
147-
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
148153

149154
check "Enable Version response", 110, 10 55 100 11, tab 1
150155

@@ -155,7 +160,7 @@ dialog sbClient_options {
155160

156161
box "sbClient", 81, 8 100 182 40, tab 1
157162
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
158-
link "www.dukelupus.com", 91, 68 150 80 8, tab 1
163+
link %sbClient.WebSite, 91, 68 150 150 8, tab 1
159164
check "Group @find results", 96, 10 46 81 8, tab 1
160165

161166
check "Enable Advanced Options", 700, 10 24 100 12, tab 7
@@ -168,22 +173,15 @@ on *:dialog:sbClient_options:init:0: {
168173
sbClient.CheckVars
169174
if (%sbClient.storetxt == 1) did -c sbClient_options 26
170175
if (%sbClient.groupfind == 1) did -c sbClient_options 96
171-
var %cnter = 1
172-
while (%cnter <= $scon(0)) {
173-
scon %cnter
174-
var %cnter2 = 1
175-
while ($chan(%cnter2) != $null) {
176-
did -a sbClient_options 31 $+($v1,@,$network)
177-
inc %cnter2
178-
}
179-
inc %cnter
180-
}
176+
didtok sbClient_options 31 44 $sbClient.GetAllChannels
181177
didtok sbClient_options 51 44 %sbClient.channels
182178
if (%sbClient.nomax == 1) did -c sbClient_options 66
183179
if (%sbClient.checkver == 1) did -c sbClient_options 71
184180
if (%sbClient.defreqmethod isnum 100-102) did -c sbClient_options $v1
185181
else did -c sbClient_options 100
186182
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
187185
}
188186
on *:dialog:sbClient_options:sclick:700: {
189187
did $iif($did(700).state,-e,-b) sbClient_options 701-704
@@ -202,7 +200,7 @@ on *:dialog:sbClient_options:sclick:56: {
202200
did -r sbClient_options 51
203201
didtok sbClient_options 51 44 %sbClient.channels
204202
}
205-
on *:dialog:sbClient_options:sclick:91: url -an http://www.dukelupus.com
203+
on *:dialog:sbClient_options:sclick:91: url -an %sbClient.WebSite
206204
on *:dialog:sbClient_options:sclick:76: sbClient.update
207205
on *:dialog:sbClient_options:sclick:96: set %sbClient.groupfind $did(96).state
208206
on *:dialog:sbClient_options:sclick:110: set %sbClient.versionresponse $did(110).state
@@ -251,6 +249,19 @@ alias sbClient.GetNetworkID {
251249
inc %cnter
252250
}
253251
}
252+
alias sbClient.GetAllNetChannels {
253+
var %i = 1, %c = $1
254+
while ($chan(%i) != $null) {
255+
var %c = $addtok(%c,$+($v1,@,$network),44)
256+
inc %i
257+
}
258+
return %c
259+
}
260+
alias sbClient.GetAllChannels {
261+
var %c
262+
scon -a var % $+ c = $!sbClient.GetAllNetChannels(%c)
263+
return %c
264+
}
254265
ctcp *:TRIGGER:?: {
255266
if ($($+(%,sbClient.,$3,@,$2,.requested),2) == 1) {
256267
set $+(%,sbClient.,$3,@,$2,.trigger) $4
@@ -260,7 +271,7 @@ ctcp *:TRIGGER:?: {
260271
}
261272
ctcp *:VERSION:?: {
262273
if (!%sbClient.versionresponse) return
263-
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)
264275
}
265276
dialog sbClient_search {
266277
title "sbClient search dialog"
@@ -286,17 +297,7 @@ on *:dialog:sbClient_search:init:0: {
286297
if (%sbClient.menu.local) did -c sbClient_search 10
287298
if (%sbClient.menu.channel) did -c sbClient_search 11
288299
if (%sbClient.find.channel) did -c sbClient_search 25
289-
var %cnter = 1, %channels
290-
while (%cnter <= $scon(0)) {
291-
scon %cnter
292-
var %cnter2 = 1
293-
while ($chan(%cnter2) != $null) {
294-
var %channels = $addtok(%channels,$+($v1,@,$network),44)
295-
inc %cnter2
296-
}
297-
inc %cnter
298-
}
299-
didtok sbClient_search 21 44 %channels
300+
didtok sbClient_search 21 44 $sbClient.GetAllChannels
300301
did -c sbClient_search 21 %sbClient.last2
301302
}
302303
on *:dialog:sbClient_search:close:0: {
@@ -323,11 +324,9 @@ on *:dialog:sbClient_search:sclick:1: {
323324
if ($did(10).state) {
324325
; do local search
325326
if (%sbClient.searching == 1) {
326-
if ($input(Local search seems to be already active. Do you want to stop active local search and start your current search?,yqd,Local search is active) == $true) {
327-
sbClientdll Stop 1
328-
set %sbClient.searching 0
329-
}
330-
else return
327+
if ($input(Local search seems to be already active. Do you want to stop active local search and start your current search?,yqd,Local search is active) != $true) return
328+
sbClientdll Stop 1
329+
set %sbClient.searching 0
331330
if ($did(11).state) goto chansearch
332331
}
333332
if (!%sbClient.ListFolder) {
@@ -346,7 +345,7 @@ on *:dialog:sbClient_search:sclick:1: {
346345
if ($did(25).state) {
347346
.set -u600 %sbclient.searchactive 1
348347
.set -u600 %DLF.searchactive 1
349-
scon $sbClient.GetNetworkID($did(21).seltext) msg $sbClient.GetChannel($did(21).seltext) @find %sstring
348+
scon -t1 $sbClient.GetNetworkID($did(21).seltext) msg $sbClient.GetChannel($did(21).seltext) @find %sstring
350349
}
351350
if ($did(11).state) {
352351
if (!$did(20).seltext) { sbClient.error No channel selected! | return }
@@ -466,9 +465,9 @@ alias -l sbClient.SendToAutoGet {
466465
if (!%lines) return
467466

468467
var %path = $nofile($script(AutoGet.mrc))
469-
.fopen MTlisttowaiting $+(",%path,AGwaiting.ini,")
468+
.fopen MTlisttowaiting $+(",%path,AGwaiting.ini")
470469
if ($fopen(MTlisttowaiting).err) return
471-
.fseek -l MTlisttowaiting $lines($+(",%path,AGwaiting.ini,"))
470+
.fseek -l MTlisttowaiting $lines($+(",%path,AGwaiting.ini"))
472471
if ($fopen(MTlisttowaiting).err) return
473472
var %i = 1, %j = 0
474473
while (%i <= %lines) {
@@ -713,6 +712,8 @@ alias -l sbClient.CheckVars {
713712
if (!$var(%sbClient.defreqmethod,0)) set %sbClient.defreqmethod 100
714713
if (!$var(%sbClient.ResultsFileRegex,0)) set %sbClient.ResultsFileRegex /^Se(?:arch|ek)\w+?[_\s]results[_\s]for[_\s]/i
715714
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
716717
}
717718
on *:load: {
718719
if ($script != $script(1)) .load -rs1 $qt($script)
@@ -749,8 +750,7 @@ alias sbClient.Check {
749750
}
750751
alias sbClient.DoSearch {
751752
if (!$($+(%,sbClient.,$1,.trigger),2)) halt
752-
scon $sbClient.GetNetworkID($1)
753-
msg $sbClient.GetChannel($1) $($+(%,sbClient.,$1,.trigger),2) $2-
753+
scon -t1 $sbClient.GetNetworkID($1) msg $sbClient.GetChannel($1) $($+(%,sbClient.,$1,.trigger),2) $2-
754754
}
755755
on *:filercvd:*results?for*: {
756756
var %resultdir = $+($mircdir,SearchBot results), %fn = $nopath($filename)
@@ -784,7 +784,6 @@ on *:filercvd:*results?for*: {
784784
sbClient.ColorNicks %window
785785
; this line sorts window contents by nick
786786
;window -bs %window
787-
;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 -|-
788787
set %sbClient.string $right($left($gettok(%r,2,1),-4),-1)
789788
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 -|-
790789
if (%sbClient.storetxt) {
@@ -861,6 +860,8 @@ on *:start: {
861860
if ($version < 7.46) {
862861
if (!$isalias(comchar)) .enable #sbclient_nocomchar
863862
}
863+
; v7.56 required for $urlget()
864+
if ($version < 7.56) set %sbClient.checkver 0
864865
;
865866
sbClient.CheckVars
866867
sbClient.Cleanup
@@ -894,30 +895,22 @@ alias sbClient.Cleanup {
894895
if (!$sbClient.remove(%f)) sbClient.error Unable to remove %f
895896
}
896897
}
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+
}
897911
alias sbClient.update {
898-
return
899-
; the update code is broken
900912
if (!$server) return
901-
sockopen sbClient dukelupus.com 80
902-
}
903-
on *:sockopen:sbClient: {
904-
.sockwrite -n $sockname GET /versions.txt HTTP/1.1
905-
.sockwrite -n $sockname Host: dukelupus.com $+ $crlf $+ $crlf
906-
}
907-
on *:sockread:sbClient: {
908-
if ($sockerr) { .sockclose sbClient | return }
909-
else {
910-
var %t
911-
sockread %t
912-
if (($gettok(%t,1,59) == sbClient) && ($gettok(%t,2,59) != $sbClient.version)) {
913-
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
914-
.sockclose sbClient
915-
}
916-
elseif (($gettok(%t,1,59) == sbClient) && ($gettok(%t,2,59) == $sbClient.version)) {
917-
if ($dialog(sbClient_options)) sbClient.Display You have current version of sbClient
918-
.sockclose sbClient
919-
}
920-
}
913+
noop $urlget(%sbClient.CheckWebSite,bge,&sbClientUpdate,sbClient.update.finished)
921914
}
922915
alias F4 { dialog -am sbClient_search sbClient_search }
923916
on *:input:#: {

sbClient.ver

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sbClient;2.26.2

0 commit comments

Comments
 (0)