0

在这里有一个嵌套结构,它开始于

@bot.message_handler(content_types=["text"])
def handle_text (message, user_markup=None):

紧接着是嵌套结构,这个函数就在里面

def wallet(message):
    if message.text == 'Wallet NST':
       sent=bot.send_message(message.chat.id, """Crypto currency is an Ethereum token.
    NST Smart Contract Token Address is as follows:
    (0xD89040Ac9823B72F64d71f66Fa2DeAE7C8520671).
    Please make sure you are using the right smart contract or your funds may be irretrievably lost. \n
    INFORM YOUR WALLET NST(NEW SOLUTION ) :""")
      bot.register_next_step_handler(sent, salva)

def guard(message):
    archive=open('oriondb.txt', 'w')
    archive.write(int(messagefrom_user.id)  + message.from_user.username + message.chat.text )
    bot.send_message(message.chat.id, 'CARTEIRA SALVA COM SUCESSO!')
    bot.register_next_step_handler( handle_text)

我想将答案保存到 txt 文件或数据库中,如何使用 pytelegramBotAPI 执行此操作?

4

1 回答 1

0

我认为它应该工作:

@bot.message_handler(content_types=["text"])
def wallet(m):
cid = m.chat.id

if m.text == 'Wallet NST':
   bot.register_next_step_handler(sent, salva)
   sent=bot.send_message(cid, """Crypto currency is an Ethereum token.
   NST Smart Contract Token Address is as follows:
   (0xD89040Ac9823B72F64d71f66Fa2DeAE7C8520671).
   Please make sure you are using the right smart contract or your funds may be 
   irretrievably lost. \n
   INFORM YOUR WALLET NST(NEW SOLUTION ) :""")


archive=open('oriondb.txt', 'a')
archive.append(str(cid)  + m.chat.username + m.chat.text )
bot.send_message(cid, 'CARTEIRA SALVA COM SUCESSO!')
于 2020-02-18T08:52:04.953 回答