结合后台任务和命令

问题描述 投票:0回答:1

我正在尝试在我的漫游器上运行后台任务和命令,我曾尝试使用@tasks.loop(seconds='timehere')我的后台任务的装饰器。我的任务仅适用于github示例here,但现在我不确定如何将命令与我的机器人结合使用。

我试图在后台运行的任务是使用Google API从文档中获取txt并将其与先前获取的txt文件进行比较以检测更改的功能。>

originalDoc = fetchDoc.fetch(currentDoc)  #fetchDoc - Google API that gets txt 

        with open('referenceDoc.txt', 'r') as f:
            referenceDoc = f.read()

        if (len(compare(referenceDoc, originalDoc))) == 0:  #compare() is a function I wrote that compares strings
            changes = False
            print('no changes\n')
        else:
            changes = True
            for x in compare(referenceDoc, originalDoc):
                # compares the pulled document with the one stored locally
                print(x)

        with open('referenceDoc.txt', 'w') as f:
            # updates the local file with the current original file
            f.write(originalDoc)

请和谢谢大家!

我正在尝试在我的机器人上运行后台任务和命令,我曾尝试将@ tasks.loop(seconds ='timehere')装饰器用于后台任务。我的任务仅在此处的github示例中有效,...

python discord discord.py-rewrite
1个回答
0
投票

也许这行得通吗?

© www.soinside.com 2019 - 2024. All rights reserved.