summary refs log tree commit diff
path: root/bot.ts
diff options
context:
space:
mode:
Diffstat (limited to 'bot.ts')
-rw-r--r--bot.ts27
1 files changed, 27 insertions, 0 deletions
diff --git a/bot.ts b/bot.ts
new file mode 100644
index 0000000..eed58db
--- /dev/null
+++ b/bot.ts
@@ -0,0 +1,27 @@
+import Maelink from "./main.ts";
+import { username, password } from "./creds.json" with {type: "json"};
+
+const ml = new Maelink()
+console.log(
+    await ml.login(username, password)
+)
+
+interface Post {
+    _id: string,
+    p: string,
+    u: string,
+    e: string,
+    reply_to: null | string,
+    post_id: string
+}
+
+// ml.ws.onmessage = e => console.log(e)
+
+ml.on('post', ({p: post, _id}: Post) => {
+    console.log(post)
+    if (!post.startsWith(`@wlod-bot`)) return;
+    ml.sendMessage({
+        message: 'hello',
+        replyTo: _id
+    }) 
+})