Skip to content

Commit 8ca5d86

Browse files
committed
update Garena NewsID
1 parent 3c27a0c commit 8ca5d86

File tree

2 files changed

+10
-30
lines changed

2 files changed

+10
-30
lines changed

balloon.py

+5-21
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ def parseCode(inputList):
1818
def getGarenaComment(rootID=0,num=5):
1919
url = "https://commenttw.garenanow.com/api/comments/get/"
2020
header = {'User-Agent': 'Garenagxx/2.0.1909.2618 (Intel x86_64; zh-Hant; TW)',"Content-Type": 'application/json'}
21-
news = ["32165","32164","32159"] #"32153"
21+
news = ["32165"] #"32164", "32159", "32153"
2222
data = {"obj_id": "tw_32775_newnews_{}".format(random.choice(news)),
23-
#"obj_id": "tw_32775_newnews_32164",
24-
#"obj_id": "tw_32775_newnews_32159",
2523
"root_id": 0,
2624
"size": num, #留言數量
2725
"replies": 10,
@@ -89,9 +87,9 @@ def getPosConfirm():
8987
print("已獲取輸入框位置: {}".format(posInbox))
9088
return posInbox
9189
def confirmObject(errPrint=True,errNum=5):
92-
posConfirm = None
93-
errSubmit = 0
9490
for i in range(2):
91+
posConfirm = None
92+
errSubmit = 0
9593
while posConfirm is None and errSubmit < errNum:
9694
checkKeyEnd()
9795
posConfirm = pyautogui.locateCenterOnScreen('imgs/confirm.png', confidence=0.8)
@@ -101,7 +99,7 @@ def confirmObject(errPrint=True,errNum=5):
10199
print("出現異常,無法跳出確認視窗")
102100
break
103101
pyautogui.click(posConfirm)
104-
time.sleep(0.3)
102+
time.sleep(0.2)
105103

106104
def balloonExchange():
107105
posExArea = pyautogui.locateCenterOnScreen('./imgs/exArea.png') #Exchange Area
@@ -153,21 +151,7 @@ def checkFinish():
153151
#pyautogui.write(code)
154152
pyautogui.hotkey('ctrl', 'v')
155153
pyautogui.click(posSubmit)
156-
errSubmit = 0
157-
for i in range(2):
158-
ok_position = pyautogui.locateCenterOnScreen('imgs/confirm.png', confidence=0.8)
159-
while ok_position is None and errSubmit < 5:
160-
checkKeyEnd()
161-
ok_position = pyautogui.locateCenterOnScreen('imgs/confirm.png', confidence=0.8)
162-
#print(f'正在擷取「確定」位置:{ok_position}')
163-
errSubmit += 1
164-
time.sleep(0.15)
165-
if errSubmit >= 5:
166-
break
167-
pyautogui.click(ok_position)
168-
time.sleep(0.1)
169-
if errSubmit >= 5:
170-
print(f'輸入序號時出現異常,無法跳出確認視窗')
154+
confirmObject(errNum = 5)
171155
count = count +1
172156
time.sleep(0.1)
173157
if keyboard.is_pressed('p'): #Paused

balloonCMD.py

+5-9
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def parseCode(inputList):
1414
def getGarenaComment(rootID=0,num=5):
1515
url = "https://commenttw.garenanow.com/api/comments/get/"
1616
header = {'User-Agent': 'Garenagxx/2.0.1909.2618 (Intel x86_64; zh-Hant; TW)',"Content-Type": 'application/json'}
17-
news = ["32165","32164","32159"] #"32153"
17+
news = ["32165"] #"32164", "32159", "32153"
1818
data = {"obj_id": "tw_32775_newnews_{}".format(random.choice(news)),
1919
"root_id": 0,
2020
"size": num, #留言數量
@@ -58,10 +58,6 @@ def codeSubmit(token,code):
5858
res = requests.post(url, headers=header, data=json.dumps(data))
5959
resJson = json.loads(res.text)
6060
return resJson
61-
if "error" in resJson.keys():
62-
print(errDic[resJson['error']])
63-
else:
64-
print(resJson)
6561
def getBalloon(token):
6662
countSubmit = countSuccess = errCode = allAmount = 0
6763
time1 = time.time()
@@ -73,17 +69,17 @@ def getBalloon(token):
7369
if "error" in res.keys():
7470
if res['error'] == "ERROR__ENTER_CODE_AMOUNT_OUT_OF_QUOTA" or allAmount == 60:
7571
time2 = time.time()
76-
print("\n已獲取{}/60顆氣球,共兌換{}次、費時{}秒,準備開始自動兌換獎勵。".format(countSuccess,countSubmit,round(time2-time1,2)))
77-
time.sleep(0.5)
72+
print("\n已獲取{}/60顆氣球,共嘗試{}次、費時{}秒,準備開始自動兌換獎勵。".format(countSuccess,countSubmit,round(time2-time1,2)))
73+
time.sleep(1)
7874
return True
7975
print("錯誤!{}".format(errDic[res['error']]))
80-
time.sleep(0.3)
76+
time.sleep(0.4)
8177
else:
8278
allAmount = res["enter_code_amount"]
8379
curAmount = res["current_token_amount"]
8480
print("成功!已兌換{}顆氣球,當前擁有{}顆氣球".format(allAmount,curAmount))
8581
countSuccess +=1
86-
time.sleep(1.2)
82+
time.sleep(1.6)
8783
def redeemBalloon(token,item_id):
8884
url = "https://bargain.lol.garena.tw/api/redeem"
8985
header = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36',

0 commit comments

Comments
 (0)