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.

simple request

Old posts that have not been replied to for several years.
Locked
s
seamer

Post by seamer »

i have a small script that i'd like to fix up so the trigger command accepts an argument and process the argument as a user in the channel. so far it looks like this:

set ranhng {
"Let me bow down to thee, Oh magnificent $nick! Dom me, use me with your leet skillz, "
"Yay...another HNG...sigh...you bore me already, "
"You know, if you shut up and listen very very carefully...we can hear your mother calling, "
}

bind pub - !hng dork

proc dork {nick uhost hand chan $rand} {
global ranhng
putchan $chan "[lindex $ranhng [rand [llength $ranhng]]]$hand"; return 0
}

when the script is called (!hng blahblah), i only get myself returned as the victim. what would i do to make the insult against a victim instead of who calls the trigger?
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Code: Select all

proc dork {nick uhost hand chan text} {
  global ranhng
  set idx [rand [llength $ranhng]]
  set line [subst [lindex $ranhng $idx]]
  putchan $chan "$line, $nick"
  return 0
}
Btw, if you want to write a good script, you should choose meaningful names for commands and variables. "Ranhng" and "dork" just aren't cutting it, I'm afraid :)
s
seamer

Post by seamer »

ranhng - random horny net geek
dork - explanatory :wink:
the channel's swamped with the obvious types in question, my bot's already developed an attitude :smile:

thanks for the code :smile:
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Oh, I didn't see the last part. To make it use the argument instead of the caller, add "set nick $text" as the first line.
s
seamer

Post by seamer »

thanks :smile:
took me a while of headscratching to figure out that the new line goes inside the proc :smile:

what if i was to go a step further and have the script check the current channel people and only react if the target's there? tried reading other people's scripts for ideas/working examples, seems to be a lack of uniformity :wink:
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Add this:

if {[lsearch [chanlist $chan $text]] == -1} {return 0}
s
seamer

Post by seamer »

i added the line inside proc dork, when called the bot reports:

Tcl error [dork]: wrong # args: should be "lsearch ?mode? list pattern"

if i put the new line outside proc, bot has a hissyfit, so i'm fairly confident i have it in the right place

Code: Select all

proc dork {nick uhost hand chan text} { 
global ranhng 
if {[lsearch [chanlist $chan $text]] == -1} {return 0}
set nick $text
set idx [rand [llength $ranhng]] 
set line [subst [lindex $ranhng $idx]] 
putchan $chan "$line, $nick" 
return 0 
}
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Oh I messed up.

if {[lsearch [chanlist $chan] $text] == -1} {return 0}

(the ] was in the wrong place)
s
seamer

Post by seamer »

nah, you really didnt mess up :smile: i'm still learning, shoulda picked it up myself

thanks for the help :smile:
Locked