Exemplo n.º 1
0
def autorequest_configure(CurrentUse):
    money = 0.02
    max_cards = 3
    card_latest_digits = CurrentUse.parser_p.card_latest_digits

    if card_latest_digits is None:
        return '''1)Отправь ровно {} даньку на сбер
2)Через минуты 2 после этого (но не позже, чем через {}) напиши боту \n/реквест.п 1234\n где вместо "1234" 4 последние цифры карты, с которой были отправлены 2 копейки
3)Если все сделано верно, то эта карта будет добавлена в список твоих; При последующих автореквестах будут чекаться переводы с каждой из твоих карт

P.S: Нельзя добавить больше {} карт'''.format(money, PAYMENT_VALID_TIME, max_cards)

    if not card_latest_digits.isdigit() or len(card_latest_digits) != 4:
        return 'Чето ты со вводом 4 циферок попутал фраерок'

    g_storage = CurrentUse.storage('', name='sberb_global')
    u_storage = CurrentUse.storage('u', name='sberb_user')

    if 'cards' not in u_storage:
        u_storage['cards'] = []

    user_cards = u_storage['cards']
    if len(user_cards) >= max_cards:
        return 'У тя добавлено максимальо возможное ко-во карт.'

    CurrentUse.send_msg('Погоди немного...')
    try:
        operation = sberb.check_transaction(g_storage, money, minuts=PAYMENT_VALID_TIME,
                                            card_latest_digits=card_latest_digits)
    except Exception as exc:
        notify(exc)
        return exc

    if operation is None:
        return 'Не найдено(Если сделалб все всерно, подожди пару минут и попробуй еще раз.)'

    used_transactions = g_storage['used_transactions']

    # todo auto clear sometimes
    used_transactions.append(operation['id'])
    g_storage.save()

    cur_card = {'number': operation['from_card'], 'fio': operation['from_user'], 'op_id': operation['id']}
    user_cards.append(cur_card)
    u_storage.save()

    return 'Карта успешно добавлена'
Exemplo n.º 2
0
async def update_lp_url(group_id, client_session):
    group = groups_list[group_id]
    group['active'] = 0
    print('updating lp_url', group_id)
    req_url = 'https://api.vk.com/method/groups.getLongPollServer?group_id={id}&access_token={token}&v=5.101'.format(
        id=abs(group_id), token=group['access_token'])
    task = asyncio.ensure_future(fetch(req_url, client_session))
    resp = await asyncio.gather(task)
    add_data, resp = resp[0]

    resp = json.loads(resp)

    try:
        resp = resp['response']
        lp_url = '{server}?act=a_check&key={key}&wait=90&mode=2&ts='.format(
            **resp)
    except BaseException as exc:

        error = resp['error']
        error_code = error['error_code']
        if error_code == 27:
            group_obj = group['group_obj']
            group_obj.is_blocked = True
            group_obj.save(update_fields=['is_blocked'])
            groups_list.pop(group_id)
            print('Group', group_id, 'is BLOCKED :(')
            return 0

        text = '{}:{}'.format(group_id, get_exc_info())

        print(text)
        notify(text)
        lp_url = None
    if not lp_url:
        return 0
    group['ts'] = resp['ts']
    group['lp_url'] = lp_url
    group['active'] = 1
    return 1
Exemplo n.º 3
0
def get_coupon(payload):
    rest_id = payload['rest_id']
    coupon_code = payload['key']
    connection = http.client.HTTPSConnection('orderapp.burgerking.ru')
    url = '/api/v1/menu/coupons?restaurant={}&code={}'.format(rest_id, coupon_code)
    connection.request('GET', url, headers=app_headers)
    response = connection.getresponse()
    status = response.status
    resp = response.read()
    # print(coupon_code, resp)
    if status == 200:
        try:
            jsonn = json.loads(resp)
        except:
            notify(resp.decode())
            jsonn = {}

        return jsonn
    elif status == 400:
        return 0
    else:
        notify(response.read().decode())
        return 0
Exemplo n.º 4
0
def token_handle(request):
    notify(str(json.loads(request.body.decode('utf-8'))))
    return HttpResponse('Salamaleykum')
Exemplo n.º 5
0
        connection.request('POST', '/api/v1/order/getLastOrder', '',
                           app_headers)
        response = connection.getresponse()
        try:
            resp_json = json.loads(response.read())
            break
        except json.JSONDecodeError:
            continue

    queue = resp_json['response']['queue']
    pin = resp_json['response']['pin']
    status = resp_json['response']['status']

    if (time.time() - time_created) > max_time:
        todel.append(i)
        notify('Dolgovirus\n' + json.dumps(order))
        continue

    if status == 1 or status == 2:
        continue

    todel.append(i)

    if status in statuses:
        status_text = statuses[status]
    else:
        status_text = 'завершен со статусом {}'.format(status)

    text = 'Заказ {} {} {}!'.format(queue, pin, status_text)

    st = notify_user(contact, text)
