如何将(更新:update,context:callbackContext)传递给我的功能而无需使用处理程序
我正在制作用于处理YouTube播放列表的电报机器人。
我有2个功能,并且两个功能都有(更新:更新,上下文:callbackContext)
gragmonse。
使用MessageHandler从MAIN调用第一个功能,并且它在没有错误的情况下运行。
但是第二个是从函数1中调用的。
我想知道如何在没有处理程序的情况下通过那些参数。我想以一种使用update.message
及其内部功能接受的方式说function2()
。
这是一个想法的示例:
def check_url(update: Update, context: CallbackContext):
get_videos_ids()
def get_videos_ids(update: Update, context: CallbackContext):
some code that use upadte.functions
if __name__ == "__main__":
updater.dispatcher.add_handler(MessageHandler(Filters.all, check_url))
I'm making Telegram bot for processing Youtube playlists.
I have 2 functions, and both of them have (update:Update, context: callbackContext)
arguments.
The first function is called from main using messageHandler and it runs without errors.
But the second one is called from function 1.
I want to know how to pass those arguments without handlers. I want to say function2()
in such a way that accept using update.message
and other functions inside it.
Here is an example for the idea:
def check_url(update: Update, context: CallbackContext):
get_videos_ids()
def get_videos_ids(update: Update, context: CallbackContext):
some code that use upadte.functions
if __name__ == "__main__":
updater.dispatcher.add_handler(MessageHandler(Filters.all, check_url))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需将更新和上下文传递给下一个功能:
Just pass down the update and the context to the next function as such: