From 8358d211ae3d6559956b6727bd35666429059f81 Mon Sep 17 00:00:00 2001 From: WlodekM Date: Fri, 24 Jan 2025 11:08:24 +0200 Subject: definitely the first commit --- bot.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 bot.ts (limited to 'bot.ts') 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 + }) +}) -- cgit 1.4.1-2-gfad0