egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Voice/Devoice on Nickname Change mIRC to TCL

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
Dizmo
Voice


Joined: 01 Apr 2016
Posts: 6

PostPosted: Fri Apr 01, 2016 2:52 pm    Post subject: Voice/Devoice on Nickname Change mIRC to TCL Reply with quote

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:

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 Smile
Back to top
View user's profile Send private message
simo
Master


Joined: 22 Mar 2015
Posts: 226

PostPosted: Fri Apr 01, 2016 4:43 pm    Post subject: Reply with quote

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:
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  }
Back to top
View user's profile Send private message
caesar
Ass Kicker


Joined: 14 Oct 2001
Posts: 3450
Location: Area 51

PostPosted: Sat Apr 02, 2016 4:56 am    Post subject: Reply with quote

Code:

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. Rolling Eyes Should do what you asked for. And I don't need anything in return apart a thanks. Smile
_________________
You may say anything about me, but at least don't misspell my name. xD
Back to top
View user's profile Send private message
Dizmo
Voice


Joined: 01 Apr 2016
Posts: 6

PostPosted: Thu Apr 07, 2016 1:25 am    Post subject: Thank you Reply with quote

caesar and simo, thank you so much.

You two are legends. The tcl script works a dream Smile

You, Sir, are a diamond

Just got to make a profile script now Smile
I'm trying to teach myself tcl again so the profile script can wait Smile I'm messing around with a database script.
Back to top
View user's profile Send private message
willyw
Owner


Joined: 15 Jan 2009
Posts: 957

PostPosted: Thu Apr 07, 2016 2:20 am    Post subject: Re: Thank you Reply with quote

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 !
Back to top
View user's profile Send private message
Dizmo
Voice


Joined: 01 Apr 2016
Posts: 6

PostPosted: Sun Jun 19, 2016 6:16 am    Post subject: Modifying the Script Reply with quote

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.
Back to top
View user's profile Send private message
caesar
Ass Kicker


Joined: 14 Oct 2001
Posts: 3450
Location: Area 51

PostPosted: Sun Jun 19, 2016 8:42 am    Post subject: Reply with quote

You have at least 3 options with using string alone. Smile

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

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:

if {![string compare -length 5 "Guest" $nick]} return

3. string first - return 0 for a match and -1 otherwise. Example:
Code:

if {![string first "Guest" $nick]} return

Pick one of your choice and add it after:
Code:

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:

if {![string compare -length 5 "Guest" $nick]} {
   set test 0
}

and add it after:
Code:

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.
_________________
You may say anything about me, but at least don't misspell my name. xD
Back to top
View user's profile Send private message
simo
Master


Joined: 22 Mar 2015
Posts: 226

PostPosted: Sun Jun 19, 2016 7:16 pm    Post subject: Reply with quote

in the case of the msl one try this:


Code:
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
Back to top
View user's profile Send private message
Dizmo
Voice


Joined: 01 Apr 2016
Posts: 6

PostPosted: Sun Jun 19, 2016 8:00 pm    Post subject: Reply with quote

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

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.
Back to top
View user's profile Send private message
Dizmo
Voice


Joined: 01 Apr 2016
Posts: 6

PostPosted: Sun Jun 19, 2016 10:41 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
caesar
Ass Kicker


Joined: 14 Oct 2001
Posts: 3450
Location: Area 51

PostPosted: Mon Jun 20, 2016 1:00 am    Post subject: Reply with quote

The new code should be:
Code:

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
}

_________________
You may say anything about me, but at least don't misspell my name. xD
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber