summary refs log tree commit diff
path: root/bot.ts
blob: 2271cd545ac111ade71033ce904135b6fca9acbf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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(`@${username}`)) return;
    ml.sendMessage({
        message: 'hello',
        replyTo: _id
    }) 
})