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 

Greetd.tcl help SOLVED

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
tazd
Voice


Joined: 05 May 2011
Posts: 3

PostPosted: Sat May 21, 2011 9:28 am    Post subject: Greetd.tcl help SOLVED Reply with quote

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
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sat May 21, 2011 1:33 pm    Post subject: Reply with quote

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
View user's profile Send private message
doggo
Halfop


Joined: 05 Jan 2010
Posts: 97

PostPosted: Sat May 21, 2011 2:04 pm    Post subject: Reply with quote

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 Wink
_________________
NON geeky!! http://gotcode4u.com/
Back to top
View user's profile Send private message Visit poster's website
tazd
Voice


Joined: 05 May 2011
Posts: 3

PostPosted: Sun May 22, 2011 3:25 am    Post subject: Reply with quote

Thanks got it running just right now
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Sun May 22, 2011 4:34 am    Post subject: Reply with quote

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
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Sun May 22, 2011 9:41 pm    Post subject: Reply with quote

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
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Mon May 23, 2011 1:03 am    Post subject: Reply with quote

True, 'string map' is even better. Forgot all about it. Smile
_________________
Once the game is over, the king and the pawn go back in the same box.
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 -> Scripting Help 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