2022-06-24 23:09:46 +04:00
|
|
|
package captcha
|
|
|
|
|
|
|
|
import (
|
|
|
|
"image"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
var captchaDb CaptchaDB = CaptchaDB{
|
|
|
|
DB: make(map[ID]ICaptcha)}
|
|
|
|
|
|
|
|
func Init(expiration time.Duration) {
|
|
|
|
captchaDb.SetExpiration(expiration)
|
|
|
|
}
|
|
|
|
|
|
|
|
func New(data string, captcha ICaptcha) (ICaptcha, ID) {
|
|
|
|
return captchaDb.New(data, captcha)
|
|
|
|
}
|
|
|
|
|
|
|
|
func Image(id ID) (*image.Image, error) {
|
|
|
|
return captchaDb.Image(id)
|
|
|
|
}
|
|
|
|
|
|
|
|
func Solve(id ID, answer Answer) (bool, error) {
|
|
|
|
return captchaDb.Solve(id, answer)
|
|
|
|
}
|
|
|
|
|
|
|
|
func IsSolved(id ID) (bool, error) {
|
|
|
|
return captchaDb.IsSolved(id)
|
|
|
|
}
|
2022-06-26 15:46:23 +04:00
|
|
|
|
|
|
|
func GetExpireInterval() time.Duration {
|
|
|
|
return captchaDb.ExpireInterval
|
|
|
|
}
|