egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

User Interaction example

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
terryd
Voice


Joined: 27 Dec 2005
Posts: 5

PostPosted: Sun Jan 01, 2006 1:11 pm    Post subject: User Interaction example Reply with quote

I have been looking for an example of catching user input.
For example it !test
what is your name
The user replies joe
How to catch that reply which i could then write to a file or what ever.
Just and example or a pointer would be most helpfull

Cheers Terry.
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Sun Jan 01, 2006 10:57 pm    Post subject: Reply with quote

generally, you catch user's output via [bind pubm] on channel or [bind msgm] on private

if you need to track the response of a particular user on a particular question, you need to implement a mechanism for associating user's nick with his/her response; the obvious and natural way of doing that is using Tcl associative array:

Code:

bind pubm - * getname
bind pub - !ask askname
proc askname {n u h c t} {
   putserv "privmsg $c :$t, what's your name?"
   set n [string tolower $t]
   set ::name($n) asked
}
proc getname {n u h c t} {
   set n [string tolower $n]
   if [info exists ::name($n)] {
      puthelp "privmsg $c :$n's name is $t"
      unset ::name($n)
   }
}


so, when you type !ask goober, the bot will output "goober, what's your name?", then upon first response from goober the bot will react with "goober's name is <response>"
_________________
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code
Back to top
View user's profile Send private message Visit poster's website
KrzychuG
Master


Joined: 16 Aug 2003
Posts: 306
Location: Torun, Poland

PostPosted: Mon Jan 02, 2006 7:57 am    Post subject: Reply with quote

I also have a question about some interaction with user but on party-line. How to force bot o leave party-line for some time and create a diffrent "channel" only with that one user.

For example:
user type a command, let it be ".register". Bot ask him directly "your username". User type what he want. Then bot ask him for "serial number", and again user type something. Then bot check if everything is OK, send proper reply and finish whole procedure.

I know that i can do it like this: ".register username serial" but i want some interaction ;)
_________________
Que?
Back to top
View user's profile Send private message Visit poster's website
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Mon Jan 02, 2006 12:54 pm    Post subject: Reply with quote

well, on the party line it's even easier since you have dedicated communication channel with that user which you access by its DCC sock index

of course, before proceeding with any interactive action, you need to seize control of that index by using [control], in order to be able to capture user's input
_________________
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code
Back to top
View user's profile Send private message Visit poster's website
KrzychuG
Master


Joined: 16 Aug 2003
Posts: 306
Location: Torun, Poland

PostPosted: Mon Jan 02, 2006 1:01 pm    Post subject: Reply with quote

Could you post some example?
_________________
Que?
Back to top
View user's profile Send private message Visit poster's website
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Mon Jan 02, 2006 1:27 pm    Post subject: Reply with quote

Code:

set idx [hand2idx goober]
putdcc $idx "Username:"
control $idx foo
proc foo {idx text} {
   if ![info exists ::response(username)] {
      set ::response(username) $text
      putdcc $idx "Authorization code:"
   } {
      set ::response(authcode) $text
      return 1 ;# yield control to eggdrop
   }
}

_________________
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber