summaryrefslogtreecommitdiff
path: root/main.c
blob: 806c8ef5f7f3e3543245d438e95cb47e0c12e0b8 (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "db.h"
#include "log.h"
#include "tdutils.h"
#include "botd.h"
#include "logic.h"

#include <stdlib.h>
#include <string.h>

cmd_t cmd = {
        NULL,
        0,
        NULL,
        false,
        NULL,
        false
};

int post_auth() {
    LOGI("OK");
    return 0;
}

static void ate(void) {
    db_close();
    td_free();
}

int main(int argc, char **argv) {
    atexit(&ate);
    parse_cmdline(argc, argv);
    db_init();
    td_init();
    td_loop();
    return 0;
}

int handle_message(struct TdUpdateNewMessage *update) {
    struct TdMessage *msg = update->message_;
    if (msg->sender_id_->ID == CODE_MessageSenderUser &&
        ((struct TdMessageSenderUser *) msg->sender_id_)->user_id_ == ADMIN) {
        if (msg->content_->ID == CODE_MessageText &&
            !strcmp(((struct TdMessageText *) msg->content_)->text_->text_, "/refresh")) {
            refresh(msg);
            return 0;
        }
    }
    store(msg);
    return 0;
}