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.

Reply to the command

Help for those learning Tcl or writing their own scripts.
Post Reply
s
slowpoke23
Voice
Posts: 5
Joined: Sun Feb 10, 2013 5:17 am

Reply to the command

Post by slowpoke23 »

OK so I have the following code, How can I make it reply to say !getaops #ChaNneL2 when its set as #channel2 in the script

And if its not set to #Channel3 and someone does !getaops #channel3 can it return a error?

bind pub n !getaops get_aops
proc get_aops {nick uhost hand chan text} {
global botnick

set aop [lindex $text 0]
if {$aop == "#channel2"} {
putserv "privmsg $chan :omg the ops for this channel are name name2"
}
}
User avatar
Madalin
Master
Posts: 310
Joined: Fri Jun 24, 2005 11:36 am
Location: Constanta, Romania
Contact:

Post by Madalin »

Ok so every use can use !getaops #channel2 (if any user uses this command but instead of #channel2 he add something else he will receive another message)

Removed the part where only admins can use this command

Code: Select all

bind pub - !getaops get_aops

proc get_aops {nick uhost hand chan text} {


	set aop [lindex [split $text] 0]
	if {$aop == "#channel2"} {
		putserv "PRIVMSG$chan :omg the ops for this channel are name name2"
	} else {
		putserv "PRIVMSG $chan :valid command !getaops #channel2"
	}
}
s
slowpoke23
Voice
Posts: 5
Joined: Sun Feb 10, 2013 5:17 am

Post by slowpoke23 »

Hi, Thanks.

I plan on having a few channels on this script like #chan1 #chan2 #lobby #help #network etc so I'm not sure how it'd be done that way?
User avatar
Madalin
Master
Posts: 310
Joined: Fri Jun 24, 2005 11:36 am
Location: Constanta, Romania
Contact:

Post by Madalin »

Well if you want different messages for every !getaops i recommand this script http://forum.egghelp.org/viewtopic.php?t=19313
It allows you to create !getaops for every channel but with different reply messages
So you would do something like this

First activate the script on every channel you want it working
!trigger activate
Then create teh !getaops command
!trigger getaops Aops are: .. .. ..
And now any user could use in the channel command
!getaops
I think its simple beside what you have. But if you prefer i can modify that script to work on more channel yet it will be harder for you to look at the code and modify the text later or add other channels
s
slowpoke23
Voice
Posts: 5
Joined: Sun Feb 10, 2013 5:17 am

Post by slowpoke23 »

Hmm that script could become handy but !getaops will only be available in one channel which will be a chanops channel.. so i don't think !trigger etc will be any help :(

I appreciate your help!
User avatar
Madalin
Master
Posts: 310
Joined: Fri Jun 24, 2005 11:36 am
Location: Constanta, Romania
Contact:

Post by Madalin »

Ok well the code should look like
So if you want something more please reply

Code: Select all

bind PUB - !getaops getaops:pub

set temp(#channel1) "text text text"
set temp(#channel2) "some other text"

proc getaops:pub {nick uhost hand chan arg} {
	global temp

	set who [lindex [split $arg] 0]

	if {[string match "#*" $who] && [info exists temp($who)]} {
		putserv "PRIVMSG $chan :$temp($who)"
	} else {
		set list ""
		foreach a [array names temp] { lappend list $a }

		putserv "PRIVMSG $chan :Valid channels are: [join $list ", "]"
	}
}
s
slowpoke23
Voice
Posts: 5
Joined: Sun Feb 10, 2013 5:17 am

Post by slowpoke23 »

Thank you!! That is what I'm after pretty much ! :)

Just one minor problem if you don't mind helping just a little bit more..

[20:00:58] <%SUme> !getaops #ChaNnel2
[20:01:00] <&Botes> Valid channels are: #channel1, #channel2
[20:01:04] <%SUme> lulz


Is there any way it if someone did say #ChaNnel2 it will reply back with #channel2 info?
User avatar
Madalin
Master
Posts: 310
Joined: Fri Jun 24, 2005 11:36 am
Location: Constanta, Romania
Contact:

Post by Madalin »

Ok this should work.
Yet i tell you to keep

set temp(#channel-name) with lowercases then after on the channel users can use whatever they want like #ChaNNel-Name it would still work

Code: Select all

bind PUB - !getaops getaops:pub

set temp(#channel1) "text text text"
set temp(#channel2) "some other text"

proc getaops:pub {nick uhost hand chan arg} {
	global temp

	set who [lindex [split $arg] 0]

	if {[string match "#*" $who] && [info exists temp([string tolower $who])]} {
		putserv "PRIVMSG $chan :$temp($who)"
	} else {
		set list ""
		foreach a [array names temp] { lappend list $a }

		putserv "PRIVMSG $chan :Valid channels are: [join $list ", "]"
	}
}
Test it and tell me if its working
Post Reply