-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #279 from AmiyaBot/V6-dev
V6 dev
- Loading branch information
Showing
6 changed files
with
72 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v6.5.0 | ||
v6.5.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule pluginsDev
updated
10 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
amiyabot==1.9.9 | ||
amiyabot==2.0.1 | ||
attrdict~=2.0.1 | ||
baidu-aip | ||
dhash~=1.3 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,52 @@ | ||
from amiyabot.log import UserLogger | ||
import time | ||
import json | ||
import hashlib | ||
import aiohttp | ||
|
||
from amiya import run_amiya | ||
from amiyabot.util import argv | ||
from pluginsServer.src import server, api | ||
|
||
AFDIAN_USER = argv('afdian-user') | ||
AFDIAN_TOKEN = argv('afdian-token') | ||
|
||
class Mylogger: | ||
def info(self, text: str): | ||
... | ||
|
||
def error(self, text: str): | ||
... | ||
@server.server.app.get('/get_sponsors') | ||
async def get_sponsors(): | ||
if not AFDIAN_TOKEN or not AFDIAN_USER: | ||
return [] | ||
|
||
def debug(self, text: str): | ||
... | ||
curr_page = 1 | ||
total_page = 1 | ||
sponsor_list = [] | ||
|
||
def warning(self, text: str): | ||
... | ||
while curr_page <= total_page: | ||
sec = int(time.time()) | ||
params = json.dumps({'page': curr_page}) | ||
data = { | ||
'user_id': AFDIAN_USER, | ||
'params': params, | ||
'ts': sec, | ||
'sign': hashlib.md5( | ||
f'{AFDIAN_TOKEN}params{params}ts{sec}user_id{AFDIAN_USER}'.encode(encoding='utf-8') | ||
).hexdigest(), | ||
} | ||
headers = {'Content-Type': 'application/json'} | ||
url = 'https://afdian.com/api/open/query-sponsor' | ||
|
||
def critical(self, text: str): | ||
... | ||
async with aiohttp.ClientSession() as session: | ||
async with session.post(url, data=json.dumps(data), headers=headers) as res: | ||
res_content = await res.json() | ||
if res_content['ec'] == 200: | ||
total_page = res_content['data']['total_page'] | ||
sponsor_list += res_content['data']['list'] | ||
else: | ||
break | ||
|
||
curr_page += 1 | ||
|
||
UserLogger.logger = Mylogger() | ||
return json.dumps(sponsor_list, ensure_ascii=False) | ||
|
||
if __name__ == "__main__": | ||
|
||
if __name__ == '__main__': | ||
run_amiya(server.server.serve()) |