egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Spam Question Script

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
ComputerTech
Master


Joined: 22 Feb 2020
Posts: 393

PostPosted: Sat Jan 23, 2021 2:48 am    Post subject: Spam Question Script Reply with quote

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 Smile
_________________
ComputerTech
Back to top
View user's profile Send private message Send e-mail Visit poster's website
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Sat Jan 23, 2021 5:19 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Sat Jan 23, 2021 11:15 am    Post subject: Reply with quote

i would simply use nickserv for that and set channel to +R
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Sat Jan 23, 2021 12:39 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
ComputerTech
Master


Joined: 22 Feb 2020
Posts: 393

PostPosted: Sat Jan 23, 2021 12:40 pm    Post subject: Reply with quote

Yeah, it was actually suppose to be a Spam Question security for a ZNC Request Eggdrop Cool

But thank you CrazyCat for that code, i will try it right away Wink
_________________
ComputerTech
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ComputerTech
Master


Joined: 22 Feb 2020
Posts: 393

PostPosted: Sat Jan 23, 2021 5:36 pm    Post subject: Reply with quote

That worked brilliant CrazyCat, thank you Very Happy
_________________
ComputerTech
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber