izuemon commited on
Commit
9f8457e
·
verified ·
1 Parent(s): 4aa01a5

Update turbowarp-server/qr-converter.py

Browse files
Files changed (1) hide show
  1. turbowarp-server/qr-converter.py +14 -5
turbowarp-server/qr-converter.py CHANGED
@@ -24,8 +24,8 @@ last_n1 = None
24
 
25
  while True:
26
  try:
27
- # 修正ポイント: name を指定する
28
- n1 = str(tw.get_variable(name="n1"))
29
 
30
  if n1 != last_n1:
31
  last_n1 = n1
@@ -45,10 +45,19 @@ while True:
45
  # 既読にする
46
  tw.set_variable(name="n1", value="0" + "1" + recv_id)
47
 
 
48
  url = f"https://20.rf.gd/set.php?project_id={recv_id}"
49
- res = requests.get(url)
50
- data = res.json()
51
- short_id = data.get("short_id", "")
 
 
 
 
 
 
 
 
52
 
53
  print("short_id:", short_id)
54
 
 
24
 
25
  while True:
26
  try:
27
+ n1_raw = tw.get_variable(name="n1")
28
+ n1 = str(n1_raw).replace('☁ n1', '').strip() # '☁ n1' 対策
29
 
30
  if n1 != last_n1:
31
  last_n1 = n1
 
45
  # 既読にする
46
  tw.set_variable(name="n1", value="0" + "1" + recv_id)
47
 
48
+ # APIアクセス
49
  url = f"https://20.rf.gd/set.php?project_id={recv_id}"
50
+ try:
51
+ res = requests.get(url, cookies={"__test": "872039d283902860e895efb6018d2632"}, timeout=5)
52
+ res.raise_for_status()
53
+ data = res.json()
54
+ short_id = data.get("short_id", "000")
55
+ except requests.exceptions.RequestException as e:
56
+ print("API接続エラー:", e)
57
+ short_id = "000"
58
+ except ValueError:
59
+ print("API JSON解析エラー")
60
+ short_id = "000"
61
 
62
  print("short_id:", short_id)
63