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.

invite

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
e
edu
Voice
Posts: 31
Joined: Sun Oct 29, 2006 2:10 pm

invite

Post by edu »

hey guys, I need some help

Code: Select all

# 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
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

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 :)
Last edited by Sir_Fz on Sat May 12, 2007 4:01 pm, edited 1 time in total.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

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: Select all

foreach (foo bar) [split $arg] {break}
(if I recall corectly) or even make a variable like:

Code: Select all

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.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

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 :wink:
Post Reply