From 5c2ecb1fd69d36b10d032a8c72582b4f7ac2fa9f Mon Sep 17 00:00:00 2001 From: ngfchl Date: Fri, 21 Apr 2023 11:53:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=B9=BF=E5=91=8A=E8=AF=AD?= =?UTF-8?q?=E9=80=89=E6=8B=A9,=E4=BB=A5=E5=8F=8A=E9=A2=84=E7=95=99?= =?UTF-8?q?=E5=B9=BF=E5=91=8A=E8=8E=B7=E5=8F=96=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pt_site/UtilityTool.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pt_site/UtilityTool.py b/pt_site/UtilityTool.py index 57c00fa..2ec5006 100644 --- a/pt_site/UtilityTool.py +++ b/pt_site/UtilityTool.py @@ -124,14 +124,18 @@ class PtSpider: 'mobile': False }, delay=delay) - def send_text(self, message: str, title: str = '', url: str = None): - """通知分流""" - ad = [ + def select_ad(self): + # res = requests.get('http://api.ptools.fun/select_ad') + ads = [ 'PTools目前开发遇到困难,开发电脑性能不足,时常崩溃,欢迎赞助!', '为补贴开发,努力卖点农副产品,自家生纯净榨核桃油,如有需要欢迎联系我!', '广告位招租哟,欢迎投放广告!', ] - message = f'{ad[random.randint(0, len(ad)-1)]}\n{"*" * 30}\n{message}' + return random.choice(ads) + + def send_text(self, message: str, title: str = '', url: str = None): + """通知分流""" + message = f'{self.select_ad()}\n{"*" * 30}\n{message}' notifies = Notify.objects.filter(enable=True).all() res = '你还没有配置通知参数哦!' if len(notifies) <= 0: