Less wrong Freya mode, I hope

This commit is contained in:
Ben Visness 2024-05-14 09:40:05 -05:00
parent ac54793fd0
commit 23b1b30d22
1 changed files with 21 additions and 17 deletions

View File

@ -33,33 +33,35 @@ var autostoreChannels = []string{
}
func HandleIncomingMessage(ctx context.Context, dbConn db.ConnOrTx, msg *Message, createSnippets bool) error {
handled := false
if handled, err := FreyaMode(ctx, dbConn, msg); handled {
return nil
} else if err != nil {
return err
}
deleted := false
var err error
// NOTE(asaf): All functions called here should verify that the message applies to them.
if !handled && err == nil {
handled, err = CleanUpLibrary(ctx, dbConn, msg)
if !deleted && err == nil {
deleted, err = CleanUpLibrary(ctx, dbConn, msg)
}
if !handled && err == nil {
handled, err = CleanUpShowcase(ctx, dbConn, msg)
if !deleted && err == nil {
deleted, err = CleanUpShowcase(ctx, dbConn, msg)
}
if !handled && err == nil {
handled, err = FreyaMode(ctx, dbConn, msg)
}
if !handled && err == nil {
if !deleted && err == nil {
err = ShareToMatrix(ctx, msg)
}
if !handled && err == nil {
if !deleted && err == nil {
err = MaybeInternMessage(ctx, dbConn, msg)
}
if err == nil {
err = HandleInternedMessage(ctx, dbConn, msg, handled, createSnippets)
err = HandleInternedMessage(ctx, dbConn, msg, deleted, createSnippets)
}
return err
@ -146,6 +148,13 @@ func CleanUpLibrary(ctx context.Context, dbConn db.ConnOrTx, msg *Message) (bool
}
func FreyaMode(ctx context.Context, dbConn db.ConnOrTx, msg *Message) (bool, error) {
if msg.Author.IsBot {
return false, nil
}
if msg.ChannelID == config.Config.Discord.ShowcaseChannelID {
return false, nil
}
twitteryUrls := []string{
"https://twitter.com",
"https://x.com",
@ -162,11 +171,6 @@ func FreyaMode(ctx context.Context, dbConn db.ConnOrTx, msg *Message) (bool, err
return false, nil
}
// paranoia
if msg.Author.IsBot {
return false, nil
}
// FREYA MODE ENGAGED
approvedTweets := []string{
"https://vxtwitter.com/FreyaHolmer/status/1757836988495847568",