mIRC version changer

mIRC version changer

mIRC Snippet that change the version reply for your mirc script. You need to create two files with message replyes: vchanger.dat and aIRCversions.txt

Postat de Copyright Categorie Review user Vizualizari Data
btc eyes toolbar Cod testat 574 2023-12-28 13:23:55

;... if you dont wanna read... TYPE /cversion

;#############################################################################
;#                                                                           #
;#  no-DLLs Scripted version changer :)                                      #
;#  version: 1.01 build 20020214                                             #
;#                                                                           #
;#  Yes, I hate DLLs.                                                        #
;#                                                                           #
;#  Author: eyes (now - Spion) spion@programmer.net                          #
;#  You can find me on Undernet or Fluxnet ( fluxnet.org )                   #
;#                 Undernet : #mircscripts.org or #mirc                      #
;#                 Fluxnet  : #irc_help #cservice or #zt                     #
;#                                                                           #
;#                                                                           #
;#  This wont work on anything else except mIRC 6+ !!! You were warned :)    #
;#                                                                           #
;#############################################################################

;thx : tabo, for the aIRC's l33t versions.txt file

;changes : 17/02/2002 - 
;1) its now removing ":"
;2) optimized, dialog-ed, popup added
;3) ignore and windows bugs fixed, 
;4) changed "motfv" with "vchanger"

;Usage: 

;on *:SIGNAL:newctcp: {
;  respond-to-ctcps
;  where $1- contains:
;  connectionid nick!user@host target :ctcptext
;  Let me explain again:
;  $1 is connection id
;  $2 is nick!user@host (to get nick only use $gettok($2,1,$asc(!))
;  $3 is the target
;  $4 is the ctcp text, for example "VERSION"
;}

;or just change the next line... 
alias my-new-version-reply return mIRC $version Khaled Mardam-Bay +script my l33t script.


;Or, just type /cversion

;Note that ALL CTCPs replies are ignored, so you will have to script
;them using this new SIGNAL event. Read below for more info

;type "/vchanger 1" to enable it (use 0 or no parameters to disable)

;new: Ive just tested it, its pretty fast on my PII 450 (I can't even notice the difference)
;CTCP ignores should work fine, I did a workarround to make it possible :)
;But... the standard CTCP replies are disabled, you will have to recode
;them to SIGNAL events.

;Allright, here is the code.


;########################################################################################


on *:LOAD: {
  echo -a *** Version changer addon loaded.
  echo -a *** Read vchanger.txt for more info.
}

alias new-version-reply { 
  if ($vchanger.s(random)) return $read($+(",$scriptdiraIRCversions.txt,"))
  else { return $iif($vchanger.s(version),$ifmatch,$my-new-version-reply) }
}

#ondisconnectnstart on
; Makes sure it doesnt get disabled:
on *:DISCONNECT:{ 
  .timer -io 1 0 vchanger 1
  window -c $+(@verch.,$cid)
}
; Makes sure it runs on start
on *:START:{ vchanger 1 | vchanger.s -s }
#ondisconnectnstart end

alias vchanger.s { 
  if (!$hget(vchanger.s)) { hmake vchanger.s 10 | .timer 1 0 vchanger.s myown 1 }
  if ($isfile($+(",$scriptdirvchanger.dat,"))) && ($hget(vchanger.s,myown) == $null) { 
    hload -bo vchanger.s $+(",$scriptdirvchanger.dat,")
  }
  if ($isid) return $hget(vchanger.s,$$1)
  else { 
    if ($1 == -s) hsave -bo vchanger.s $+(",$scriptdirvchanger.dat,")
    else { hadd vchanger.s $$1 $2- }
  }
}

alias vchanger {
  ; if the first parameter exists and is not "0" ...
  if ($1) {
    ; see above.
    .enable #ondisconnectnstart
    ; Activate the timer that checks for queued CTCPs. 
    ; You can modify the timer time, but I think 300 miliseconds is ok.
    .timer..vchanger -om 0 300 vchanger.checkctcps
  }
  else {
    .disable #ondisconnectnstart
    .timer..vchanger off
    var %cid = 1, %cid.cnt = 0
    if (!$scid(0)) return
    while (%cid.cnt < $scid(0)) {
      if ($scid(%cid)) { inc %cid.cnt 
        ; turns off DEBUG and ignores for all connections. 
        ; Yes, we /ignore everything and monitor raw server data,
        ; thats how we get CTCPs, but not reply versions.
        scid %cid 
        .debug off
        .ignore -rtw *!*@*
        window -c $+(@verch.,%cid)
      }
      inc %cid 
    }  
  }
}

on *:UNLOAD: { 
  ; In case you load this as an addon (Id rather say its a snippet)
  ; we need to make sure it doesnt do bad stuff after beeing unload.
  .remove $scriptdirvchanger.dat
  hfree -w vchanger.s
  vchanger
  echo -s *** Unloaded the version changer addon.
}

alias vchanger.ignore { 
  ; This alias is a trick to keep the normal ignore list avaible, by ignoring the *!*@*
  ; CTCP ignore that we set, and still keep an eye the other ignores when checking for queued CTCPs
  ; It temporarly unignores *!*@* and it sets a fast timer to turn it back ON, then returns the normal
  ; ignore as it would appear if we dont have a *!*@* ignore. Cool eh? :)
  if ($ignore(*!*@*)) { .ignore -rtw *!*@* | .timer 1 0 scid $cid .ignore -tw *!*@* | return $ignore($1-).type }
  else { return $ignore($1-).type } 
}


