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.

cool !learn funcommands idea

Old posts that have not been replied to for several years.
Locked
C
CosmicD
Op
Posts: 102
Joined: Sat Dec 11, 2004 3:46 pm

cool !learn funcommands idea

Post by CosmicD »

Maybe it exists but it would be cool if i'd had the following:

a "learn" script that can adopt new funcommands.

Like I would tell the bot to "!learn !certainpubliccommand $botnick thinks that $victim is in love with $posternick. <2 args>

it would then correctly learn how to use that new command like it's suppowed to and program it in such a way that the user that's going to use this command has to do 2 arguments, the $victim nick or the nick that places the command ..

the bot would place these new commands in a tcl database or so, and so users can create their own fun commands :) (or onwers, depending of the bind)

I don't know jack about coding really, but it would be cool that those arguements that people could learn to the bot be like $where $what $victim $nick $botnick or something...

PS: errormessages that tell the user when they do something wrong are welcome, like, when they use too many arguments or soemthing like that, or when arguments cant be understood..


Hope that makes sense....
User avatar
^DooM^
Owner
Posts: 772
Joined: Tue Aug 26, 2003 5:40 pm
Location: IronForge
Contact:

Re: cool !learn funcommands idea

Post by ^DooM^ »

CosmicD wrote:Maybe it exists but it would be cool if i'd had the following:

a "learn" script that can adopt new funcommands.

Like I would tell the bot to "!learn !certainpubliccommand $botnick thinks that $victim is in love with $posternick. <2 args>

it would then correctly learn how to use that new command like it's suppowed to and program it in such a way that the user that's going to use this command has to do 2 arguments, the $victim nick or the nick that places the command ..

the bot would place these new commands in a tcl database or so, and so users can create their own fun commands :) (or onwers, depending of the bind)

I don't know jack about coding really, but it would be cool that those arguements that people could learn to the bot be like $where $what $victim $nick $botnick or something...

PS: errormessages that tell the user when they do something wrong are welcome, like, when they use too many arguments or soemthing like that, or when arguments cant be understood..


Hope that makes sense....
You want someone to code this?

That is a rather large request. I doubt very much anyone here has the time or inclination to write such a script.

Your best bet would be to read the TCL Commands Manual and start this script off yourself and ask for help on specific problems you encounter.
The lifecycle of a noob is complex. Fledgling noobs gestate inside biometric pods. Once a budding noob has matured thru gestation they climb out of their pod, sit down at a PC, ask a bunch of questions that are clearly in the FAQ, The Noob is born
C
CosmicD
Op
Posts: 102
Joined: Sat Dec 11, 2004 3:46 pm

Post by CosmicD »

oh well, i was kinda hoping it would exist already :(
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

here's some code to get you started

Post by user »

Code: Select all

bind pub n !addCrap addCrap
proc addCrap {n u h c a} {
	# check for valid lists of arguments
	if {![info complete $a]||![info complete [lindex $a 1]]} {
		puthelp "PRIVMSG $c :$n: that makes no sense to me."
		return
	}
	# check for valid number of arguments
	if {[llength $a]!=3} {
		puthelp "PRIVMSG $c :$n: usage: $::lastbind !newTrigger {argument names enclosed in braces} {message enclosed in braces}"
		return
	}
	# extract trigger, argument list and message
	foreach {trigger args msg} $a break
	# code creating code ain't pretty :P
	set    code "\n"
	append code "	set args \[split \$arg\]\n"
	append code "	if \{\[llength \$args\]!=[llength $args]\} \{\n"
	append code "		puthelp \"PRIVMSG \$chan :\$nick: usage: \$::lastbind $args\"\n"
	append code "		return\n"
	append code "	\}\n"
	if {[llength $args]} {
		append code "	foreach [list $args] \[split \$arg\] break\n"
	}
	append code "	if \[catch \{[list subst -noc $msg]\} msg\] \{\n"
	append code "		puthelp \"PRIVMSG \$chan :\$nick: $h screwed up: \$msg\"\n"
	append code "	\} else \{\n"
	append code "		puthelp \"PRIVMSG \$chan :\$msg\"\n"
	append code "	\}\n"
	# invent a proc name and create bind + proc
	set i -1
	while {[info commands crap[incr i]]!={}} {}
	bind pub - $trigger crap$i
	proc crap$i {nick uhost hand chan arg} $code
}
The usage is a bit different from what you requested: !addCrap trigger {argument list} {message enclosed in braces}
eg:
!addCrap !test0 {} {Hello $nick!}
!addCrap !test1 {victim} {I am testing this thing on $victim}
!addCrap !test2 {victim1 victim2} {\001ACTION slaps $victim1 with $victim2\001}
I didn't test it, so have fun debugging :twisted:
The variables that can be used in the message are: nick, uhost, hand, chan and arg + the names you supply when creating the command.
Have you ever read "The Manual"?
C
CosmicD
Op
Posts: 102
Joined: Sat Dec 11, 2004 3:46 pm

Post by CosmicD »

thx alot, going to try this :)

it works very well for the commands, it seems to not accept if you screw up the accolades and not return any (correct) variables so thats good,

hopefully i'tll survive the translation and my prefference to do every "error message" in notice..

That be done I have a few "debugging info :P"

it would be nice if the bot gives a message back when things are entered succesfully ?

When a command already exists, could you please add a code that tells the user that the command already exists ?

Where are the commands supposed to be saved ? I think it should add the procedures to the addcrap tcl file at the bottom ? but it doesnt do that so my bot forgets the commands when I restart :)

I see the new binds with procs like crap0 en crap1 but they don't appear anything in the tcl, nor do I get any error message about it :(

thx alot already.. youre having a credit message in the help page of that bot :)
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

It was not meant to be a complete script...it was just to give you a starting point...a few clues / ideas...if you plan to make alot of commands, I think it will be better to have all the argument name lists and messages stored in an array and have all the binds invoke a single proc that takes care of the things the now generated procS do. (to avoid having MANY almost exact copies of that lame proc code :P)

To have a message when a command is created, just add it at the end of the proc?

If you deny overwriting ANY existing bind, it will be a pain in the ass when you screw up. I think it would be better to deny overwriting binds not created by your script.

I didn't include the saving part, but that's pretty easy (I think it would be a good idea to have a separate command for that, so you can test the new command first and then decide if you want to keep them.)

Code: Select all

set crapFile "saved.crap"
bind pub n !saveCrap saveCrap

proc saveCrap {n u h c a} {
	foreach {t f k . C} [join [binds pub]] {
		if {$k==$a} {
			set f [open $::crapFile a]
			puts $f [list bind $t $f $k $C]
			puts $f [list proc $C [info args $C] [info body $C]]
			close $f
			puthelp "PRIVMSG $c :$n: saved."
		}
	}
	puthelp "PRIVMSG $c :$n: no such bind."
}
if {[file exists $crapFile]} {source $crapFile}
(not tested)
Have you ever read "The Manual"?
C
CosmicD
Op
Posts: 102
Joined: Sat Dec 11, 2004 3:46 pm

Post by CosmicD »

wow, it kinda saves all the pubs, is it also possible to tighten ? to only save the crap* procs ?

when I do .binds crap* in the dcc chat, it shows all the crap procs that I have , so i wonder why it wont work if i change the binds pub thingy to binds crap* inside the script you provided,

then it says "no such bind" :(

i've got a tcl error where it says args should be binds ?type/mask?

when I type binds pub/crap? it doesnt work, what am i doing wrong ? :(

if i just execute the script like you wrot it, it first says "saved" and then "no such binds so thatsweird

when i go look in the file i see all kinds of variables of only certain procs starting with pub_ but not really the ones i need...

when doing .binds crap* inside dcc chat, i get all the crap procs that are there, why doesn't it save ?
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Add "return" below the "saved" message to get rid of the "no such bind" message and add this little snippet above the line opening the file:

Code: Select all

if {![string match {crap[0-9]*} $C]} {puthelp "PRIVMSG $c :$n: nope."; return}
...and you probably want to delete the file to get rid of all the other procs you've saved
Have you ever read "The Manual"?
C
CosmicD
Op
Posts: 102
Joined: Sat Dec 11, 2004 3:46 pm

Post by CosmicD »

OK, i have now:

and I try to save, and it always says "nope" :) and nothing is being saved. if i leave the file out only one proc that I have called pub_cd is being saved

Code: Select all

set crapFile "melissa.fun"
bind pub n !saveCrap saveCrap

proc saveCrap {n u h c a} {
   foreach {t f k . C} [join [binds pub]] {
    if {$k==$a} {
    if {![string match {crap[0-9]*} $C]} {puthelp "PRIVMSG $c :$n: nope."; return}
    set f [open $::crapFile a]
         puts $f [list bind $t $f $k $C]
         puts $f [list proc $C [info args $C] [info body $C]]
         close $f
         puthelp "PRIVMSG $c :$n: saved."
         return
       }
   }
   puthelp "PRIVMSG $c :$n: no such bind."
}
if {[file exists $crapFile]} {source $crapFile}
there seems to be going on something weird.. you know when i view the saved file with the previous script, it would be savind procs with the name pub* ... theres only one like that..

it would be like i wouold do in dcc .binds pub* , but not really getting the types but the procs... hope that makes sens

I'll never be a programming genious because I don't even understand lots of the structures , so, can anyone help ?
C
CosmicD
Op
Posts: 102
Joined: Sat Dec 11, 2004 3:46 pm

Post by CosmicD »

user wrote:I think it will be better to have all the argument name lists and messages stored in an array and have all the binds invoke a single proc that takes care of the things the now generated procS
*nods clueless head*.. I'll always be a programming newbie, never got the hang of any langueg excep a bit of pirch scripting a long time ago... :P
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

CosmicD wrote:it would be like i wouold do in dcc .binds pub* , but not really getting the types but the procs... hope that makes sens
That's weird...sounds like you moved a "}" in the save proc or something - or I am really tired and incapable of reading my own code :P
Anyway...I'm bored with this topic, so you'll have to wait and see if anyone else feels like making this script for you :)
Have you ever read "The Manual"?
C
CosmicD
Op
Posts: 102
Joined: Sat Dec 11, 2004 3:46 pm

Post by CosmicD »

lol, i can understand :P its a good script though, i guess i'll find something or someone :P
Locked