使用Telethon在一个Python脚本中创建多个机器人
我想在同一python脚本中创建多个机器人, 这些机器人相似,它们之间的唯一区别是令牌。
我想到的第一个想法是创建一个类包含bot脚本,然后每次创建一个新的bot时,我都会创建此类的新实例,并将机器人令牌传递给初始化函数。
我不确定是否可以使用Telethon在类内部创建一个机器人,我看到的所有示例都在使用功能和装饰。那么Telethon(MTPROTO)是否支持多个实例一起运行?
还是我需要同时运行它们?
代码示例对我非常有帮助。
谢谢。
I want to create multiple bots in the same python script,
these bots are similar, the only difference between them is the tokens.
the first idea that comes to my mind is to create a class contains the bot script, then I create new instance of this class each time I want to create a new bot, and pass the bot token to the init function.
I'm not sure if I can create a bot inside a class using telethon, all examples that I saw are using functions and decorations. Then does telethon (MTProto) supports multiple instances running together ?
Or do I need to run them concurrently ?
code examples will be very helpful for me.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在循环中,其他代码不会执行,而无需结束循环。
但是OFC您可以上课,然后
进行多线程
运行多个线程类似于同时运行多个不同的程序
单击此处以获取有关多线程的更多信息
我希望它有用。
In a loop the other codes wont execute without the ending of the loop.
But ofc you can make a class and then
do multithreading
Running several threads is similar to running several different programs concurrently
Click here for more about Multithreading
I hope it was helpful.