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.

Recruitment Questions script

Old posts that have not been replied to for several years.
Locked
a
almighty
Voice
Posts: 30
Joined: Tue Jan 07, 2003 5:34 pm
Contact:

Recruitment Questions script

Post by almighty »

People enter the channel and if they type the command !recruit the bot notices the person with a question or a few questions.
The the person can answer the question and when they have done so the bot gives the person the next question in line. The answer is stored in a file somewhere. This carrys on for a few questions until they get to the end, where all the answers get emailed to a email address.
I have the following so far, I know its not much, but i was stuck on how to do this next bit.

Code: Select all

putlog "Loading Recruitment Script by Almighty"

bind join *|* * msg_join 
bind pub - !recruit pub:recruit

proc msg_join {nick host hand chan} {
putserv "NOTICE $nick :Welcome to We Are Now Kings, for the recruitment questions use !recruit. Enjoy your stay!"
}
proc pub:recruit {nick uhost hand chan args} {
global botnick
putserv "NOTICE $nick :------\002Recruitment Questions for We Are Now Kings: \002---------"
putserv "NOTICE $nick :FIRST QUESTION HERE"
putserv "NOTICE $nick :INSERT QUESTIONS HERE"
}
Can anyone shine some light on this for me?
http://www.big-bubba.co.uk
Big Brother Clone for the South West
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

For starters, shouldn't you send them privmsg's instead of notices? That way they can type in the query window.

You need a msgm bind to listen for the answers (I assume you want them to message the bot privately, otherwise use pubm.) Bind on * so you get every line. Now, you probably need a global variable to keep track of "state information" such as what questions have been asked, etc. So, when they type recruit, you set the state variable for that person to be "question 1" or whatever. You send them question 1. In the handler for msgm, whenever you get a message, you check to see if that person's state variable is set. If it is, you record the line to some file (maybe $nick.answers) and ask the next one. To be a little nicer, you could have them type whatever they want and type "next" to signify an end to their answer, unless all your questions are one-liners.

For instance, say the global is called state. It's an array. $state($nick) will say what question the person is answering. If $state($nick) isn't set, the person hasn't typed !recruit yet.

That should give you some idea. For tcl commands, check out www.tcl.tk/man
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Have you ever read "The Manual"?
a
almighty
Voice
Posts: 30
Joined: Tue Jan 07, 2003 5:34 pm
Contact:

Post by almighty »

yea i changed it to privmsg i just pasted in the older code,
thanks for the info and link.
http://www.big-bubba.co.uk
Big Brother Clone for the South West
a
almighty
Voice
Posts: 30
Joined: Tue Jan 07, 2003 5:34 pm
Contact:

Post by almighty »

Ok, using that other thread, i have come up with this:

Code: Select all

....
proc recruit:msgm {nick uhost hand args} { 
   global surveyQ surveyA 
   if {[info exists surveyA($uhost)]} { 
      lappend surveyA($uhost) $args 
      if {[llength $surveyA($uhost)]<[llength $surveyQ]} { 
         # there are more questions to be asked... 
         putserv "PRIVMSG $nick :[lindex $surveyQ [llength $surveyA($uhost)]]" 
      } { 
         # completed 
         putserv "PRIVMSG $nick :We're done. Now go away!" 
exec echo "$nick has answered the recruitment questions at [date] [time] foreach q $surveyQ a $surveyA($uhost) { \"Q: $q\" \"A: $a\" } " | sendmail mail@emailhere.co.uk
         putlog "$nick has answered the recruitment questions:" 
         foreach q $surveyQ a $surveyA($uhost) { 
            putlog "Q: $q" 
            putlog "A: $a" 
         } 
....
I have missed out the other parts as those are working fine.
I get this error

Code: Select all

Tcl error [recruit:msgm]: can't read "q": no such variable
I know what this means, but i want to be able to email the answers to the email address, not just a confirmation, how would i go about doing this?[/code]
http://www.big-bubba.co.uk
Big Brother Clone for the South West
User avatar
Rusher2K
Halfop
Posts: 88
Joined: Fri Apr 18, 2003 10:45 am
Location: Germany
Contact:

Post by Rusher2K »

When you want to send e-mails have al look @

http://www.egghelp.org/cgi-bin/tcl_arch ... oad&id=108

Allows you to send e-mails through the bot.
User avatar
]Kami[
Owner
Posts: 590
Joined: Thu Jul 24, 2003 2:59 pm
Location: Slovenia
Contact:

Post by ]Kami[ »

Hehe, i made similar scripts for clan :) one for memebr one for wars etc..and one which contains all :)
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

almighty wrote:i want to be able to email the answers to the email address, not just a confirmation, how would i go about doing this?
Passing the input directly to exec is dangerous. To avoid having to figure out what chars to escape and how, you could write the body of the mail to a file and 'exec cat the_file | sendmail bla@bla.bla'

Code: Select all

...
# completed
putserv "PRIVMSG $nick :We're done. Now go away!" 
putlog "$nick has answered the recruitment questions:"
set f [open tmp.file w]
puts $f "$nick has answered the recruitment questions at [date] [time]\n"
foreach q $surveyQ a $surveyA($uhost) { 
	putlog "Q: $q"
	putlog "A: $a"
	puts $f "Q: $q"
	puts $f "A: $a"
}
close $f
exec cat tmp.file | sendmail mail@emailhere.co.uk
file delete tmp.file
...
...OR you could 'open |sendmail bla@bla.bla' and puts directly to the mailer process, but that might not work with the sendmail binary...I don't have one to try it with atm.
Have you ever read "The Manual"?
Locked