Compare commits
No commits in common. "f89a5a5aa6b7c679be9d07c5f3a9e3be31a74bea" and "45cd7a127082f7877684abb8ae0429a8d7c3a44d" have entirely different histories.
f89a5a5aa6
...
45cd7a1270
@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"TeleTokConf": {
|
|
||||||
"ptInstance": "PROXITOK INSTANCE URL",
|
|
||||||
"matrixAddress": "SYNAPSE SERVER URL",
|
|
||||||
"accessToken": "INSERT TOKEN HERE"
|
|
||||||
}
|
|
||||||
}
|
|
36
index.ts
36
index.ts
@ -1,36 +0,0 @@
|
|||||||
import {
|
|
||||||
MatrixClient,
|
|
||||||
SimpleFsStorageProvider,
|
|
||||||
AutojoinRoomsMixin,
|
|
||||||
RustSdkCryptoStorageProvider
|
|
||||||
} from "matrix-bot-sdk";
|
|
||||||
|
|
||||||
//import config data
|
|
||||||
const config = require("./config/config.json");
|
|
||||||
|
|
||||||
const homeserverUrl = config.TeleTokConf.matrixAddress;
|
|
||||||
const accessToken = config.TeleTokConf.accessToken;
|
|
||||||
|
|
||||||
const storage = new SimpleFsStorageProvider("./config/bot.json");
|
|
||||||
const cryptoProvider = new RustSdkCryptoStorageProvider("./config/crypto");
|
|
||||||
|
|
||||||
const client = new MatrixClient(homeserverUrl, accessToken, storage, cryptoProvider);
|
|
||||||
AutojoinRoomsMixin.setupOnClient(client);
|
|
||||||
|
|
||||||
|
|
||||||
client.on("room.message", handleCommand);
|
|
||||||
|
|
||||||
client.start().then(() => console.log("Now listening for TikTok URLs..."));
|
|
||||||
|
|
||||||
async function handleCommand(roomId: string, event: any) {
|
|
||||||
// Don't handle unhelpful events (ones that aren't text messages, are redacted, or sent by us)
|
|
||||||
if (event['content']?.['msgtype'] !== 'm.text') return;
|
|
||||||
if (event['sender'] === await client.getUserId()) return;
|
|
||||||
|
|
||||||
// Check to ensure that the `!hello` command is being run
|
|
||||||
const body = event['content']['body'];
|
|
||||||
if (!body?.startsWith("!hello")) return;
|
|
||||||
|
|
||||||
// Now that we've passed all the checks, we can actually act upon the command
|
|
||||||
await client.replyNotice(roomId, event, "Hello world!");
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user