| View previous topic :: View next topic |
| Author |
Message |
ComputerTech Master

Joined: 22 Feb 2020 Posts: 393
|
Posted: Mon Jun 08, 2020 5:08 am Post subject: Info Collector Script |
|
|
Hey all so i am looking for a script that does the following
| Code: |
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
appreciate all who help  _________________ ComputerTech |
|
| Back to top |
|
 |
ComputerTech Master

Joined: 22 Feb 2020 Posts: 393
|
Posted: Tue Jun 09, 2020 7:26 pm Post subject: |
|
|
so simo helped me with a nice script
| Code: |
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  _________________ ComputerTech |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Wed Jun 10, 2020 1:07 am Post subject: |
|
|
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: |
if {[string tolower $chan] ne [string tolower $::eTxFile(chan)]} { return }
|
why not go with string equal that's already built in:
| Code: |
if {![string equal -nocase $chan $::eTxFile(chan)]} { return }
|
Edit: If you want to somewhat validate the e-mails I'd use something like:
| Code: |
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. |
|
| Back to top |
|
 |
ComputerTech Master

Joined: 22 Feb 2020 Posts: 393
|
Posted: Wed Jun 10, 2020 7:02 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
ComputerTech Master

Joined: 22 Feb 2020 Posts: 393
|
Posted: Wed Jun 10, 2020 1:37 pm Post subject: |
|
|
alright so i figured a random password script, now just need to add the valid email line
and this
| Quote: |
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  _________________ ComputerTech |
|
| Back to top |
|
 |
Operator873 Voice

Joined: 10 Jun 2020 Posts: 1 Location: DFW, TX
|
Posted: Thu Jun 11, 2020 12:11 am Post subject: |
|
|
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: |
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..." |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Thu Jun 11, 2020 1:45 am Post subject: |
|
|
| Code: |
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. |
|
| Back to top |
|
 |
ComputerTech Master

Joined: 22 Feb 2020 Posts: 393
|
Posted: Thu Jun 11, 2020 5:55 am Post subject: |
|
|
Look's awesome will try it after lunch, thanks so much caesar your help is always appreciated  _________________ ComputerTech |
|
| Back to top |
|
 |
ComputerTech Master

Joined: 22 Feb 2020 Posts: 393
|
Posted: Thu Jun 11, 2020 9:18 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Thu Jun 11, 2020 10:54 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
ComputerTech Master

Joined: 22 Feb 2020 Posts: 393
|
Posted: Thu Jun 11, 2020 12:46 pm Post subject: |
|
|
so just leave the email line out? _________________ ComputerTech |
|
| Back to top |
|
 |
|