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

Joined: 22 Feb 2020 Posts: 393
|
Posted: Sat Jan 23, 2021 2:48 am Post subject: Spam Question Script |
|
|
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 |
|
| Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1032 Location: France
|
Posted: Sat Jan 23, 2021 5:19 am Post subject: |
|
|
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: | 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) _________________ https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community. |
|
| Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Sat Jan 23, 2021 11:15 am Post subject: |
|
|
| i would simply use nickserv for that and set channel to +R |
|
| Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1032 Location: France
|
Posted: Sat Jan 23, 2021 12:39 pm Post subject: |
|
|
| 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. _________________ https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community. |
|
| Back to top |
|
 |
ComputerTech Master

Joined: 22 Feb 2020 Posts: 393
|
Posted: Sat Jan 23, 2021 12:40 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
ComputerTech Master

Joined: 22 Feb 2020 Posts: 393
|
Posted: Sat Jan 23, 2021 5:36 pm Post subject: |
|
|
That worked brilliant CrazyCat, thank you  _________________ ComputerTech |
|
| Back to top |
|
 |
|