Exemplo n.º 6
0
        "Content-Type":
        "multipart/form-data; boundary=----WebKitFormBoundaryiEWt3RN0RLTKYqY7",
        "Accept": "application/json",
        "X-Requested-With": "XMLHttpRequest",
        "X-Xsrftoken": item['xsrftoken'],
        "DNT": "1",
        "Referer": "https://saratov.hh.ru/applicant/resumes?from=header_new",
        "Accept-Encoding": "gzip, deflate",
        "Accept-Language": "ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7"
    }
    burp0_data = "------WebKitFormBoundaryiEWt3RN0RLTKYqY7\r\nContent-Disposition: form-data; name=\"resume\"\r\n\r\n" + res_id + "\r\n------WebKitFormBoundaryiEWt3RN0RLTKYqY7\r\nContent-Disposition: form-data; name=\"undirectable\"\r\n\r\ntrue\r\n------WebKitFormBoundaryiEWt3RN0RLTKYqY7--\r\n"
    status = 0
    for i in range(100):
        req = requests.post(
            "https://saratov.hh.ru:443/applicant/resumes/touch",
            headers=burp0_headers,
            cookies=burp0_cookies,
            data=burp0_data)
        status = req.status_code
        if status == 200:
            break
        time.sleep(1)
    return status == 200


for item in TOUCH_LIST:
    status = touch(item)

    if status != 200:
        notify("Can't touch resume " + item['res_id'])
Exemplo n.º 7
0
    if status == 200:
        try:
            jsonn = json.loads(resp)
        except:
            notify(resp.decode())
            jsonn = {}

        return jsonn
    elif status == 400:
        return 0
    else:
        notify(response.read().decode())
        return 0


easy_threading = EasyThreading(get_coupon, concurrent)

for i in range(latest_code + 1, latest_code + 1 + count_to_check):
    payload = {'key': i, 'rest_id': rest_id}
    easy_threading.add_payload(payload)

resps = easy_threading.finish()

for code, resp in resps.items():
    if not resp: continue
    notify(json.dumps(resp, ensure_ascii=False))
    if code > latest_code:
        latest_code = code

open('latest_code.txt', 'w').write(str(latest_code))
Exemplo n.º 8
0
 def process_exception(self, request, exception):
     exc_info = get_exc_info()
     message = exc_info
     notify(message)
     return None
Exemplo n.º 9
0
def group_add(access_token, CurrentUse=None):
    # todo get latest chat id
    need_perms = ['photos', 'docs', 'messages', 'manage', 'wall']
    sess = VkApi(token=access_token)

    try:
        perms = sess.method('groups.getTokenPermissions')
    except:
        return 0, 'Неверный токен'

    have_perms = set()
    for perm in perms['permissions']:
        have_perms.add(perm['name'])

    for perm in need_perms:
        if perm not in have_perms:
            return 0, 'Необходимые права токена: ' + ', '.join(need_perms)

    group = sess.method('groups.getById', {'fields': 'description'})[0]
    group_id = group['id']
    try:
        group_obj = ConnectedGroup.objects.get(id=-group_id)
        return 0, 'Эта группа уже есть в базе данных'
    except ObjectDoesNotExist:
        pass

    payload = {
        'group_id': group_id,
        'enabled': 1,
        'api_version': 5.87,
        'message_new': 1,
        'group_change_settings': 1,
    }
    # todo all to 0?
    try:
        result = sess.method('groups.setLongPollSettings', payload)
    except:
        result = 0
    if not result:
        return 0, 'Не удалось изменить настройки Long Poll сервера'

    payload = {
        'group_id': group_id,
        'messages': 1,
        'bots_add_to_chat': 1,
        'bots_capabilities': 1,
        'bots_start_button': 1,
        'v': 5.101
    }
    try:
        result = sess.method('groups.setSettings', payload)
    except:
        result = 0
    if not result:
        return 0, 'Не удалось включить функции бота'
    secret = randomString(16)
    owner = CurrentUse.user
    group_obj = ConnectedGroup(id=-group_id,
                               access_token=access_token,
                               secret=secret,
                               owner=owner)
    group_obj.save()
    time.sleep(1)
    r = _send_startup_event(group_id, secret)

    notify('Добавлена новая группа\nhttps://vk.com/club{}'.format(
        abs(group_id)))
    return 1, '1'
Exemplo n.º 10
0
def notifys(CurrentUse):
    n = notify(CurrentUse.text)
    return n
Exemplo n.º 11
0
        response = agr_handlers[agr_level](response)

    return response


try:
    sess = VkApi(token=VK_MY_TOKEN)
    exec_stack = ExecuteStack(sess)
    payload = {'user_ids': uid, 'fields': 'online'}

    is_online = sess.method('users.get', payload)[0]['online']
    if is_online and (time.time() - storage['latest_send']) > SEND_TIMEOUT:
        storage['latest_send'] = time.time()
        actions = gen_actions()
        for action in actions:
            exec_stack.add(action['method'],
                           action['payload'],
                           additional=action['callback'])
        resps = exec_stack.finish()
        for resp, callback in resps:
            if callback:
                callback(resp)

        storage['current_notifies'] += 1
        if storage['current_notifies'] == 1:
            storage['current_first'] = time.time()
except:
    notify('sanya_sleep error\n' + get_exc_info())

storage.save()