How to use the matrix-bot-sdk.LogService.info function in matrix-bot-sdk

To help you get started, we’ve selected a few matrix-bot-sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github matrix-org / mjolnir / src / Mjolnir.ts View on Github external
client.on("room.message", async (roomId, event) => {
            if (roomId !== config.managementRoom) return;
            if (!event['content']) return;

            const content = event['content'];
            if (content['msgtype'] === "m.text" && content['body']) {
                const prefixes = [COMMAND_PREFIX, this.localpart + ":", this.displayName + ":", await client.getUserId() + ":"];
                const prefixUsed = prefixes.find(p => content['body'].startsWith(p));
                if (!prefixUsed) return;

                // rewrite the event body to make the prefix uniform (in case the bot has spaces in its display name)
                event['content']['body'] = COMMAND_PREFIX + content['body'].substring(prefixUsed.length);
                LogService.info("Mjolnir", `Command being run by ${event['sender']}: ${event['content']['body']}`);

                await client.sendReadReceipt(roomId, event['event_id']);
                return handleCommand(roomId, event, this);
            }
        });
github turt2live / matrix-voyager-bot / src / mq / mq.ts View on Github external
for (const topic of Object.keys(this.listeners)) await this.doBind(topic);

        LogService.info("mq", `Asserting dead letter queue ${VoyagerConfig.rabbitmq.deadLetterQueue} exists...`);
        await this.channel.assertQueue(VoyagerConfig.rabbitmq.deadLetterQueue, {
            durable: true,
            messageTtl: 2 * 60 * 1000, // 2 minutes
            deadLetterExchange: VoyagerConfig.rabbitmq.exchange,
        });

        LogService.info("mq", "Binding dead letter exchange to dead letter queue...");
        await this.channel.bindQueue(VoyagerConfig.rabbitmq.deadLetterQueue, VoyagerConfig.rabbitmq.deadLetterExchange, "*");

        LogService.info("mq", "Listening for events...");
        await this.channel.consume(this.queueName, this.onMessage.bind(this));

        LogService.info("mq", "RabbitMQ ready");
    }
github turt2live / matrix-voyager-bot / src / mq / mq.ts View on Github external
LogService.info("mq", `Asserting queue ${this.queueName} exists...`);
        await this.channel.assertQueue(this.queueName, {
            exclusive: true,
            autoDelete: true,
            deadLetterExchange: VoyagerConfig.rabbitmq.deadLetterExchange,
        });
        for (const topic of Object.keys(this.listeners)) await this.doBind(topic);

        LogService.info("mq", `Asserting dead letter queue ${VoyagerConfig.rabbitmq.deadLetterQueue} exists...`);
        await this.channel.assertQueue(VoyagerConfig.rabbitmq.deadLetterQueue, {
            durable: true,
            messageTtl: 2 * 60 * 1000, // 2 minutes
            deadLetterExchange: VoyagerConfig.rabbitmq.exchange,
        });

        LogService.info("mq", "Binding dead letter exchange to dead letter queue...");
        await this.channel.bindQueue(VoyagerConfig.rabbitmq.deadLetterQueue, VoyagerConfig.rabbitmq.deadLetterExchange, "*");

        LogService.info("mq", "Listening for events...");
        await this.channel.consume(this.queueName, this.onMessage.bind(this));

        LogService.info("mq", "RabbitMQ ready");
    }
github turt2live / matrix-voyager-bot / src / mq / mq.ts View on Github external
autoDelete: true,
            deadLetterExchange: VoyagerConfig.rabbitmq.deadLetterExchange,
        });
        for (const topic of Object.keys(this.listeners)) await this.doBind(topic);

        LogService.info("mq", `Asserting dead letter queue ${VoyagerConfig.rabbitmq.deadLetterQueue} exists...`);
        await this.channel.assertQueue(VoyagerConfig.rabbitmq.deadLetterQueue, {
            durable: true,
            messageTtl: 2 * 60 * 1000, // 2 minutes
            deadLetterExchange: VoyagerConfig.rabbitmq.exchange,
        });

        LogService.info("mq", "Binding dead letter exchange to dead letter queue...");
        await this.channel.bindQueue(VoyagerConfig.rabbitmq.deadLetterQueue, VoyagerConfig.rabbitmq.deadLetterExchange, "*");

        LogService.info("mq", "Listening for events...");
        await this.channel.consume(this.queueName, this.onMessage.bind(this));

        LogService.info("mq", "RabbitMQ ready");
    }
github turt2live / matrix-voyager-bot / src / mq / mq.ts View on Github external
private async doBind(topic: string) {
        if (this.boundTopics.indexOf(topic) !== -1) return;
        LogService.info("mq", `Binding topic ${topic} on ${VoyagerConfig.rabbitmq.exchange} to queue ${this.queueName}...`);
        await this.channel.bindQueue(this.queueName, VoyagerConfig.rabbitmq.exchange, topic);
        this.boundTopics.push(topic);
    }
github turt2live / matrix-voyager-bot / src / db / postgres.ts View on Github external
public async query(statement: string, args?: any[]): Promise {
        LogService.info("PostgresDatabase", `Running query: ${statement}`);
        const pgClient = await this.getClient();
        try {
            return (await pgClient.client.query(statement, args)).rows;
        } finally {
            if (pgClient.shouldRelease) pgClient.client.release();
        }
    }
github turt2live / matrix-voyager-bot / src / mq / mq.ts View on Github external
public async sendPayload(topic: string, type: string, payload: any): Promise {
        LogService.info("mq", `Sending payload to topic ${topic} of type ${type}`);
        const buf = Buffer.from(JSON.stringify(payload));
        return this.channel.publish(VoyagerConfig.rabbitmq.exchange, topic, buf, {
            persistent: true,
            contentType: "application/json",
            contentEncoding: "utf8",
            type: type,
        });
    }
github matrix-org / mjolnir / src / utils.ts View on Github external
function backfill(from: string) {
        const qs = {
            filter: JSON.stringify(filter),
            from: from,
            dir: "b",
        };
        LogService.info("utils", "Backfilling with token: " + token);
        return client.doRequest("GET", `/_matrix/client/r0/rooms/${encodeURIComponent(roomId)}/messages`, qs);
    }