优化广告语选择,以及预留广告获取接口

This commit is contained in:
ngfchl
2023-04-21 11:53:36 +08:00
parent 9d9370703b
commit 5c2ecb1fd6

View File

@@ -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目前开发遇到困难开发电脑性能不足时常崩溃欢迎赞助<img src="http://img.ptools.fun/pay.png" width="100%" align="center">',
'为补贴开发,努力卖点农副产品,自家生纯净榨核桃油,如有需要欢迎联系我!<img src="http://img.ptools.fun/wechat.png" width="100%" align="center">',
'广告位招租哟,欢迎投放广告!<img src="http://img.ptools.fun/wechat.png" width="100%" align="center">',
]
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: