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.

!say script

Old posts that have not been replied to for several years.
Locked
b
bratt
Voice
Posts: 4
Joined: Tue Jul 05, 2005 6:03 am

!say script

Post by bratt »

hi need help with this script that is intent to make a bot say something in channel by using the trigger !say #chan <text>

the script seems to be bugged or has a mistake because when i do the command it says it to the channel its commanded in rather than the channel its meant to.

the auth part just means the script i have for a user to auth to be able to use the command

Code: Select all

# Says something on any channel
# Usage: !say <chan> <what>
proc pub:say {nick host hand chan arg} {
	global botnick
	if {![auth:check $hand]} {return 0}
	if {[llength $arg] < 2} {
		notice $nick "Usage: !say <chan> <what>"
		return 0
	}
	set thechan [lindex $arg 0]
	set what [lrange $arg 1 end]
	if {![onchan $botnick $thechan]} {
		notice $nick "I'm not on that channel."
		return 0
	}
	puthelp "PRIVMSG $chan :$what"
	notice $nick "Said to $thechan: $what"
	putcmdlog "<<$nick>> !$hand! ($thechan) !say $what"
thanx in advance
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

Code: Select all

puthelp "PRIVMSG $thechan :$what"
However, it will exploit with braces and brackets.

Use this code instead

Code: Select all

set thechan [lindex [split $arg] 0]
set what [lrange [split $arg] 1 end]
b
bratt
Voice
Posts: 4
Joined: Tue Jul 05, 2005 6:03 am

Post by bratt »

cheers metroid i tried that and it seems to be doing the same
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

Well it shouldn't.

Maybe you forgot something, here is the fixed code:

Code: Select all

# Says something on any channel
# Usage: !say <chan> <what>
proc pub:say {nick host hand chan arg} {
   global botnick
   if {![auth:check $hand]} {return 0}
   if {[llength $arg] < 2} {
      notice $nick "Usage: !say <chan> <what>"
      return 0
   }
   set thechan [lindex [split $arg] 0]
   set what [lrange [split $arg] 1 end]
   if {![onchan $botnick $thechan]} {
      notice $nick "I'm not on that channel."
      return 0
   }
   puthelp "PRIVMSG $thechan :$what"
   notice $nick "Said to $thechan: $what"
   putcmdlog "<<$nick>> !$hand! ($thechan) !say $what" 
b
bratt
Voice
Posts: 4
Joined: Tue Jul 05, 2005 6:03 am

Post by bratt »

cheers
Locked