Verison changer

By Dark| on Dec 02, 2010

Found this - edited it alittle bit
xD
Works with all mircs
-note-
i didnt write the WHOLE Code just edited it xD

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

;Sorry people if my sloppy coding caused any trouble to you :(
;Hopefully I wont burn in hell for this...

;#############################################################################
;#                                                                           #
;#  no-DLLs Scripted version changer :)                                      #
;#  version: 1.1.2f build 20040326                                           #
;#                                                                           #
;#  No I dont hate DLLs, I was just kidding. I did this for the fun of it :) #
;#                                                                           #
;#  Author: Spion spion@rjk.edu.mk  (Yes, my mail changed, again)            #
;#  You can find me on Undernet #mirc                                        #
;#                                                                           #
;#############################################################################

;thx : tabo,                           for the aIRC's l33t versions.txt file
;      expl0rer & freeksho,            for testing
;      Sais, zack^, Ymar, tidy_trax    for help in fixing that damn bug.

;changes : 26/03/2004 -
;1) Fixed the nasty timer bug that allowed people to exploit
;   If you still like vchanger after all the fiasco, please
;   upgrade URGENTLY.

;changes : 27/09/2002 -
;1) Nasty dialog bug fixed (ugh :/)
;2) Some stuff optimized.

;changes : 10/09/2002 - 
;1) Minor multi-server problem fixed, thanks to freeksho :)

;changes : 28/08/2002 - 
;1) Big changes. Some scripters using this addon might kill me ;)
;   Now you use identifiers which return the 
;   target/channel/nick/fulladdress/connection ID. Here they are :
;   $vc.target $vc.nick $vc.fulladdress and $vc.cid ... I think its 
;   enough ;) Dunno if the cid one is needed tho. For examples scroll
;   to line 220 or something like that.
;2) Fixed all the ignores bug (I hope.) You still cannot ignore
;   *!*@* tho. :/
;3) It asks you if you want a popup when you load it :)

;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 the CTCP text
;  and instead using $nick $chan $cid etc like in a normal CTCP, you use :
;  $vc.target $vc.nick $vc.chan $vc.fulladdress and $vc.cid 
;}

;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 are ignored, so you will have to script ctcps
;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.
  var %q = $input(Would you like a popup to the menubar? Youll have to type /cversion if you dont add it,40)
  if (%q == $yes) {
    vchanger.s popup 1
  }

}

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
  scid $cid .debug off
  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 (!$1) return 1
  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 -iom 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, while active 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 check stuff ? :)
  if (!$scid(0)) return
  %cid.cnt = $scon(0)
  .ignore -tw * 
  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) 
      }
      ; 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)) { 
        tokenize 32 $ifmatch
        ; ... and if any of these is 1) recieved by the server
        ;                            2) ctcp (contains PRIVMSG and $chr(1) ...
        if ($1 == <-) && ($3 == PRIVMSG) && (** iswm $left($5,2)) && ( == $right($gettok($1-,-1,32),1)) {
          %ctcp = $remove($5-,)
          %addr = $remove($2,:)
          ; ... 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 parameter ctcptext
            ;ok, people might kill me for using /set, BUT ITS NO BIGGIE. :D
            ;These are the variables for the temp. storage of what the identifiers should return.
            set -u0 %vchanger.cid %cid
            set -u0 %vchanger.fulladdress $mid($2,2)
            set -u0 %vchanger.nick $gettok(%vchanger.fulladdress,1,$asc(!))
            set -u0 %vchanger.target $4
            scid %cid 
            .signal -n newctcp $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! :)
  }
}

; Yoll need these when you script ctcps For example $vc.chan will return the channel where 
; the /ctcp went. :D I'm thinking of alias -l to convert them to $chan $target $nick 
; $fulladdress and $cid ... and to make them 100% compatible with your normal CTCP events. 
; I'm even thinking of a script convertor which will convert all your CTCP events to 
; NEWSIGNAL events, and yes, also convert-back the NEWCTCP to CTCP ;)

alias vc.chan return $iif(%vchanger.target ischan,%vchanger.target)
alias vc.target return %vchanger.target
alias vc.nick return %vchanger.nick
alias vc.fulladdress return %vchanger.fulladdress
alias vc.cid return %vchanger.cid

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

alias -l vc.void
on *:SIGNAL:newctcp: {
  ;Mom told me not to mess with timers, but I never listened :(
  ;Fixed that damn bug.
  if ($timer(.CR)) return
  else {
    if (VERSION == $1) .ctcpreply $vc.nick VERSION $new-version-reply
    if (PING == $1) .ctcpreply $vc.nick PING $2-
    if (TIME == $1) .ctcpreply $vc.nick TIME Buy a watch ;)
    if (FINGER == $1) .ctcpreply $vc.nick FINGER Finger yer mom.
    .timer.CR 1 5 vc.void
  }
  echo $color(ctcp) -a $+([,$vc.nick $vc.chan,]) $1-
}

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

menu menubar {
  $iif($vchanger.s(popup),version):cversion
}

dialog vchanger {
  title "Change your version reply [/cversion]"
  size -1 -1 448 130
  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
  check "Menubar popup", 8, 215 102 93 15
  button "OK", 99, 369 98 70 24, ok
}

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
    if ($vchanger.s(popup)) did -c $dname 8
    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
    if ($did == 8) vchanger.s popup $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) && ($devent = sclick) { 
      write $+(",$scriptdiraIRCversions.txt,") $did($dname,4)
      did -r $dname 2
      loadbuf -o $dname 2 $+(",$scriptdiraIRCversions.txt,")
      did -c $dname 2 1
    }
    elseif ($did == 6) && ($devent = sclick) { 
      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
    }
  }
}
;The end. Oh, forgot the /cversion alias ;)

Comments

Sign in to comment.
Dark|   -  Dec 02, 2010

you have to load it
missed that one
xD

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.