; This alias checks for queued CTCPs

alias vchanger.checkctcps {
  var %cid = 1, %cid.cnt = 0, %tmpwin, %i, %line, %ctcp, %addr, %verch
  ;If we are not connected to a server, why checking stuff ? :)
  if (!$scid(0)) return
  %cid.cnt = $scon(0)
  while (%cid.cnt) {
    %cid = $scon(%cid.cnt)
    dec %cid.cnt
    if ($scid(%cid)) { 
      ; If the window that fills with queues (each network has its own) is not open...it opens it
      if (!$window($+(@verch.,%cid))) { 
        window -h $+(@verch.,%cid) 
        scid %cid .debug $+(@verch.,%cid) 
        scid %cid .ignore -tw * 
      }
      ; make sure debug is on for the network... and *!*@* ctcp ignore is on
      %verch = @verch. $+ %cid
      %i = 1
      ;now, we check all queued lines in the window... 
      while ($line(%verch,%i)) { 
        %line = $ifmatch
        ; ... and if any of these is 1) recieved by the server
        ;                            2) ctcp (contains PRIVMSG and $chr(1) ...
        if ($gettok(%line,1,32) == <-) && ($gettok(%line,3,32) == PRIVMSG) && ( ** iswm $left($gettok(%line,5,32),2) ) && ( == $right($gettok(%line,-1,32),1)) {
          %ctcp = $remove($gettok(%line,5-,32),)
          %addr = $remove($gettok(%line,2,32),:)
          ; ... but not an ACTION - and there is noone in the ignore list matching the address...
          if (*ctcp* !iswm $vchanger.ignore(%addr)) && (*ACTION !iswm $gettok(%ctcp,1,32)) {
            ; ... sends a NEWCTCP signal :) 
            ; with the paramteres : connectionID nick!user@host target ctcptext
            scid %cid .signal newctcp %cid %addr $gettok(%line,4,32) $mid(%ctcp,2)
          }
        }
        inc %i
      }
      ;Clears the queue: we dont want to check the same lines again.
      clear %verch
    }
    elseif ($window($+(@verch.,%cid))) { window -c $+(@verch.,%cid) }
    ;If we got disconnected from the server, we should close the unneeded queue window! :)
  }
}

;Well, I did it for you, you dont need to script the version reply and other stuff :

on *:SIGNAL:newctcp: {
  if (VERSION == $4) scid $1 .ctcpreply $gettok($2,1,$asc(!)) VERSION $new-version-reply
  if (PING == $4) scid $1 .ctcpreply $gettok($2,1,$asc(!)) PING $5-
  if (TIME == $4) scid $1 .ctcpreply $gettok($2,1,$asc(!)) TIME $fulldate
  if (FINGER == $4) scid $1 .ctcpreply $gettok($2,1,$asc(!)) FINGER $emailaddr Idle $duration($idle)
  echo $color(ctcp) -s $+([,$gettok($2,1,$asc(!))) $+($4,]) $iif($4 != PING,$5-)
}

;Someone said I should make a dialog and a popup, well there you go.

menu menubar {
  Change Version:/cversion
}

dialog vchanger {
  title "Change your version reply [/cversion]"
  size -1 -1 448 130
  button "OK", 99, 369 98 70 24, ok
  radio "or choose one from the list : ", 1, 8 48 146 18
  combo 2, 9 67 432 123, size drop
  radio "Type your version reply :", 3, 8 7 146 14
  edit $new-version-reply, 4, 8 24 431 23, autohs
  button "Add", 5, 9 99 50 22
  button "Del", 6, 58 99 50 22
  check "Random reply", 7, 121 102 93 15
}

on *:DIALOG:vchanger:*:*: {
  if ($devent == init) {
    if ($vchanger.s(myown)) did -c $dname 3
    else { did -c $dname 1 }
    if ($vchanger.s(random)) did -c $dname 7
    loadbuf -o $dname 2 $+(",$scriptdiraIRCversions.txt,")
    did -c $dname 2 1
  }
  else {
    if ($did == 3) vchanger.s myown 1
    if ($did == 7) vchanger.s random $did($dname,$did).state
    elseif ($did == 1) { vchanger.s myown 0 }
    if ($did == 99) vchanger.s -s
    if ($did($dname,1).state == 1) { 
    vchanger.s version $did($dname,2).text }
    else { vchanger.s version $did($dname,4).text }
    if ($did == 5) { 
      write $+(",$scriptdiraIRCversions.txt,") $did($dname,4)
      did -r $dname 2
      loadbuf -o $dname 2 $+(",$scriptdiraIRCversions.txt,")
      did -c $dname 2 1
    }
    elseif ($did == 6) { 
      var %tmp = $read($+(",$scriptdiraIRCversions.txt,"), s, $did($dname,2)) | write $+(-dl,$readn) $+(",$scriptdiraIRCversions.txt,")
      did -r $dname 2
      loadbuf -o $dname 2 $+(",$scriptdiraIRCversions.txt,")
      did -c $dname 2 1
    }
  }
}

alias cversion dialog -ma vchanger vchanger