Skip to content
This repository has been archived by the owner on Dec 12, 2023. It is now read-only.

Commit

Permalink
修补一些小问题
Browse files Browse the repository at this point in the history
  • Loading branch information
XGZ authored and XGZ committed Jan 31, 2023
1 parent 1bca8ea commit e7aa272
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 51 deletions.
4 changes: 2 additions & 2 deletions Web/templates/gi.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ <h1>{% block title %}菜单{% endblock %}</h1>
<form action="{{ url_for('apg.gi') }}" method="post">
<label>
<select name="gi" class="form-select" aria-label="Default select example">
<option value="0" selected = "selected">不保留配置文件更新</option>
<option value="1">保留配置文件更新</option>
<option value="0">不保留配置文件更新</option>
<option value="1" selected = "selected">保留配置文件更新</option>
</select>
</label>
<button type="submit" class="btn btn-info">更新软件</button>
Expand Down
57 changes: 17 additions & 40 deletions conn/bots/getUpdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import json
import re

import requests
import httpx

from conn.Template.ancestors import Father

Expand All @@ -22,12 +22,8 @@ def __init__(self):
"offset": 0,
"timeout": 100
}
self.proxies = {
"https": self.AdReg.get('Proxy')['Proxy'],
"http": self.AdReg.get('Proxy')['Proxy']
}
self.proxies = self.AdReg.get('Proxy')['Proxy'] if self.AdReg.get('Proxy')['Proxy'] else None
self.offset = None
self.verify = None if self.AdReg.get('Proxy')["TG_API_HOST"] == "https://api.telegram.org" else False
self.status = ["left", "member", "administrator", "creator"]

def http_post(self, url, data):
Expand All @@ -40,24 +36,18 @@ def http_post(self, url, data):
try:
if not re.findall('(/bot\w+)', self.Token):
self.Update()
resp = requests.post(
url=self.url + self.Token + url,
headers=self.headers,
proxies=self.proxies,
data=json.dumps(data),
verify=self.verify,
timeout=2000
)
resp.close()
if resp.status_code == 200:
return [resp.status_code, resp.json()]
# 502 和409表示没有消息
elif resp.status_code in [502, 409]:
return [200, {"ok": True, "result": []}]
elif resp.status_code == 404:
return [resp.status_code, {"ok": False, "result": [f'404: {resp.text}']}]
else:
return [resp.status_code, resp.json()]
with httpx.Client(proxies=self.proxies, timeout=200, headers=self.headers) as client:
resp = client.post(url=self.url + self.Token + url, data=json.dumps(data))
resp.close()
if resp.status_code == 200:
return [resp.status_code, resp.json()]
# 502 和409表示没有消息
elif resp.status_code in [502, 409]:
return [200, {"ok": True, "result": []}]
elif resp.status_code == 404:
return [resp.status_code, {"ok": False, "result": [f'404: {resp.text}']}]
else:
return [resp.status_code, resp.json()]
except Exception as e:
return [0, {'ok': False, 'result': [e]}]

Expand All @@ -75,7 +65,7 @@ def get_long_link(self, offset: int = None, limit: int = 100, timeout: int = 0,
"""
try:
data = {
'offset': f"{offset if offset else self.offset}",
'offset': self.offset,
'limit': limit,
'timeout': timeout,
'allowed_updates': allowed_updates
Expand Down Expand Up @@ -236,20 +226,7 @@ def Update(self):
更新GetUpdate和父类
:return:
"""
self.marking_time()
self.flash_Config()
self.url = self.AdReg.get('Proxy')["TG_API_HOST"]
self.Token = "/bot" + self.AdReg.get('Token')
self.headers = {"Content-Type": "application/json",
"Connection": "close",
}
self.data = {
"offset": 0,
"timeout": 100
}
self.proxies = {
"https": self.AdReg.get('Proxy')['Proxy'],
"http": self.AdReg.get('Proxy')['Proxy']
}
self.offset = None
self.verify = None if self.AdReg.get('Proxy')["TG_API_HOST"] == "https://api.telegram.org" else False
self.status = ["left", "member", "administrator", "creator"]
self.proxies = self.AdReg.get('Proxy')['Proxy']
4 changes: 3 additions & 1 deletion conn/mission/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ def Team(self, data):
elif sun < 10:
time.sleep(int(data['interval']) / 4)
elif sun < 20:
time.sleep(2)
time.sleep(3)
else:
time.sleep(1)
return False

return True
Expand Down
20 changes: 15 additions & 5 deletions conn/mission/sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,23 +86,28 @@ def finishing_text(self, text_str: str):

# 如果一行出现两个关键字
for text2 in re_text:

text2 = list(text2)
mark = ""
mark_text = re.findall("((?:NOT|RUN)+)", text2[0])
if mark_text:
mark = mark_text[0]
text2[0] = text2[0][3::]

# 如果值存在关键字跳过执行
if re.findall('(?:shopId\d?|venderId\d?|shopid\d?|venderid\d?)', text2[-1]):
if re.findall('(?:shopId\d|venderId\d|shopid\d|venderid\d)', text2[-1]):
self.logger.write_log(f"检测到屏蔽关键字屏蔽内容是: {poi}")
continue

if text2[0] in rep.keys():
# 如果关键字在数组中执行并且清空字典
ex_name = self.sundries.looking(rep.get(text2[0])["expport"])
if ex_name:
TYPE = re.findall("https://(\w{2})", spell)
if TYPE:
spell += f'export NOT_TYPE="{TYPE[0]}";'
else:
spell += 'export NOT_TYPE="no";'
# 发送去队列了
spell += 'export NOT_TYPE="no";'
self.sundries.tx_compared([rep.get(text2[0])['mark'], ex_name, spell])
else:
spell = ''
Expand All @@ -112,7 +117,7 @@ def finishing_text(self, text_str: str):
# 如果关键字不在数组加入数组
rep.setdefault(text2[0], {
"mark": mark,
"expport": re_text[0][0]
"expport": text2[0]
})
spell += text2[0] + '="' + str(text2[1]) + '";'
if spell:
Expand All @@ -121,8 +126,13 @@ def finishing_text(self, text_str: str):
if not ex_name:
self.logger.write_log(f"没有查询到 {poi}")
return []
# 尝试获取活动类型
TYPE = re.findall("https://(\w{2})", spell)
if TYPE:
spell += f'export NOT_TYPE="{TYPE[0]}";'
else:
spell += 'export NOT_TYPE="no";'
# 发送去队列了
spell += 'export NOT_TYPE="no";'
self.sundries.tx_compared([mark, ex_name, spell])
return [0]
return []
Expand Down
7 changes: 4 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# pip3 install -r requirements.txt

# 其他库
httpx
httpx[socks]
requests
requests[socks]
pysocks
ruamel.yaml == 0.17.21
Flask > 1
aiohttp >= 3.8.3
APScheduler > 1
colorlog >= 6.7.0

socksio >= 1.0.0
Flask-Cors
pyinstaller
requests[socks]
pysocks
# ws需要插件
simple-websocket
Flask-SocketIO==5.2.0
Expand Down

0 comments on commit e7aa272

Please sign in to comment.