Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.7 kB
5
Indexable
Never
var discord = require('discord');
var requests = require('requests');
var asyncio = require('asyncio');

token = '';
puslapis = 'http://cbb.lt';
timeout = 300 // laikas sekundemis
kanalas = 'test';
komanda = '!test';

zinute_ok = '[OK] Puslapis veikia tvarkingai.';
zinute_error = '[Error] Puslapis susiduria su problemomis. Patikrinkite konfiguracija.';

#apacioje nieko nekeisti;

client = discord.Client();

on_ready = client.event(on_ready);
async function on_ready() {
    console.log('Prisijungeme kaip {0.user}'.format(client));
}
on_message = client.event(on_message);
async function on_message(msg) {
    username = String(msg.author).split('#')[0];
    user_message = String(msg.content);
    channel = String(msg.channel.name);
    console.log(f'{username}: {user_message} ({channel})');
}
    if (msg.author == client.user) {
        return;
    }
    if (msg.channel.name == kanalas && user_message.lower() == komanda) {

        try {
            resp = requests.get(puslapis);
            resp.raise_for_status();
        }
            zinute = await msg.channel.send(zinute_ok);
    }
        } catch ( (requests.} catch (ions.HTTPError, requests.} catch (ions.ConnectionError) {

            zinute = await msg.channel.send(zinute_error);
        }

        while (true) {

            await asyncio.sleep(timeout);

            try {
                resp = requests.get(puslapis);
                resp.raise_for_status();
            }
                await zinute.edit(content=zinute_ok);

            } catch ( (requests.} catch (ions.HTTPError, requests.} catch (ions.ConnectionError) {

                await zinute.edit(content=zinute_error);
            }
client.run(token)) {
) {
) {
) {
) {