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.

Help with msg prompts

Old posts that have not been replied to for several years.
Locked
T
TheElite

Post by TheElite »

Hi, I was wondering if anyone would like to give me suggestions on how I would do a prompt system. For instance, someone would message the bot saying !create or whatever. It would then prompt for thier name, they would enter it. Then it would continue with other prompts.
I looked at a previous post about waiting for user input... but from what I could tell the control function is only for DCC chats.
User avatar
CrazyCat
Revered One
Posts: 1306
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

why don't you enable binds after each commande?
bind pub - "!create" tcl:create

proc tcl:create {nick uhost handle chan arg } {
your procedure.....
bind msg - "new command" tcl:next
}

proc tcl:next {nick uhost handle arg} {
unbind msg - "new command"
your proc ....
bind ...
}
T
TheElite

Post by TheElite »

Because they aren't new commands... it's whatever the user sends to the bot next gets put into a temp variable and then gets written to a file. There are about five or six prompts before it gets written to the file. I guess I could bind it to a different custom flag so when a user with a flag of, let's say, A types anything it'll get put into the variable to be written. But so far, I havn't had any luck with custom flags either...

Code: Select all

bind pub C !startduel startduel

proc startduel {nick uhost hand chan text} {
  global duel_p1 duel_p2
  set duel_p1 $nick
  set duel_p2 [string range $text 0 [string wordend $text 0]]
  putmsg $chan "blah $duel_p1 $duel_p2"
}
Doesn't even get into that function (procedure... whatever /me == C++ guy) :grin:
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Use a global array to keep track of the state of each person, and another array to keep track of what they said so far.

Add in code to check nick changes, parts, quits, kicks, to keep the arrays updated.

You could also make it non-linear, so that they can answer in whatever order they want, as long as they start with !create and end with !done or something.

Code: Select all

bind pub !create - on_create
bind pub !name - on_name

proc on_create {nick uhost hand chan text} {
  global state
  set state($nick) 1
  putserv "privmsg $chan :Okay, now type !name <blah> to set your name"
}

proc on_name {nick uhost hand chan text} {
  global state answers
  if {![info exists state($nick)]} {
    putserv "privmsg $chan :You have to use !create first"
    return 0
  }
  if {$state($nick) > 1} {
    putserv "privmsg $chan :You already entered your name, fool"
    return 0
  }
  putserv "privmsg $chan :Good job, now type !baa <noise> to set your favorite animal noise."
  lappend answers($nick) $text
  set state($nick) 2
}
T
TheElite

Post by TheElite »

Thanks, I guess I'll just do it that way.
Any help with the user-defined flags though?
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

User defined flags are just like built-in ones:

chattr handle +ABCDEFG

bind pub A !hello blah
T
TheElite

Post by TheElite »

Yeah, I know that much... but in the previous post, as you see, I did that, I've double checked that my global flags include a C and they do... but I still can't get that procedure to work...
Locked