chore: formatting

This commit is contained in:
kieran 2024-10-20 20:03:47 +01:00
parent ed8aec1008
commit b417ff27d7
No known key found for this signature in database
GPG Key ID: DE71CEB3925BE941

View File

@ -5,21 +5,21 @@ import {
type NostrEvent,
type SystemInterface,
NostrPrefix,
EventKind
EventKind,
} from "@snort/system";
import EventEmitter from "eventemitter3";
export interface BotEvents {
message: (msg: BotMessage) => void,
event: (ev: NostrEvent) => void,
message: (msg: BotMessage) => void;
event: (ev: NostrEvent) => void;
}
export interface BotMessage {
link: NostrLink,
from: string,
message: string,
event: NostrEvent,
reply: (msg: string) => void,
link: NostrLink;
from: string;
message: string;
event: NostrEvent;
reply: (msg: string) => void;
}
export type CommandHandler = (msg: BotMessage) => void;
@ -32,13 +32,13 @@ export class SnortBot extends EventEmitter<BotEvents> {
constructor(
readonly name: string,
readonly system: SystemInterface,
readonly publisher: EventPublisher
readonly publisher: EventPublisher,
) {
super();
system.pool.on("event", (addr, sub, e) => {
this.emit("event", e);
if (e.kind === 30311) {
const links = [e, ...this.activeStreams].map(v => NostrLink.fromEvent(v))
const links = [e, ...this.activeStreams].map(v => NostrLink.fromEvent(v));
const linkStr = links.map(e => e.encode());
if (linkStr.every(a => this.#activeStreamSub.has(a))) {
return;
@ -72,7 +72,7 @@ export class SnortBot extends EventEmitter<BotEvents> {
event: e,
reply: (msg: string) => {
this.#sendReplyTo(link, msg);
}
},
});
}
}
@ -80,7 +80,10 @@ export class SnortBot extends EventEmitter<BotEvents> {
}
get activeStreams() {
return this.system.GetQuery("streams")?.snapshot?.filter(a => a.tags.find(b => b[0] === "status")?.at(1) === "live") ?? []
return (
this.system.GetQuery("streams")?.snapshot?.filter(a => a.tags.find(b => b[0] === "status")?.at(1) === "live") ??
[]
);
}
/**