用户:
水翎稞查看:10 回复:13 评论:10 创建时间:2022-02-13T12:46:48
import requests, json, random, time
import datetime
#星阁自动招人代码
#功能:1、实时改变工作室的简介,顶工作室
# 2、获取申请加入的名单,自动通过
# 3、所有自动通过的人的id与用户名自动记录到log.json
#自动通过时,一小时内同一个人只可以自动通过一次,防止有人恶意退出重进刷屏。自动判断赞数,三赞以上才给过
class WorkShop:
def __init__(self, hd):
self.hd = hd
def getDetail(self, urid):
self.url = f"https://api.codemao.cn/web/shops/{url_id}"
self.result = requests.get(self.url)
return [self.result, json.loads(self.result.text)]
def getwsid(self, urid): # wsid:真正的工作室id;urid:url中的工作室id
self.id = self.getDetail(urid)[1]
self.id = self.id["shop_id"]
return self.id
def getHeadurl(self, urid):
self.headurl = self.getDetail(urid)[1]
self.headurl = self.headurl["preview_url"]
return self.headurl
def getlevel(self, urid):
self.level = self.getDetail(urid)[1]["level"]
return self.level
def audit(self, wsid, user_id, 可以吗):
self.url = "https://api.codemao.cn/web/work_shops/users/audit"
if 可以吗:
self.data = {'id': wsid, 'user_id': user_id, 'status': "ACCEPTED"}
else:
self.data = {'id': wsid, 'user_id': user_id, 'status': "UNACCEPTED"}
self.result = requests.post(self.url, json=self.data, headers=self.hd)
print("audit")
return self.result
def updateDetail(self, wsid, description, name, head_url):
self.url = "https://api.codemao.cn/web/work_shops/update"
self.data = {"description": description, "id": wsid, "name": name, "preview_url": head_url}
self.result = requests.post(self.url, headers=self.hd, json=self.data)
return self.result
def sendReview(self, urid, text):
self.url_fasong = f"https://api.codemao.cn/web/discussions/{urid}/comment"
self.data = {"content": text, "rich_content": text, 'source': "WORK_SHOP"}
self.result = requests.post(self.url_fasong, json=self.data, headers=self.hd)
print("send")
return self.result
def getWillJoin(self, wsid, offset=0, limit=40):
self.url = f"https://api.codemao.cn/web/work_shops/users/unaudited/list?offset={offset}&limit={limit}&id={wsid}"
self.result = requests.get(self.url,headers=self.hd)
return [self.result,json.loads(self.result.text)]
class User:
def __init__(self, hd):
self.hd = hd;
def getDetail(self,id):
self.url = f"https://api.codemao.cn/creation-tools/v1/user/center/honor?user_id={id}"
self.result = requests.get(self.url,headers=self.hd)
return [self.result,json.loads(self.result.text)]
def find(n,l):
for i in l:
if i == n:
return True
return False
def findin(n,l,a):
for i in l:
if i[a] == n:
return True
return False
def canJoin(n,l,a,name):
for i in l:
if i[a] == n:
if i[0] == name:
return False
return True;
header = {
"cookie": ":)"}
ws = WorkShop(header)
us = User(header)
name = "星阁"
head = "https://cdn-community.codemao.cn/47/community/d2ViXzUwMDFfMTAwNDIyNDJfMF8xNjI2OTQxNjYxNDUwXzhkZDdmYjIx.png"
i = 0
with open("blackId.json", "r", encoding="utf-8-sig") as f:
blackId = json.load(f)
with open("words.json", "r", encoding="utf-8") as f:
words = json.load(f)
print(blackId, words)
while True:
i += 1
d = datetime.datetime.now()
aaa = None
try:
now = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
description = f"星阁是一个驿站,有初至猫站之人匆匆路过。海纳百川,想来就来,想走就走,无需多言。时间:{now},一小时内每人自动通过一次"
print(i, ws.updateDetail(7744, description, name, head))
text = ws.getWillJoin(7744)[1]
print(i, text)
except:
print("失败")
if text["items"]!=[]:
id = text["items"][0]["user_id"]
nickname = text["items"][0]["nickname"]
r = us.getDetail(10042242)
like = r[1]['liked_total']
y = d.year
m = d.month
dy = d.day
h = d.hour
mi = d.minute
s = d.second
timeCode = f"{y},{m},{dy},{h}"
findornot = find(id, blackId)
if not findornot and like>=3:
word = random.choice(words)
text = f"{nickname} {word} 地加入星阁"
with open("log.json", "r", encoding="utf-8") as f:
aaa = json.load(f)
print(nickname,canJoin(timeCode,aaa,2,nickname))
if canJoin(timeCode,aaa,2,nickname):
ws.sendReview(8129, text)
ws.audit(7744, id, True)
aaa.append([nickname,id,timeCode,{"year":y,"month":m,"day":dy,"hour":h,"minute":mi,"second":s},text,True])
time.sleep(3)
else:
aaa.append([nickname,id,timeCode,{"year":y,"month":m,"day":dy,"hour":h,"minute":mi,"second":s},"进入过于频繁",False])
ws.audit(7744, id, False)
with open("log.json", "w", encoding="utf-8") as f:
f.write(json.dumps(aaa,sort_keys = False,indent=4,ensure_ascii=False))
else:
ws.audit(7744, id, False)
with open("log.json", "r", encoding="utf-8") as f:
aaa = json.load(f)
if findornot and like<3:
aaa.append([nickname,id,timeCode,{"year":y,"month":m,"day":dy,"hour":h,"minute":mi,"second":s},f"点赞小于15({like})且 ",False])
elif like<3:
aaa.append([nickname,id,random.randint(1,10086),{"year":y,"month":m,"day":dy,"hour":h,"minute":mi,"second":s},f"点赞小于15({like})",False])
elif findornot:
aaa.append([nickname,id,timeCode,{"year":y,"month":m,"day":dy,"hour":h,"minute":mi,"second":s},f"黑名单",False])
with open("log.json", "w", encoding="utf-8") as f:
f.write(json.dumps(aaa,sort_keys = False,indent=4,ensure_ascii=False))
time.sleep(1)