| View previous topic :: View next topic |
| Author |
Message |
edu Voice
Joined: 29 Oct 2006 Posts: 31
|
Posted: Sat May 12, 2007 2:31 pm Post subject: invite |
|
|
hey guys, I need some help
| Code: |
# Character that will be used before public querries
set edu(cmdchar) "."
# Owner flag:
set edu(flag.owner) "o"
# Voice flag
set edu(flag.voice) "V"
bind pub $edu(flag.owner)|$edu(flag.voice) $edu(cmdchar)invite edu:pub:invite
# .invite <nickname>
proc edu:pub:invite {nickname hostname handle channel text} {
global edu
set text [split $text]
set invite_nickname [join [lrange $text 0 1]]
if {![channel get $channel [censored]]} {
return
}
if {![botisop $channel]} {
putquick "NOTICE $nickname :ERROR: I'm not opped on $channel"
return
}
if {$invite_nickname == ""} {
putquick "NOTICE $nickname :SYNTAX: $edu(cmdchar)invite <nickname>"
return
}
if {[onchan $invite_nickname $channel]} {
putquick "NOTICE $nickname :ERROR: $invite_nickname is already in $channel"
return
}
putquick "INVITE $invite_nickname $channel"
putquick "NOTICE $nickname :*INVITE* $invite_nickname on $channel"
}
|
The things I need are the following 1) .invite [#channel] <nickname> and 2) $botnick invite [#channel] <nickname>
I need you help as soon as possible, please.
PS: please, thanks.
PS2: Sorry for my bad english _________________ Seek the truth |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sat May 12, 2007 3:48 pm Post subject: |
|
|
| Code: | bind pubm n|n * invite:nick
proc invite:nick {nick uhost hand chan arg} {
foreach {a b} [split $arg] {break}
if {[string equal -nocase .invite $a]} {
set cmd .invite
set parm [join [lrange [split $arg] 1 end]]
} elseif {[isbotnick $a] && [string equal -nocase invite $b]} {
set cmd "$::botnick invite"
set parm [join [lrange [split $arg] 2 end]]
}
if {[info exists cmd]} {
if {[scan $parm {%s %s} c n]!=2} {
puthelp "notice $nick :USAGE: $cmd <#chan> <nick>"
return 0
}
puthelp "invite $n $c"
puthelp "notice $nick :Invited $n to $c"
}
} |
Edit: Applied caesar's suggestion  _________________ Follow me on GitHub
- Opposing
Public Tcl scripts
Last edited by Sir_Fz on Sat May 12, 2007 4:01 pm; edited 1 time in total |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Sat May 12, 2007 3:58 pm Post subject: |
|
|
Hi, I see you are using '[lindex [split $arg] 0]' two times and then '[lindex [split $arg] 1]' one time, and I wonder why don't you just:
| Code: |
foreach (foo bar) [split $arg] {break}
|
(if I recall corectly) or even make a variable like:
| Code: |
set split [split $arg]
|
and use 'split' variable instead of splitting it n times. _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sat May 12, 2007 4:02 pm Post subject: |
|
|
Well I didn't apply that since I'm doing the check only once, however I edited the code and applied it; thanks for your suggestion  _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
|