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