我需要使用nohup在服务器上启动bot

问题描述

我需要在服务器上启动bot。我使用nohup,但是它是错误的。 telethon使用input()进行授权。但是不知道该功能。我该怎么办?

代码

from telethon import TelegramClient,events

api_id   = 0
api_hash = 'hash'

session = 'my'

client = TelegramClient('my',api_id,api_hash)


@client.on(events.NewMessage(incoming=True))
async def func(event):

    name_bot = '@betta_test'

    chat = await client.get_entity(name_bot)

    await event.message.forward_to(chat)


client.start()
client.run_until_disconnected()

解决方法

我用这个

nohup python3 /path/to/your/file.py >> log.txt &