Exemplo n.º 1
0
def get_reputation_server():
    send_messange = ""
    db_worker = SQLighter(config.database)
    reputation = db_worker.all_iformation_reputation_servers()
    field_names = "REPUTATION SERVERS\n"
    s2 = '{0}.open.by\nEMAIL REPUTATION: {1}\nVOLUME CHANGE: {2}\nWEB REPUTATION: {3}\nBLACKLISTED: {4}\n'.format(
        reputation[0][0], reputation[0][2], reputation[0][5], reputation[0][3],
        reputation[0][6])
    s3 = '{0}.open.by\nEMAIL REPUTATION: {1}\nVOLUME CHANGE: {2}\nWEB REPUTATION: {3}\nBLACKLISTED: {4}\n'.format(
        reputation[1][0], reputation[1][2], reputation[1][5], reputation[1][3],
        reputation[1][6])
    s4 = '{0}.open.by\nEMAIL REPUTATION: {1}\nVOLUME CHANGE: {2}\nWEB REPUTATION: {3}\nBLACKLISTED: {4}\n'.format(
        reputation[2][0], reputation[2][2], reputation[2][5], reputation[2][3],
        reputation[2][6])
    s5 = '{0}.open.by\nEMAIL REPUTATION: {1}\nVOLUME CHANGE: {2}\nWEB REPUTATION: {3}\nBLACKLISTED: {4}\n'.format(
        reputation[3][0], reputation[3][2], reputation[3][5], reputation[3][3],
        reputation[3][6])
    s6 = '{0}.open.by\nEMAIL REPUTATION: {1}\nVOLUME CHANGE: {2}\nWEB REPUTATION: {3}\nBLACKLISTED: {4}\n'.format(
        reputation[4][0], reputation[4][2], reputation[4][5], reputation[4][3],
        reputation[4][6])
    s7 = '{0}.open.by\nEMAIL REPUTATION: {1}\nVOLUME CHANGE: {2}\nWEB REPUTATION: {3}\nBLACKLISTED: {4}\n'.format(
        reputation[5][0], reputation[5][2], reputation[5][5], reputation[5][3],
        reputation[5][6])
    s8 = '{0}.open.by\nEMAIL REPUTATION: {1}\nVOLUME CHANGE: {2}\nWEB REPUTATION: {3}\nBLACKLISTED: {4}\n'.format(
        reputation[6][0], reputation[6][2], reputation[6][5], reputation[6][3],
        reputation[6][6])
    requests.get(
        'https://api.telegram.org/bot%s/sendMessage?chat_id=%s&text=%s %s %s %s %s %s %s %s'
        % (token, chat_id_Maxim, field_names, s2, s3, s4, s5, s6, s7, s8))
Exemplo n.º 2
0
def do_safe(func, bot, message):
    try:
        client = SQLighter(DB_PATH)
        func(message, client)
    except Exception as ex:
        bot.send_message(message.chat.id, "Error: '{}'".format(ex))
        raise ex
Exemplo n.º 3
0
from aiogram import types
from loader import dp
from sqlite import SQLighter
from data import config

# инициализируем соединение с БД
db = SQLighter('db.db')


# Команда отписки
@dp.message_handler(commands=['unsubscribe'])
async def unsubscribe(message: types.Message):
    if not db.subscriber_exists(message.from_user.id):
        # если юзера нет в базе, добавляем его с неактивной подпиской (запоминаем)
        db.add_subscriber(message.from_user.id, False)
        await message.answer("Вы итак не подписаны.")
    else:
        # если он уже есть, то просто обновляем ему статус подписки
        db.update_subscription(message.from_user.id, False)
        await message.answer(config.unsubscribe_MSG)
Exemplo n.º 4
0
from aiogram import Bot, Dispatcher, executor, types
from config import TOKEN, DB_NAME, Step, CHAT_OUTPUT, CREDENTIALS_FILE, SPREAD_SHEET_ID
from keyboard import work_type_kb, order_answer_kb
from sqlite import SQLighter
from oauth2client.service_account import ServiceAccountCredentials
import requests
import os
import random
import httplib2
import googleapiclient.discovery

