fix
This commit is contained in:
parent
bac5ba9f36
commit
0b8878dbb6
9
api.py
9
api.py
@ -365,7 +365,7 @@ def add_time(it: Add_time):
|
||||
stat[date]['time2cdm'] += amount
|
||||
write(stat, 'stat.json')
|
||||
|
||||
stat_run(0)
|
||||
stat_run(amount)
|
||||
return 'OK'
|
||||
else:
|
||||
return 'Error'
|
||||
@ -474,7 +474,6 @@ def get_stat(it: Get_stat):
|
||||
if token_check(token):
|
||||
stat_run(0)
|
||||
db = read('stat.json')
|
||||
#date = datetime.today().strftime('%Y-%m-%d')
|
||||
if date not in db:
|
||||
return 'Not found'
|
||||
stats = db[date]
|
||||
@ -531,6 +530,12 @@ class Gen_fp(BaseModel):
|
||||
def gen_fp(it: Gen_fp):
|
||||
token, id, amount = it.token, it.id, it.amount
|
||||
if token_check(token):
|
||||
try:
|
||||
if float(amount) <= 0.0001:
|
||||
return 'Error'
|
||||
amount = str(float(amount)) # Защиты от 1000 нулей в начале
|
||||
except:
|
||||
return 'Error'
|
||||
user_api = read('user_api.json')
|
||||
if id not in user_api['fp']:
|
||||
user_api['fp'][id] = []
|
||||
|
21
tg.py
21
tg.py
@ -49,9 +49,7 @@ def start(message):
|
||||
if message.text == '/start':
|
||||
bot.reply_to(message, 'Всё работает', reply_markup=markup)
|
||||
else:
|
||||
#try:
|
||||
if 1:
|
||||
#nick, amount = message.text.split(' ')[1].split('_')
|
||||
try:
|
||||
fp_id = message.text.split(' ')[1]
|
||||
dst_id, amount = read('user_api.json')['fp'][fp_id]
|
||||
nick = get_nick(API_TOKEN, dst_id)
|
||||
@ -61,7 +59,6 @@ def start(message):
|
||||
return
|
||||
amount = str(float(amount)) # Защиты от 1000 нулей в начале
|
||||
src_id = user_in_db(API_TOKEN, tg=message.chat.id)
|
||||
#dst_id = user_in_db(API_TOKEN, nick=nick)
|
||||
if dst_id == 'false':
|
||||
bot.reply_to(message, 'Не существует такого пользователя.')
|
||||
else:
|
||||
@ -83,8 +80,8 @@ def start(message):
|
||||
transfer_callback('http://127.0.0.1:7002/', API_TOKEN, src_nick, nick, amount)
|
||||
elif ds_dst != 'null':
|
||||
transfer_callback('http://127.0.0.1:7003/', API_TOKEN, src_nick, nick, amount)
|
||||
#except:
|
||||
# pass
|
||||
except:
|
||||
pass
|
||||
|
||||
@bot.message_handler(commands=['help'])
|
||||
def help(message):
|
||||
@ -103,7 +100,8 @@ def help(message):
|
||||
/user_id - Айди пользователя`
|
||||
|
||||
[Исходный код](https://gitea.del.pw/justuser/CryptoDM)
|
||||
[API и документация](https://cdm-api.del.pw/docs#/)
|
||||
[Документация UserAPI](https://gitea.del.pw/justuser/cdm_example_user_api)
|
||||
[UserAPI URL](https://cdm-api.del.pw/docs)
|
||||
''', parse_mode='Markdown')
|
||||
|
||||
@bot.message_handler(commands=['reg'])
|
||||
@ -334,14 +332,12 @@ class Gen_fp_mess_api(BaseModel):
|
||||
fp_id: str
|
||||
@app.post('/api/gen_fp_mess/')
|
||||
def gen_fp_mess_api(it: Gen_fp_mess_api):
|
||||
#try:
|
||||
if 1:
|
||||
try:
|
||||
token, nick, amount, chat_id, fp_id = it.token, it.nick, it.amount, it.chat_id, it.fp_id
|
||||
token, fp_id, chat_id = it.token, it.fp_id, it.chat_id
|
||||
keyboard = telebot.types.InlineKeyboardMarkup()
|
||||
url_button = telebot.types.InlineKeyboardButton('ОПЛАТИТЬ'
|
||||
, url=f'https://t.me/cdm_bank_bot?start={fp_id}')
|
||||
#, url=f'https://t.me/cdm_bank_bot?start={nick}_{amount}')
|
||||
keyboard.add(url_button)
|
||||
bot.send_message(int(chat_id), f'''
|
||||
`----- ЧЕК -----`
|
||||
@ -349,10 +345,9 @@ def gen_fp_mess_api(it: Gen_fp_mess_api):
|
||||
Получатель: `{nick}`
|
||||
`---------------`''', parse_mode='Markdown', reply_markup=keyboard)
|
||||
|
||||
#[ОПЛАТИТЬ](https://t.me/cdm_bank_bot?start={nick}_{amount})''', parse_mode='Markdown')
|
||||
return 'OK'
|
||||
#except:
|
||||
# return 'Error'
|
||||
except:
|
||||
return 'Error'
|
||||
|
||||
def run_api():
|
||||
uvicorn.run(app, host='0.0.0.0', port=7002)
|
||||
|
Loading…
Reference in New Issue
Block a user