attachments.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:TnyBot-Discord 作者: 00firestar00 项目源码 文件源码
def __init__(self, bot, config_file):
        super().__init__(bot)

        opener = urllib_request.build_opener()
        opener.addheaders = [("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) Tnybot/1.0 Chrome/55.0")]
        urllib_request.install_opener(opener)

        config = configparser.RawConfigParser()
        config.read(config_file)

        self.base_dir = config["Images"]["dir"]
        self.checksum = config["Images"]["checksum"] == "True" or False
        if self.checksum:
            print(
                """!!!! Warning! Using checksums to detect duplicate images.
                Processing image hashes may take awhile on older CPUs.
                This will save disk space, but will cause an increase in downloads on restart.
                """
            )

        self.channels = self.get_config_values(config, "Channels")
        self.merged_channels = self.get_config_values(config, "MergedChannels") or []
        self.upload_channels = self.get_config_values(config, "Upload")

        if not self.bot.unit_tests:  # pragma: no cover
            self.bot.loop.create_task(self.background())
            # self.bot.loop.create_task(self.upload())
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号