This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Voice/Devoice on Nickname Change mIRC to TCL

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
D
Dizmo
Voice
Posts: 6
Joined: Fri Apr 01, 2016 2:18 pm

Voice/Devoice on Nickname Change mIRC to TCL

Post by Dizmo »

Hey, I've tried looking for a pre-made TCL script to do what I need it to do however I've managed to 'hit a brick wall'.

The mIRC version is terrible, no wonders as most of it was written by myself. Here is the mIRC version (**IF you only know mIRC scripting and are able to make the script below 'less buggy and annoying (No Such Channel: #CHANNEL), when connected to other networks, then please read the last paragraph of my post):

Code: Select all

on %*:join:#CHAN:{
  if (($left($nick, 1) isupper) && ($left($nick, 1) isalpha)) { .mode #CHAN +v $nick }
}

on *:NICK: {
  if (($left($newnick, 1) isupper) && ($left($newnick, 1) isalpha)) { .mode #CHAN +v $newnick }
  if ($islower($left($newnick,1))) { .mode #CHAN -v $newnick }
}
The script, although buggy and annoyingly spammy, does the following:

Voices users that join a specific channel who have a capitalised first letter of their nick; f.ex Dizmo. The second part of the script devoices (/nick testing123), or voices (/nick Testing123) on nick change.

This applies to all users, even ones that are opped, or in this case (InspIRCd); users with +vho +ao of +q.

The reason for the script: When users are 'active' they change their nicks from 'test' to 'Test' and thus get voice. I tried to write this in TCL but got so annoyed by myself that I didn't only give up, I also deleted the script; so I can't even prove that I've tried to do it.

I hate asking people to write scripts and certainly can't afford to pay for someone to write the script for me, however, if my next suggestion* isn't breaking 'egghelp.org's' rules then I'm good if you are.

* I can host an eggdrop or bnc for free (not really sure how long for, at least a month). If said eggdrop/bnc is to be on QuakeNET then you'll have to give me time to get a trust set up. ** If you're happy to make this mIRC script better then I will offer an eggdrop/bnc for free for a duration (not sure how long for).

Thank you in advance, I really appreciate it.
Regards,
Dizmo.

P.S I also have a web hosting company so I may be willing to offer discount hosting/free hosting (with limits). Nothing is free in this life :)
s
simo
Revered One
Posts: 1070
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

try this for your mirc code i added putmode so it would do like +vvvv nick1 nick2 nick3 nick4 in 1 line in the case of multi users joining so it wont spam channel with multi lines of +v for each nick :

Code: Select all

On ^*:join:#:{
  if ($nick(#,$me,@&~%)) {
    if (($left($nick, 1) isupper) && ($left($nick, 1) isalpha)) { putmode -t0 $chan +v $nick }
  }
}
 
ON ^*:nick:{
  haltdef
  var %VoiceFirstCAP = 1
  while ( $comchan($newnick,%VoiceFirstCAP) != $null )  {
    var %chan1 $v1
    if ($nick(%chan1,$me,@&~%)) {
      if (($left($newnick, 1) isupper) && ($left($newnick, 1) isalpha)) { putmode -t0 %chan1 +v $newnick }
      if ($islower($left($newnick,1))) { putmode -t0 %chan1 -v $newnick }
    }
    inc %VoiceFirstCAP
  }
  halt
}


Alias putmode {
  if (!$isid) {
    var %echo = !echo -acq $+ $iif($active == Status Window,e) info *
    var %strict = $true
    if ($left($1,1) == -) {
      if (f isincs $1) %strict = $false
      if (t isincs $1) !.echo -q $regex(putmode,$1,/t(\d*)/)
      tokenize 32 $2-
    }
    if ($2 == $null) %echo /putmode: insufficient parameters
    else {
      var %name = putmode. $+ $cid $+ . $+ $1
      if (!$timer(%name)) {
        hadd -m %name index -1
        hadd -m %name current 0
        hadd -m %name strict $iif(%strict,$true,$false)
        ; deze $ifmatch,0) is normaal $ifmatch,1400)
        !.timer $+ %name -m 0 $iif($regml(putmode,1) isnum,$ifmatch,0) putmode.exec $cid $1
        !.echo -q $regex(putmode,reset,/reset/)
      }
      hinc -m %name index
      hadd -m %name $hget(%name,index) $2-
    }
  }
}
 
alias putmode.exec {
  var %name = putmode. $+ $1 $+ . $+ $2, %parameter, %parameters, %tmp, $&
    %index = $hget(%name,current), %subindex, %modestring, %prefix, $&
    %parmrequired = $remove($gettok($chanmodes,1-2,44),44) $+ $nickmode, $&
    %parmrequiredset = $gettok($chanmodes,3,44), %string, %substring, %operator
  while ($hget(%name,%index) <= $hget(%name,index)) {
    %string = $ifmatch
    %subindex = 1
    while (%subindex <= $len($gettok(%string,1,32))) {
      %substring = $mid(%string,%subindex,1)
      %parameter = $gettok(%string,2,32)
      if (%substring isin +-) {
        %tmp = %prefix
        %prefix = $ifmatch
        if (%prefix == %tmp) goto loopend
      }
      elseif (%substring isincs %parmrequired || (%substring isincs %parmrequiredset && %prefix == +)) {
        if (%substring isincs $nickmode && $gettok(%string,2,32) !ison $2) goto loopend
        elseif (%substring isincs bhoqv && $hget(%name,strict)) {
          if (%substring === b) && ($chr(33) !isin %parameter) && (@ !isin %parameter) {
            if (%parameter == $null) !.echo -q .
            elseif (. !isin %parameter) %parameter = %parameter $+ !*@*
            else %parameter = *!*@ $+ %parameter
          }
          %operator = $iif(%prefix == -,!) $+ is $+ $replacex(%substring,b,ban,q,owner,o,op,h,hop,v,voice)
          if (%parameter %operator $2) goto loopend
        }
        %parameters = %parameters %parameter
        %string = $gettok(%string,1,32) $gettok(%string,3-,32)
      }
      %modestring = %modestring $+ %substring
      if ($numtok(%parameters,32) == $modespl) {
        if ($me ison $2) || ($me ison $2)  !mode $2 %modestring %parameters
        %string = $mid($gettok(%string,1,32),$calc(%subindex + 1)) $gettok($hget(%name,%index),$calc($modespl + 2) $+ -,32)
        hadd -m %name %index $iif($left(%string,1) !isin +-,%prefix) $+ %string
        goto end
      }
      :loopend
      inc %subindex
    }
    hdel %name %index
    hinc %name current
    inc %index
  }
  if (($me ison $2 || $me ison $2) && $len(%modestring) > 1) {
    !mode $2 %modestring %parameters
    hdel %name %index
  }
  :end
  if ($hget(%name,0).item == 3) putmode.cleanup $1 $2
}
alias putmode.cleanup {
  var %name = putmode. $+ $1 $+ . $+ $2
  !.timer $+ %name off
  hfree -w %name
}

ON *:KICK:#:if ($knick == $me) putmode.cleanup $cid $chan
ON *:PART:#:if ($nick == $me) putmode.cleanup $cid $chan
ON *:DISCONNECT:{ putmode.cleanup $cid *  | echo -at 0,4 *!*...Disconnected...*!*  00,03 $network  }
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Code: Select all

bind join * * case:joined
bind nick * * case:nick

proc case:joined {nick uhost hand chan} {
	# we trigger our special function to do the testing when someone just joined the channel
	case:action $chan $nick
}
	
proc case:nick {nick uhost hand chan newnick} {
	# we trigger our special function to do the testing when someone just changed his nick to a new one
	case:action $chan $newnick
}

proc case:action {chan nick} {
	# check if bot is the one that joined the channel and then check if he's a channel operator (has @)
	if {[isbotnick $nick] || ![botisop $chan]} return
	# we split the nick in sepatate elements (let's call them letters) and grab only the first one
	set letter [lindex [split $nick ""] 0]
	# we test if the letter we previously grabbed is in uppercase (result will be 1) or lowercase (result will be 0)
	set test [string is upper $letter]
	# if the result is 1 then proceed to the next step
	if {$test} {
		# test if the nick isn't already voiced
		if {![isvoice $nick $chan]} {
			# nick isn't already voiced so give him voice (+v)
			pushmode $chan +v $nick
		}
	# the previous test failed thus we do something else in return
	} else {
		# test if nick has voice (+v) on the channel
		if {[isvoice $nick $chan]} {
			# and now we actually remove his voice (+v) status
			pushmode $chan -v $nick
		}
	}
}
Haven't tested this so let me know if doesn't work. :roll: Should do what you asked for. And I don't need anything in return apart a thanks. :)
Once the game is over, the king and the pawn go back in the same box.
D
Dizmo
Voice
Posts: 6
Joined: Fri Apr 01, 2016 2:18 pm

Thank you

Post by Dizmo »

caesar and simo, thank you so much.

You two are legends. The tcl script works a dream :)

You, Sir, are a diamond

Just got to make a profile script now :)
I'm trying to teach myself tcl again so the profile script can wait :) I'm messing around with a database script.
w
willyw
Revered One
Posts: 1196
Joined: Thu Jan 15, 2009 12:55 am

Re: Thank you

Post by willyw »

Dizmo wrote: ...
I'm trying to teach myself tcl again...
This can be helpful:

http://suninet.the-demon.de/


There are others too.
That one is a tutor though, that starts from scratch.
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
D
Dizmo
Voice
Posts: 6
Joined: Fri Apr 01, 2016 2:18 pm

Modifying the Script

Post by Dizmo »

Hey,

I need to add another 'variable' into the script, however I'm a little lost as to how I do it. I'm probably over complicating things again....

I need the bot to not voice Guest***** nicks. I can't just put a return 1 after a variable check (I hope that makes sense, it sort of does, in my head) because of how the script checks the nicks.

It's a shame I can't do a 'if line ABC is positive, go to line ABCDEFG' or similar. I'm sure Q basic works like that - can't remember, it's been so long since I used Qbasic (ah the old days).

I'd appreciate any help.

Regards,
Stuart.
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

You have at least 3 options with using string alone. :)

1. string match - returns 1 for match and 0 otherwise. Example:

Code: Select all

if {[string match "Guest*" $nick]} return
2. String compare (with defining the length of the string we are looking after, in our case 5 cos Guest is 5 characters long) - returns 0 for match and 1 otherwise. Example:

Code: Select all

if {![string compare -length 5 "Guest" $nick]} return
3. string first - return 0 for a match and -1 otherwise. Example:

Code: Select all

if {![string first "Guest" $nick]} return
Pick one of your choice and add it after:

Code: Select all

if {[isbotnick $nick] || ![botisop $chan]} return
if you want to stop the execution if nick matches Guest upon joining the channel.

But if you wish to devoice members that changed their names to Guest123 for instance, you would have to change previous line you picked, let's say you went with string compare, to:

Code: Select all

if {![string compare -length 5 "Guest" $nick]} {
	set test 0
}
and add it after:

Code: Select all

set test [string is upper $letter]
This way we force the previous test that was testing if first letter of the nick is capital letter to actually fail even if it didn't, and remove the voice of the said member if his nick starts with Guest.
Once the game is over, the king and the pawn go back in the same box.
s
simo
Revered One
Posts: 1070
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

in the case of the msl one try this:

Code: Select all

On ^*:join:#:{
  if ($nick(#,$me,@&~%)) {
      if ($regex($nick,/(Guest)/i)) { halt }
    if (($left($nick, 1) isupper) && ($left($nick, 1) isalpha)) { putmode -t0 $chan +v $nick }
  }
}
 
ON ^*:nick:{
  haltdef
  var %VoiceFirstCAP = 1
  while ( $comchan($newnick,%VoiceFirstCAP) != $null )  {
    var %chan1 $v1
    if ($nick(%chan1,$me,@&~%)) {
      if ($regex($newnick,/(Guest)/i)) { halt }
      if (($left($newnick, 1) isupper) && ($left($newnick, 1) isalpha)) { putmode -t0 %chan1 +v $newnick }
      if ($islower($left($newnick,1))) { putmode -t0 %chan1 -v $newnick }
    }
    inc %VoiceFirstCAP
  }
  halt
}
Last edited by simo on Mon Jun 20, 2016 3:06 pm, edited 1 time in total.
D
Dizmo
Voice
Posts: 6
Joined: Fri Apr 01, 2016 2:18 pm

Post by Dizmo »

Thank you for the replies everyone. I've tried adding the following:

Code: Select all

set test [string is upper $letter]
   if {![string compare -length 5 "Guest" $nick]} {
   set test 0
and my script isn't working. Maybe I'm making a stupid mistake, I don't know. I can't see any errors.

Feel free to tell me '**** off' lol. I've just about got my sense of humour left after fighting with this damn script. I'd appreciate further help, however I won't be offended if you've had enough of me - I certainly am fed up of myself.

Regards,
Stuart.
D
Dizmo
Voice
Posts: 6
Joined: Fri Apr 01, 2016 2:18 pm

Post by Dizmo »

Ignore that last post.

For some reason, and I'm lost as to why it wasn't working, the script is now working.

No extra restart, rehash or reload. It just started work :/

Thanks again all.

Regards,
Stuart.
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

The new code should be:

Code: Select all

bind join * * case:joined
bind nick * * case:nick

proc case:joined {nick uhost hand chan} {
   case:action $chan $nick
}
   
proc case:nick {nick uhost hand chan newnick} {
   case:action $chan $newnick
}

proc case:action {chan nick} {
	if {[isbotnick $nick] || ![botisop $chan]} return
	if {![string compare -length 5 "Guest" $nick]} {
		set test 0
	} else {
		set letter [lindex [split $nick ""] 0]
		set test [string is upper $letter]
	}
	if {$test} {
		if {![isvoice $nick $chan]} {
			set mode "+v"
		}
	} else {
		if {[isvoice $nick $chan]} {
			set mode "-v"
		}
	}
	pushmode $chan $mode $nick
}
Once the game is over, the king and the pawn go back in the same box.
Post Reply