summary refs log tree commit diff
path: root/src/main.go
diff options
context:
space:
mode:
authorEmile <git@emile.space>2024-10-25 15:44:53 +0200
committerEmile <git@emile.space>2024-10-25 15:44:53 +0200
commit98bbb0f559a8883bc47bae80607dbe326a448e61 (patch)
tree60870e3af017d741e9a5b2140af2b82ab5dd1b89 /src/main.go
parent971a5c7c170b16bc18cf5c44afa089710aade10f (diff)
no startup spam, just print messages while he's running
Diffstat (limited to 'src/main.go')
-rw-r--r--src/main.go31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/main.go b/src/main.go
index 1837cc1..8c4dda8 100644
--- a/src/main.go
+++ b/src/main.go
@@ -91,27 +91,13 @@ func main() {
 	syncer := client.Syncer.(*mautrix.DefaultSyncer)
 	syncer.OnEventType(event.EventMessage, func(ctx context.Context, evt *event.Event) {
 
-		// When marvin received an event, the room the event was sent from gets set here
-		// This is used for replying within that room
-		lastRoomID = evt.RoomID
-		rl.SetPrompt(fmt.Sprintf("%s> ", lastRoomID))
-		log.Info().
-			Str("sender", evt.Sender.String()).
-			Str("type", evt.Type.String()).
-			Str("id", evt.ID.String()).
-			Str("body", evt.Content.AsMessage().Body).
-			Msg("Received message")
-
-		body := evt.Content.AsMessage().Body
-
-		// filtering out the synced messages, remarvin only answers messages that are coming in
+		// Filtering out the synced messages, remarvin only answers to messages that are coming in
 		// after has has been started, otherwise you could spam `.5` and marvin would spam back
 		// which is annoying
-		// yes, we have an offset of like 6h
+		// Yes, we have an offset of like 6h in the event time, no idea why
 		eventTime := evt.Timestamp + (6 * 60 * 60)
 		currentTime := time.Now().UnixMilli()
 		if eventTime <= currentTime {
-			log.Info().Msg("old msg, not responding")
 			return
 		}
 
@@ -121,6 +107,19 @@ func main() {
 			return
 		}
 
+		// When marvin received an event, the room the event was sent from gets set here
+		// This is used for replying within that room
+		lastRoomID = evt.RoomID
+		rl.SetPrompt(fmt.Sprintf("%s> ", lastRoomID))
+		log.Info().
+			Str("sender", evt.Sender.String()).
+			Str("type", evt.Type.String()).
+			Str("id", evt.ID.String()).
+			Str("body", evt.Content.AsMessage().Body).
+			Msg("Received message")
+
+		body := evt.Content.AsMessage().Body
+
 		if body == ".5" {
 			line := `five questions huh?
 				We usually ask new people here 5 questions for the means of introduction. No personal data wanted. Are you in for that?