前有 WgpSec 安全团队提供的 WgpSecBot
后有 CTFhub 提供的比赛赛事日历
再加上最近在摆烂开发,博客啥也没干,于是
拼接起来,做一个比赛信息推送 Bot 吧!
下面的 token 需要参照 WgpSecBot 里面获取 API,自行替换
#encoding=utf8 import json import time import urllib import requests proxies={ "http":None, "https":None, } data='{"offset":0,"limit":5}' url="https://api.ctfhub.com/User_API/Event/getUpcoming" response=requests.post(url,data,proxies=proxies) contest_up=response.json() result=[] for x in contest_up['data']['items']: result.append("比赛名称:%s"%(x['title'],)) result.append("比赛时间:%s ~ %s"%(time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(x['start_time'])),time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(x['end_time'])))) data='{"event_id": %s}'%(x['id'],) url="https://api.ctfhub.com/User_API/Event/getInfo" response=requests.post(url,data,proxies=proxies) contest_detail=response.json() result.append("比赛类型:%s-%s"%(contest_detail['data']['class'],contest_detail['data']['form'])) result.append("比赛网址:%s"%(contest_detail['data']['official_url'],)) result.append("————————————") result.append("消息来源:CTFHub") content={"txt":"\n".join(result)} token="YOUR_TOKEN"; url="https://api.bot.wgpsec.org/push/%s?%s"%(token,urllib.parse.urlencode(content)) response=requests.get(url,proxies=proxies)