From 86ce4cea1cb59e81814b2f99d72cb396c9464b44 Mon Sep 17 00:00:00 2001 From: justuser Date: Sat, 27 Jul 2024 10:12:07 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=81=D0=BC=D0=B5=D0=BD=D0=B0=20=D0=BD=D0=B8?= =?UTF-8?q?=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ds.py | 26 ++++++++++++++++++++------ tg.py | 14 ++++++++++++++ 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/ds.py b/ds.py index 6cad7f7..f753088 100644 --- a/ds.py +++ b/ds.py @@ -59,8 +59,8 @@ async def checkauth(message, reg = False): pass else: await send('''Пожалуйста, зарегистрируйтесь или войдите: -`!reg Nickname 1234567890` -`!login Nickname 1234567890` +`/reg Nickname 1234567890` +`/login Nickname 1234567890` Ник вводить желательно игровой. Пароль любой.''') @@ -70,7 +70,7 @@ def command(com, message): if message.author != bot.user: # Если не публичный чат if message.channel.type != discord.ChannelType.text: - if message.content.startswith(f'!{com}'): + if message.content.startswith(f'/{com}'): return True async def help(message): @@ -83,6 +83,7 @@ async def help(message): /login ник пароль - Войти в аккаунт /unreg - Выйти из аккаунта /passwd пароль - Смена пароля +/nick ник - Смена ника /bal - Баланс /pay ник сумма - Перевод ` @@ -141,7 +142,7 @@ async def login(message): else: await send('Пароль не совпадает') else: - await send('!login ник пароль') + await send('/login ник пароль') async def unreg(message): send = message.channel.send @@ -160,7 +161,20 @@ async def passwd(message): else: await send('Что-то пошло не так...') else: - await send('!passwd пароль') + await send('/passwd пароль') + +async def nick(message): + send = message.channel.send + if await checkauth(message): + if len(message.content.split()) == 2: + com, nicl = message.content.split() + id = user_in_db(API_TOKEN, ds=message.author.id) + if update_nick(API_TOKEN, id, new_nick) == 'OK': + await send('Ник успешно изменён') + else: + await send('Что-то пошло не так...') + else: + await send('/nick ник') async def pay(message): send = message.channel.send @@ -191,7 +205,7 @@ async def pay(message): print(22222) transfer_callback('http://127.0.0.1:2222/', API_TOKEN, src_nick, nick, amount) else: - await send('!pay ник количество') + await send('/pay ник количество') @bot.event async def on_message(message): diff --git a/tg.py b/tg.py index c435cc7..ac62b07 100644 --- a/tg.py +++ b/tg.py @@ -60,6 +60,7 @@ def help(message): /login ник пароль - Войти в аккаунт /unreg - Выйти из аккаунта /passwd пароль - Смена пароля +/nick ник - Смена ника /bal - Баланс /pay ник сумма - Перевод """)} @@ -141,6 +142,19 @@ def passwd(message): bot.reply_to(message, '/passwd новый_пароль') +@bot.message_handler(commands=['nick']) +def nick(message): + if checkauth(message): + if len(message.text.split()) == 2: + com, new_nick = message.text.split() + id = user_in_db(API_TOKEN, tg=message.chat.id) + if update_nick(API_TOKEN, id, new_nick) == 'OK': + bot.reply_to(message, 'Ник успешно изменён') + else: + bot.reply_to(message, 'Что-то пошло не так...') + else: + bot.reply_to(message, '/nick новый_ник') + @bot.message_handler(commands=['bal']) def bal(message): if checkauth(message):