2022-06-24 23:09:46 +04:00
|
|
|
package captcha
|
|
|
|
|
|
|
|
import (
|
|
|
|
"image"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
var captchaDb CaptchaDB = CaptchaDB{
|
|
|
|
DB: make(map[ID]ICaptcha)}
|
|
|
|
|
2022-06-26 20:53:48 +04:00
|
|
|
func Init(expiry time.Duration) {
|
|
|
|
captchaDb.SetExpiry(expiry)
|
2022-06-24 23:09:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
2022-06-26 20:53:48 +04:00
|
|
|
func GetExpiry() time.Duration {
|
|
|
|
return captchaDb.ExpireIn
|
2022-06-26 15:46:23 +04:00
|
|
|
}
|