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.

Info Collector Script

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Info Collector Script

Post by ComputerTech »

Hey all so i am looking for a script that does the following

Code: Select all

guest types !request

bot pms user asking 3 questions  username,password,email

user pms bot username,password,email

bot then saves that username,password,email into a text file
and thats all :D

appreciate all who help :D
ComputerTech
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

so simo helped me with a nice script

Code: Select all

    set eTxFile(file) {/home/computertech/tech/scripts/add.txt}
    
    bind pub -|- !request pub:register
    proc pub:register {nick uhost hand chan text} {
       if {[scan $text {%s%s%s} user password email] != 3} {
          putserv "notice $nick :usage: !request user password email"
          return
       }
    if {[string tolower $chan] ne [string tolower $::eTxFile(chan)]} { return }
      set tf $::eTxFile(file)
      if {![file exists $tf]} {
        puthelp "notice $nick :Text file does not exist: $tf"
        return
      }
      puthelp "notice $nick :You Have Requested A Bnc/Znc, This the info you provided $text "
      set id [open $tf a]
      puts $id $text
      close $id
      return 
    }
so now all i need is this one thing
instead of users typing openly !request username password email

i would like them to type it into the private message of the bot
And Not /msg botnick username password email
but rather the bot will pm the user saying what to do then the user will type !request username password email

would bind msg do for this? because i tried it but it only seems to work when i did /msg botnick message :roll: :roll:
ComputerTech
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

The putserv "notice $nick part is responsible for where is the message going to be sent and in what format. In this given example it will be sent to $nick as a notice. If you want to make it a private message (PM) then change 'notice' into 'privmsg'.

You need to alter the code so the '!request' part only sends out that private message to the person issuing the command on the channel and make a new function that would listen on a 'bind msg' to do the actual recording that is done at the moment inside the public !request one.

I would honestly generate a random password and tell the user to change it after he/she connects to Bnc/Znc.

Instead of the double 'string to lower':

Code: Select all

if {[string tolower $chan] ne [string tolower $::eTxFile(chan)]} { return } 
why not go with string equal that's already built in:

Code: Select all

if {![string equal -nocase $chan $::eTxFile(chan)]} { return } 
Edit: If you want to somewhat validate the e-mails I'd use something like:

Code: Select all

regexp {[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?} $mail
that will return 0 for invalid and 1 for valid e-mail address.
Once the game is over, the king and the pawn go back in the same box.
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

Ah, i like both of your idea's,
the email one i will add right away.

the random password one, hmm not to sure how to do it.
ComputerTech
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

alright so i figured a random password script, now just need to add the valid email line ;)

and this

You need to alter the code so the '!request' part only sends out that private message to the person issuing the command on the channel and make a new function that would listen on a 'bind msg' to do the actual recording that is done at the moment inside the public !request one.
but if course if you would like to add a password generator that would be awesome also, caesar. mine might not be that a good heh :roll:
ComputerTech
User avatar
Operator873
Voice
Posts: 1
Joined: Wed Jun 10, 2020 10:24 pm
Location: DFW, TX
Contact:

Post by Operator873 »

Hello ComputerTech.

I built this largely based on the scripts already written for you. It includes a random password generator. It looks like there is some of this conversation I can't see so I may be missing something.

Anyway, I tested it and it works well. I borrowed randomRangeString from the TCLers Wiki

Code: Select all

bind pub -|- "!request" pub:register

proc randomRangeString {length {chars "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"}} {
    set range [expr {[string length $chars]-1}]

    set txt ""
    for {set i 0} {$i < $length} {incr i} {
       set pos [expr {int(rand()*$range)}]
       append txt [string range $chars $pos $pos]
    }
    return $txt
}

proc pub:register {nick uhost hand chan text} {
	if {[scan $text {%s%s} user email] != 2} {
		putserv "NOTICE $nick :usage: !request user email"
		return
	}

	set newPass [randomRangeString 16]
	set newUser [lindex [split $text] 0]
	set newEmail [lindex [split $text] 1]
		
	puthelp "NOTICE $nick :You Have Requested A Bnc/Znc. Username is: $newUser / Your email is: $newEmail."
	puthelp "NOTICE $nick :Your temporary password is: $newPass"
	
	set outFile [open /home/computertech/tech/scripts/add.txt {RDWR CREAT APPEND}]
	puts $outFile "$newUser $newEmail $newPass"
	close $outFile
	return
}
Edit: changed my file location to yours
"Hello Darkness, my old friend..."
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Code: Select all

proc randPass {len {min 33} {max 125}} {
	return [subst [string repeat {[format %c  [expr int(rand()*($max-$min+1)) + $min]]} $len]]
}

bind pub -|- !request pub:request
	
proc pub:request {nick uhost hand chan text} {
	if {[scan $text {%s%s} user email] != 2} {
		putserv "NOTICE $nick :usage: !request user email"
		return
	}
	set pass [randPass 10]
	puthelp "NOTICE $nick :You have requested a Bnc/Znc with the info that you provided: username: $user, e-mail: $email. A random password \002$pass\002 was generated for you that you should change later." 
	set fh [open "/home/computertech/tech/scripts/add.txt" "a+"]
	puts $fh "$user $email $pass"
	close $fh
}
This generates a password from the ASCII table from element 33 ("!" symbol) up to 125 ("}" symbol). You can change the range by telling randPass the min and the max it should grab and generate from the ASCII table.

If the file doesn't exist then it will be created (empty file) and the initial access position will be set to the end of the file.
Once the game is over, the king and the pawn go back in the same box.
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

Look's awesome will try it after lunch, thanks so much caesar your help is always appreciated :D
ComputerTech
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

Oh and Hey there Operator873 welcome to the eggdrop forum, and thank you very much for your script i appreciate it. :) seems good to me ;)

and caesar your script worked awesome as usual your work never fails thanks again i'll post a final version of the script, with the valid email line ;)
ComputerTech
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

No problem.

The e-mail validator isn't quite fool proof cos has a problem with domain names, would be too much of a hassle to make it fully functional.
Once the game is over, the king and the pawn go back in the same box.
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

so just leave the email line out?
ComputerTech
Post Reply