Initial code
This commit is contained in:
commit
1f20a611da
26 changed files with 1050 additions and 0 deletions
63
src/modules/base/base.ts
Normal file
63
src/modules/base/base.ts
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
import { MatrixClient } from "matrix-js-sdk";
|
||||
import type { ICallbackStore } from "../types.js";
|
||||
import { config } from "../../config.js";
|
||||
|
||||
let client: MatrixClient;
|
||||
|
||||
const registerModuleTest = (
|
||||
matrixClient: MatrixClient,
|
||||
callbackStore: ICallbackStore,
|
||||
) => {
|
||||
client = matrixClient;
|
||||
|
||||
callbackStore.messageCallbacks.push({
|
||||
startCondition: `${config.app.triggerPrefix}ping`,
|
||||
callbackFunc: onPing,
|
||||
});
|
||||
callbackStore.messageCallbacks.push({
|
||||
startCondition: `${config.app.triggerPrefix}say `,
|
||||
callbackFunc: onSay,
|
||||
});
|
||||
callbackStore.messageCallbacks.push({
|
||||
startCondition: `${config.app.triggerPrefix}help`,
|
||||
callbackFunc: onHelp,
|
||||
});
|
||||
};
|
||||
|
||||
const onPing = (_text: string, roomId: string) => {
|
||||
client.sendTextMessage(roomId, "Pong!");
|
||||
};
|
||||
|
||||
const onSay = (text: string, roomId: string) => {
|
||||
const trigger = `${config.app.triggerPrefix}say `;
|
||||
|
||||
client.sendTextMessage(roomId, text.replace(trigger, ""));
|
||||
};
|
||||
|
||||
const onHelp = (_text: string, roomId: string) => {
|
||||
client.sendHtmlMessage(
|
||||
roomId,
|
||||
"",
|
||||
`<h3>Role: User</h3>
|
||||
<ul>
|
||||
<li><b>!ping</b> - Pong!</li>
|
||||
<li><b>!say {text}</b> - Repeats your message</li>
|
||||
<li><b>!help</b> - Prints this help message</li>
|
||||
<li><b>!rank</b> - Prints your rank and experience</li>
|
||||
<li><b>!leaderboard</b> - Prints total user ranking</li>
|
||||
</ul>
|
||||
<hr/>
|
||||
<h3>Role: Moderator</h3>
|
||||
<ul>
|
||||
<li><b>!load</b> - Load bot data</li>
|
||||
<li><b>!save</b> - Save bot data</li>
|
||||
</ul>
|
||||
<hr/>
|
||||
<h3>Role: Admin</h3>
|
||||
<ul>
|
||||
<li><b>!shutdown</b> - Shutdown bot</li>
|
||||
</ul>`,
|
||||
);
|
||||
};
|
||||
|
||||
export { registerModuleTest };
|
||||
1
src/modules/base/index.ts
Normal file
1
src/modules/base/index.ts
Normal file
|
|
@ -0,0 +1 @@
|
|||
export * from "./base.js";
|
||||
Loading…
Add table
Add a link
Reference in a new issue