commit 0d05cd3cb9af4f34229bad426c93542f4bc8fb1f
parent 93f1c2b57707503ecd8fdbb0b77cf72db40f1e0b
Author: Natasha Kerensikova <natgh@instinctive.eu>
Date: Thu, 26 Jun 2025 18:32:57 +0000
Subscription objects are stored (for future commands)
Diffstat:
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/main.go b/main.go
@@ -103,6 +103,7 @@ type NatsIM struct {
irc *irc.Connection
nc *nats.Conn
+ subs []*nats.Subscription
db *sql.DB
ensureSubject *sql.Stmt
insertReceived *sql.Stmt
@@ -282,8 +283,10 @@ func (natsim *NatsIM) ircJoined(e *irc.Event) {
}
for _, subject := range natsim.Nats.Subjects {
- if _, err := natsim.nc.Subscribe(subject, natsim.natsReceive); err != nil {
+ if s, err := natsim.nc.Subscribe(subject, natsim.natsReceive); err != nil {
natsim.ircSendError("Subscribe", err)
+ } else {
+ natsim.subs = append(natsim.subs, s)
}
}
}