chore: formatting
This commit is contained in:
parent
ed8aec1008
commit
b417ff27d7
@ -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") ??
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user