bot = Bot(TOKEN)
dp = Dispatcher(bot)

db = SQLighter(DB_NAME)


async def add_client(message, chat_id, username):
    db.add_client(chat_id=chat_id, username=username)
    await message.answer('Здравствуйте. Какой вид услуг вас интересует?',
                         reply_markup=work_type_kb)


@dp.message_handler(commands=['start'])
async def start(message: types.Message):
    if 'username' in message.from_user:
        chat_id = message.from_user.id
        username = '******' + message.from_user.username
        step_list = db.get_step(username)

        if step_list is None:
Exemplo n.º 5
0
def start_test_web_servers():
    Fail = 0
    Up = 0
    while True:
        last_check_ping = check_ping()
        if (last_check_ping == "Network Error") and (Fail == 0):
            Fail = 1
            Up = 0
            bot_check_ping(last_check_ping)
        elif (last_check_ping == "Network Active") and (Up == 0):
            Up = 1
            Fail = 0
            bot_check_ping(last_check_ping)
        if last_check_ping == "Network Active":
            for number in servers.keys():
                try:
                    server = HTTPConnection('%s.open.by' % (number),
                                            timeout=60)
                    #server.request('POST', '/', data, headers=headers)
                    server.request("GET", "/", headers=headers)
                    check_result = server.getresponse()
                    code = check_result.status
                    reason = check_result.status
                    d[number] = code
                    err[number] = 0
                    server.close()
                except Exception as e:
                    err[number] = str(e)
                    d[number] = 1
                    #print(d)
            for number in servers:
                db_worker = SQLighter(config.database)
                base_result = db_worker.status_code(number)
                error_result = db_worker.status_error(number)
                ts = calendar.timegm(time.gmtime())
                ts_base = int(float(base_result[0][1]))
                td = ts - ts_base
                if (error_result[0][0]) != (err.get(number)):
                    st = datetime.datetime.fromtimestamp(ts).strftime(
                        '%Y-%m-%d %H:%M:%S')
                    error = err.get(number)
                    db_worker = SQLighter(config.database)
                    db_worker.update_status_error(err.get(number), ts, number)
                    print(number, servers.get(number), err.get(number), st)
                    bot_err_sent(number, servers.get(number), error, st)
                    #err_mail_send(number,error,st)
                elif ((err.get(number) != 0) and (td > 300)):
                    st = datetime.datetime.fromtimestamp(ts).strftime(
                        '%Y-%m-%d %H:%M:%S')
                    error = err.get(number)
                    db_worker = SQLighter(config.database)
                    db_worker.update_status_error(err.get(number), ts, number)
                    print(number, servers.get(number), err.get(number), st)
                    bot_err_sent(number, servers.get(number), error, st)
                    #err_mail_send(number,error,st)
                elif ((int(base_result[0][0])) !=
                      (d.get(number))) and (d.get(number) != "1"):
                    st = datetime.datetime.fromtimestamp(ts).strftime(
                        '%Y-%m-%d %H:%M:%S')
                    code = d.get(number)
                    db_worker = SQLighter(config.database)
                    db_worker.update_status_code(d.get(number), ts, number)
                    print(number, d.get(number), st)
                    bot_code_sent(number, servers.get(number), code, st)
                    #mail_send(number,code,st)
                elif ((d.get(number) != 200) and (td > 300)):
                    #elif(d.get(number) != 200):
                    st = datetime.datetime.fromtimestamp(ts).strftime(
                        '%Y-%m-%d %H:%M:%S')
                    code = d.get(number)
                    db_worker = SQLighter(config.database)
                    db_worker.update_status_code(d.get(number), ts, number)
                    print(number, d.get(number), st)
                    bot_code_sent(number, servers.get(number), code, st)
                    #mail_send(number,code,st)
        db_worker = SQLighter(config.database)
        get_all_status(db_worker.all_status_code())
        db_worker.close()
        time.sleep(5)