You've already forked nyx
mirror of
https://github.com/rls-moe/nyx
synced 2025-08-19 06:18:38 +00:00
Images/Non-images post work, several bug fixes, UI fixes
This commit is contained in:
@@ -16,3 +16,7 @@ func getID() (int, error) {
|
||||
id, err := fountain.NewID()
|
||||
return int(id), err
|
||||
}
|
||||
|
||||
func DateFromId(id int) time.Time {
|
||||
return time.Unix(int64(fountain.IDToUnix(id)), 0).UTC()
|
||||
}
|
@@ -10,12 +10,13 @@ import (
|
||||
)
|
||||
|
||||
type Reply struct {
|
||||
ID int `json:"id"`
|
||||
Text string `json:"text"`
|
||||
Image []byte `json:"image"`
|
||||
Thread int `json:"thread"`
|
||||
Board string `json:"board"`
|
||||
Metadata Metadata `json:"meta"`
|
||||
ID int `json:"id"`
|
||||
Text string `json:"text"`
|
||||
Image []byte `json:"image"`
|
||||
Thumbnail []byte `json:"thumb"`
|
||||
Thread int `json:"thread"`
|
||||
Board string `json:"board"`
|
||||
Metadata Metadata `json:"meta"`
|
||||
}
|
||||
|
||||
func NewReply(tx *buntdb.Tx, host, board string, thread *Thread, in *Reply, noId bool) error {
|
||||
|
@@ -27,6 +27,10 @@ type Generator struct {
|
||||
now int64
|
||||
}
|
||||
|
||||
func (g *Generator) IDToUnix(id int) int {
|
||||
return (id >> counterLen) + int(g.StartTime)
|
||||
}
|
||||
|
||||
// NewID generates a new, unique snowflake value
|
||||
//
|
||||
// Up to 8192 snowflakes per second can be requested
|
||||
|
@@ -16,6 +16,13 @@ func OperateReplyText(unsafe string) template.HTML {
|
||||
return template.HTML(unsafe)
|
||||
}
|
||||
|
||||
const (
|
||||
passScoreAggressive = 7.1
|
||||
passScoreReactive = 0.65
|
||||
passScoreLimitMin = 0.01
|
||||
passScoreLimitMax = 0.99
|
||||
)
|
||||
|
||||
var (
|
||||
blacklist = []string{
|
||||
"spam",
|
||||
@@ -25,6 +32,8 @@ var (
|
||||
"subscription",
|
||||
"penis",
|
||||
"nazi",
|
||||
"beemovie",
|
||||
"bee movie",
|
||||
}
|
||||
)
|
||||
|
||||
@@ -62,7 +71,13 @@ func (b *byteCounter) Write(p []byte) (n int, err error) {
|
||||
}
|
||||
|
||||
func CaptchaPass(spamScore float64) bool {
|
||||
chance := math.Max(0, math.Min(0.65*math.Atan(7.1*spamScore), 0.99))
|
||||
chance := math.Max(
|
||||
passScoreLimitMin,
|
||||
math.Min(
|
||||
passScoreReactive*math.Atan(
|
||||
passScoreAggressive*spamScore,
|
||||
),
|
||||
passScoreLimitMax))
|
||||
take := rand.Float64()
|
||||
fmt.Printf("Chance: %f, Take %f", chance, take)
|
||||
return take > chance
|
||||
|
Reference in New Issue
Block a user