NATS ↔ Instant Messaging Bridge

Check-in [f39decd1ba]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Subscribe command
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f39decd1baeb6a64ca525d3c259c247c50405f924ebf5d6b9666e6d0cd3a6bc0
User & Date: nat 2025-06-28 19:15:12
Context
2025-06-29
19:14
Unsubscribe command check-in: a898f8f6a3 user: nat tags: trunk
2025-06-28
19:15
Subscribe command check-in: f39decd1ba user: nat tags: trunk
2025-06-27
18:19
Subscription list command check-in: 5a05441095 user: nat tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to main.go.

240
241
242
243
244
245
246








247
248
249
250
251
252
253
	for {
		cmd, ok := <-natsim.cmdQueue
		if !ok {
			return
		}

		switch cmd.name {








		case "subscriptions":
			var buf strings.Builder
			buf.WriteString(fmt.Sprintf("Current subscriptions (%d):", len(natsim.subs)))
			for i, s := range natsim.subs {
				buf.WriteString(fmt.Sprintf("\n%d. %s", i+1, s.Subject))
			}
			natsim.ircSend(buf.String())







>
>
>
>
>
>
>
>







240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
	for {
		cmd, ok := <-natsim.cmdQueue
		if !ok {
			return
		}

		switch cmd.name {
		case "subscribe":
			if s, err := natsim.nc.Subscribe(cmd.arg, natsim.natsReceive); err != nil {
				natsim.ircSendError("Subscribe", err)
			} else {
				natsim.subs = append(natsim.subs, s)
				natsim.ircSendf("Subscribed to %q", s.Subject)
			}

		case "subscriptions":
			var buf strings.Builder
			buf.WriteString(fmt.Sprintf("Current subscriptions (%d):", len(natsim.subs)))
			for i, s := range natsim.subs {
				buf.WriteString(fmt.Sprintf("\n%d. %s", i+1, s.Subject))
			}
			natsim.ircSend(buf.String())