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.
Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
ComputerTech
Master
Posts: 399 Joined: Sat Feb 22, 2020 10:29 am
Contact:
Post
by ComputerTech » Sat Jan 23, 2021 2:48 am
So looking for a script that will make the bot generate a random letter/number then ask like this via PM to the user.
Generated code Kwq89fsef
Answer what above code says with !code <answer here>
So to answer in short, i need a script that generates a random letter/number code and asks the user via PM what the above code says and if the user answers the correct code then it passes and it not, it fails
Thanks in advanced
ComputerTech
CrazyCat
Revered One
Posts: 1236 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Sat Jan 23, 2021 5:19 am
You have the random generator @
http://forum.egghelp.org/viewtopic.php?t=20848
just fill an array with it and wait for the answer:
Code: Select all
array set sentcode {}
bind pub o|o "!gencode" gencode
proc gencode {nick uhost handle chan text} {
set args [split $text]
if {[llength $args]!=1} {
putserv "PRIVMSG $nick :usage is !gencode <victim>"
return 1
}
set victim [join [lindex $args 0]]
if {![onchan $victim]} {
putserv "PRIVMSG $nick :Can't find $victim"
return 1
}
set code [randString 8 8]
set ::sentcode([string tolower $victim]) $code
putserv "PRIVMSG $victim :your code is $code"
}
bind pub - "!code" getcode
proc getcode {nick uhost handle chan text} {
set args [split $text]
set victim [string tolower $nick]
if {[llength $args]!=1} {
putserv "PRIVMSG $nick :usage is !code <your code>"
return 1
}
if {![info exists ::sentcode($victim)]} {
putserv "PRIVMSG $nick :I'm not waiting a code from you"
return 1
}
set code [join [lindex $args 0]]
if {$::sentcode($victim) eq $code} {
putserv "PRIVMSG $nick :Ok"
unset ::sentcode($victim)
} else {
putserv "PRIVMSG $nick :Error with the code"
return 1
}
}
# usage : randString <min> <max>
proc randString { {min 1} {max 8} } {
set chars "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
set size [expr {int(rand()*($max-$min+1)+$min)}]
set range [string length $chars]
set txt ""
for {set i 0} {$i < $size} {incr i} {
set pos [expr {int(rand()*$range)}]
append txt [string index $chars $pos]
}
return $txt
}
Feel free to adapt that (not tested, some errors can occure)
simo
Revered One
Posts: 1080 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Sat Jan 23, 2021 11:15 am
i would simply use nickserv for that and set channel to +R
CrazyCat
Revered One
Posts: 1236 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Sat Jan 23, 2021 12:39 pm
simo wrote: i would simply use nickserv for that and set channel to +R
ComputerTech never said it was to access a channel, he said the !code command must pass if codes match, and fail if not.
Nothing seems related to nickserv nor channel access.
ComputerTech
Master
Posts: 399 Joined: Sat Feb 22, 2020 10:29 am
Contact:
Post
by ComputerTech » Sat Jan 23, 2021 12:40 pm
Yeah, it was actually suppose to be a Spam Question security for a ZNC Request Eggdrop
But thank you CrazyCat for that code, i will try it right away
ComputerTech
ComputerTech
Master
Posts: 399 Joined: Sat Feb 22, 2020 10:29 am
Contact:
Post
by ComputerTech » Sat Jan 23, 2021 5:36 pm
That worked brilliant CrazyCat, thank you
ComputerTech