Add info; Version 0.5.0

This commit is contained in:
Aslan 2025-12-26 04:42:14 +01:00
parent dd4da06753
commit 4819805b3c
4 changed files with 19 additions and 4 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "aslobot-matrix", "name": "aslobot-matrix",
"version": "0.1.0", "version": "0.5.0",
"description": "", "description": "",
"license": "ISC", "license": "ISC",
"author": "", "author": "",

View file

@ -1,3 +1,4 @@
import config from "./config.json" with { type: "json" }; import config from "./config.json" with { type: "json" };
import packageConfig from "../package.json" with { type: "json" };
export { config }; export { config, packageConfig };

View file

@ -1,6 +1,7 @@
import { MatrixClient } from "matrix-js-sdk"; import { MatrixClient } from "matrix-js-sdk";
import type { ICallbackStore } from "../types.js"; import type { ICallbackStore } from "../types.js";
import { config } from "../../config.js"; import { config, packageConfig } from "../../config.js";
import { platform } from "os";
let client: MatrixClient; let client: MatrixClient;
@ -14,6 +15,10 @@ const registerModuleBase = (
startConditions: [`${config.app.triggerPrefix}ping`], startConditions: [`${config.app.triggerPrefix}ping`],
callbackFunc: onPing, callbackFunc: onPing,
}); });
callbackStore.messageCallbacks.push({
startConditions: [`${config.app.triggerPrefix}info`],
callbackFunc: onInfo,
});
callbackStore.messageCallbacks.push({ callbackStore.messageCallbacks.push({
startConditions: [`${config.app.triggerPrefix}say `], startConditions: [`${config.app.triggerPrefix}say `],
callbackFunc: onSay, callbackFunc: onSay,
@ -32,6 +37,14 @@ const onPing = (_text: string, roomId: string) => {
client.sendTextMessage(roomId, "Pong!"); client.sendTextMessage(roomId, "Pong!");
}; };
const onInfo = (_text: string, roomId: string) => {
client.sendHtmlMessage(
roomId,
"",
`<p>AsloBot version <b>${packageConfig.version}</b> running on <b>${platform()}</b></p>`,
);
};
const onSay = (text: string, roomId: string) => { const onSay = (text: string, roomId: string) => {
const trigger = `${config.app.triggerPrefix}say `; const trigger = `${config.app.triggerPrefix}say `;
@ -51,6 +64,7 @@ const onHelp = (_text: string, roomId: string) => {
`<h3>Role: User</h3> `<h3>Role: User</h3>
<ul> <ul>
<li><b>!ping</b> - Pong!</li> <li><b>!ping</b> - Pong!</li>
<li><b>!info</b> - Prints information about this bot</li>
<li><b>!say {text}</b> - Repeats your message</li> <li><b>!say {text}</b> - Repeats your message</li>
<li><b>!bowling {text}</b> - Repeats your message in bowling</li> <li><b>!bowling {text}</b> - Repeats your message in bowling</li>
<li><b>!help</b> - Prints this help message</li> <li><b>!help</b> - Prints this help message</li>

View file

@ -28,7 +28,7 @@ const onLevel = (_text: string, roomId: string, sender: string) => {
client.sendHtmlMessage( client.sendHtmlMessage(
roomId, roomId,
"", "",
`<h3>Your Level: <b>${level.level}</b></h3> `<h3>Your Level: ${level.level}</h3>
</br> </br>
<i>Next level progress: ${level.experienceInLevel}/${level.expToNextLevel}xp</i>`, <i>Next level progress: ${level.experienceInLevel}/${level.expToNextLevel}xp</i>`,
); );