コード例 #1
0
def bay():
    '''Отправка первого сообщения'''

    conn = api.hmac(hmac_key, hmac_secret)
    n = None
    while True:
        try:
            n = conn.call('GET', '/api/notifications/').json()['data']
        except Exception as e:
            print(e)

        for i, e in reversed(list(enumerate(n))):

            if e['read'] == False:
                s = e['msg']  # тело сообщения
                d = str(e['id'])  # id сообщения
                d1 = str('/api/notifications/mark_as_read/' + d +
                         '/')  # api ключ
                k = str(e['contact_id'])  # id сделки
                k1 = str('/api/contact_message_post/' + k + '/')

                if 'Вы получили новое предложение' in s:
                    print('есть сообщение!')
                    print('начинаем процесс отправки реквезитов!!!')
                    conn.call('POST', k1, Msg1.encode('utf-8')).json()
                    conn.call('POST', d1).json()
                    print('\t реквезиты отправлены.\n')
                    continue
        time.sleep(10)
コード例 #2
0
ファイル: main.py プロジェクト: HolidayMan/Lacalbitcoins_prog
def show_notif_fun():
    name_of_acc = select.get(ACTIVE)
    for i in accounts:
        if name_of_acc == i.name:
            key = i.hmac_key
            key_secret = i.hmac_secret
            break
    conn = api.hmac(key, key_secret)
    s = conn.call('GET', '/api/notifications/').json()
    ins = []
    try:
        for i in s['data']:
            st = ''
            time = i['created_at'][:i['created_at'].index('T')] + ' at ' + i[
                'created_at'][i['created_at'].index('T') +
                              1:i['created_at'].index('+')]
            st = '\"{}\"; recieved: {}; {}\n'.format(
                i['msg'], time, 'READ' if i['read'] else 'NOT READ')
            ins.append(st)
    except KeyError:
        answer.config(state=NORMAL)
        answer.insert(
            END,
            'Something went wrong. Maybe your hmac or hmack secret is incorrect.\n-----------------------\n'
        )
        answer.config(state=DISABLED)
        return 0
    ins = ''.join(ins[::-1])
    answer.config(state=NORMAL)
    answer.insert(
        END, 'Notifications at {}:\n{}-----------------------\n'.format(
            name_of_acc, ins))
    answer.config(state=DISABLED)
コード例 #3
0
def first_mess():
    # поток отправки первого сообщения
    conn = api.hmac(API_keys.hmac_key, API_keys.hmac_secret)
    n = None
    while True:
        try:
            n = conn.call('GET', '/api/notifications/').json()['data']
        except Exception as e:
            print(e)

        for i, e in reversed(list(enumerate(n))):

            if e['read'] == False:
                s = e['msg']  # тело сообщения
                d = str(e['id'])  # id сообщения
                d1 = str('/api/notifications/mark_as_read/' + d +
                         '/')  # api ключ
                k = str(e['contact_id'])  # id сделки
                k1 = str('/api/contact_message_post/' + k + '/')

                if 'Вы получили новое предложение' in s:
                    print('есть сообщение!')
                    '''
                    print('начинаем процесс отправки реквезитов!!!')
                    conn.call('POST', k1, conf.MyMess).json()
                    conn.call('POST', d1).json()
                    print('\t реквезиты отправлены.\n')
                    # logging.info('Реквизиты отправлены. ID сделки: ' + k)
                    continue
                    '''
        time.sleep(4)
        print('идем далше')
コード例 #4
0
def start1(queue):
    # поток измения моей цены

    while True:
        for proxy in range(len(conf.proxy)):
            pr = conf.proxy[proxy]
            r = q(queue)
            list_l = []
            if r is None:
                continue
            else:
                for trader in r.keys():
                    if trader in conf.list_ignore or float(
                            r[trader]) < conf.Low:
                        continue
                    else:
                        list_l.append(r[trader])
                if len(list_l) > 0:
                    print(pr, end=' ')
                    min_price = float(list_l[0])
                    my_new_price = str(round(min_price - conf.X, 2))
                    params = {u'price_equation': my_new_price}
                    try:
                        conn = api.hmac(
                            API_keys.hmac_key,
                            API_keys.hmac_secret,
                            proxy={'https': conf.proxy_logpas + pr})
                        a = conn.call('POST', conf.Me_3, params).json()
                        print(a, my_new_price)
                        del conn
                    except Exception as e:
                        print(e)
コード例 #5
0
def bay():
    while True:
        list_l = []
        s = requests.Session()
        r = s.get(conf.url_2).text
        s.close()
        del s
        list_price = re.findall(
            r'<td class="column-price">\s*\W*(\d{2}\D\d{3}\D\d{2})', r)
        list_names = re.findall(r'<a href="/accounts/profile/(\w*)', r)
        # словарь имя:цена
        r = {
            list_names[name]: str(list_price[name]).replace(',', '')
            for name in range(len(list_price))
        }

        for trader in r.keys():
            if trader in conf.list_ignore or float(r[trader]) > conf.Hight:
                continue
            else:
                list_l.append(r[trader])
        if len(list_l) > 0:
            min_price = float(list_l[0])
            print(min_price)
            my_new_price = str(round(min_price + conf.Y, 2))
            params = {u'price_equation': my_new_price}
            try:
                conn = api.hmac(API_keys.hmac_key, API_keys.hmac_secret)
                a = conn.call('POST', conf.Me_3_1, params).json()
                print(a)
                del conn
            except Exception as e:
                print(e)
        time.sleep(6)
