| View previous topic :: View next topic |
| Author |
Message |
tazd Voice
Joined: 05 May 2011 Posts: 3
|
Posted: Sat May 21, 2011 9:28 am Post subject: Greetd.tcl help SOLVED |
|
|
What i am trying o achieve is add the needed info to get this script to only announce to those that are give +v in a channel but not to those that are a halfop or above.
This shows what i tried with my limited knowledge and quick scan looking at things but its a no go so was hoping someone here could point me in the right direction.
| Code: | bind mode - '% +h' userhop
set welc(msg) "%nick type !droid in %chan to list of help commands"
set welc(chan) "#channel"
set welc(type) "1"
bind join - #channel* givewelcome
proc givewelcome {nick uhost hand chan} {
global welc
set welctxt $welc(msg)
regsub -all "%nick" $welctxt "$nick" welctxt
regsub -all "%chan" $welctxt "$chan" welctxt
switch $welc(type) {
1 { puthelp "NOTICE $nick :$welctxt" }
2 { puthelp "PRIVMSG $nick :$welctxt" }
}
}
|
Many thanks in advance
Moderated: Moved to Scripting Help.
Placed script-code inside proper tags.
/NML_375
Last edited by tazd on Sun May 22, 2011 3:25 am; edited 1 time in total |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sat May 21, 2011 1:33 pm Post subject: |
|
|
I'd probably add a check somewhat like this:
| Code: | if {[matchattr $hand +v-ho]} {
return
} |
That would make sure the user has the v flag but not the h nor o flag (checking for channel modes +ohv would be rather pointless, since noone will join the channel opped/voiced). _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
doggo Halfop
Joined: 05 Jan 2010 Posts: 97
|
Posted: Sat May 21, 2011 2:04 pm Post subject: |
|
|
| Code: | bind mode * "#nzbmatrix.chat +v" Monkey:voice
proc Monkey:voice {nick uhost hand chan mode target} {
if {$nick != "Monkey"} {return}
putserv "NOTICE $target :type !droid in $chan to list of help commands"
} |
should do what you want tazd  _________________ NON geeky!! http://gotcode4u.com/ |
|
| Back to top |
|
 |
tazd Voice
Joined: 05 May 2011 Posts: 3
|
Posted: Sun May 22, 2011 3:25 am Post subject: |
|
|
| Thanks got it running just right now |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Sun May 22, 2011 4:34 am Post subject: |
|
|
| Quote: |
if {$nick != "Monkey"} {return}
|
You should use 'string equal -nocase' as you will sooner or later find out that for example 'Monkey' isn't equal with 'monkey'.
Also, instead of:
| Quote: |
regsub -all "%nick" $welctxt "$nick" welctxt
regsub -all "%chan" $welctxt "$chan" welctxt
|
you can use 'subst' to get the same result. _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Sun May 22, 2011 9:41 pm Post subject: |
|
|
| caesar wrote: |
Also, instead of:
| Quote: |
regsub -all "%nick" $welctxt "$nick" welctxt
regsub -all "%chan" $welctxt "$chan" welctxt
|
you can use 'subst' to get the same result. |
And as well, you can use [string map] along with [list] instead of curly braces. So instead of all this below: | Code: | set welctxt $welc(msg)
regsub -all "%nick" $welctxt "$nick" welctxt
regsub -all "%chan" $welctxt "$chan" welctxt |
Just do this: | Code: | | set weltxt [string map [list "%nick" "$nick" "%chan" "$chan"] $welc(msg)] |
Using subst most times isn't a clean approach. To me it is akin to regexp and regsub. Only to be used as a last resort. _________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Mon May 23, 2011 1:03 am Post subject: |
|
|
True, 'string map' is even better. Forgot all about it.  _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
|