コード例 #6
0
def torg_loc(params, nam=None):
    '''API изменения цены'''

    if nam is None:
        nowtime = datetime.now().strftime('%H:%M:%S.%f')
        a = api.hmac(hmac_key, hmac_secret).call('POST', Me_3_1, params).json()
        print("-------------------------------------------------------", )
        print(
            str(a) + nowtime + "  Новая цена  : " +
            str(params.get('price_equation')) + '\t')
    else:
        nowtime = datetime.now().strftime('%H:%M:%S.%f')
        a = api.hmac(hmac_key,
                     hmac_secret,
                     proxy={
                         'https': proxy_logpas + nam
                     }).call('POST', Me_3_1, params).json()
        print("-------------------------------------------------------", )
        print(
            str(a) + nowtime + "  Новая цена  : " +
            str(params.get('price_equation')) + '\t' + nam)
コード例 #7
0
ファイル: main.py プロジェクト: HolidayMan/Lacalbitcoins_prog
def show_ad_fun():
    name_of_acc = select.get(ACTIVE)
    for i in accounts:
        if name_of_acc == i.name:
            key = i.hmac_key
            key_secret = i.hmac_secret
            break
    conn = api.hmac(key, key_secret)
    s = conn.call('GET', '/api/ads/').json()
    print(s)
    try:
        s = s['data']['ad_list']
        if s:
            st = ''
            for ind, i in enumerate(s):
                try:
                    acc_inf = i['data']['account_info']
                except KeyError:
                    acc_inf = '(phone number: {})\n '.format(
                        i['data']['account_details']['phone_number'])
                st += '{}) username: {};\n feedback: {};\n trades: {};\n last online: {};\n price_equation: {};\n trade type: {};\n ad id: {};\n bank name: {};\n payment window minutes: {};\n account info: {};\n country: {};\n currency: {};\n created at: {};\n max amount available: {};\n message: {};\n volume coeficient BTC: {};\n view at: {};\n edit: {}\n\n\n\n'.format(
                    ind + 1, i['data']['profile']['username'],
                    i['data']['profile']['feedback_score'],
                    i['data']['profile']['trade_count'],
                    i['data']['profile']['last_online'],
                    i['data']['price_equation'], i['data']['trade_type'],
                    i['data']['ad_id'], '\"' + i['data']['bank_name'] + '\"',
                    i['data']['payment_window_minutes'], acc_inf,
                    i['data']['location_string'], i['data']['currency'],
                    i['data']['created_at'], i['data']['max_amount_available'],
                    '\"' + i['data']['msg'] + '\"',
                    i['data']['volume_coefficient_btc'],
                    i['actions']['public_view'], i['actions']['html_form'])
            answer.config(state=NORMAL)
            answer.insert(
                END, 'Ads for ' + name_of_acc + ' {\n' + st +
                '\n}\n-----------------------\n')
            answer.config(state=DISABLED)
        else:
            answer.config(state=NORMAL)
            answer.insert(END, 'You have no ads.\n-----------------------\n')
            answer.config(state=DISABLED)
            return 0
    except KeyError:
        answer.config(state=NORMAL)
        answer.insert(
            END,
            'Something went wrong. Maybe your hmac or hmack secret is incorrect.\n-----------------------\n'
        )
        answer.config(state=DISABLED)
        return 0
コード例 #8
0
ファイル: main.py プロジェクト: HolidayMan/Lacalbitcoins_prog
def get_balance_fun():
    name_of_acc = select.get(ACTIVE)
    for i in accounts:
        if name_of_acc == i.name:
            hmac_key = i.hmac_key
            hmac_secret = i.hmac_secret
            break
    conn = api.hmac(hmac_key, hmac_secret)
    s = conn.call('GET', '/api/wallet/').json()
    try:
        answer.config(state=NORMAL)
        answer.insert(
            END, "Balance on {}: {}\n".format(name_of_acc,
                                              s['data']['total']['balance']) +
            '\n-----------------------\n')
        answer.config(state=DISABLED)
    except KeyError:
        answer.config(state=NORMAL)
        answer.insert(
            END,
            'Something went wrong. Maybe your hmac or hmack secret is incorrect.\n-----------------------\n'
        )
        answer.config(state=DISABLED)
コード例 #9
0
ファイル: api_connection.py プロジェクト: havocesp/lucifer
import api
import json
import sys
import secret

hmac_key = secret.hmac_key
hmac_secret = secret.hmac_secret
conn = api.hmac(hmac_key, hmac_secret)