-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
41 additions
and
26 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,40 @@ | ||
import requests | ||
from actions_toolkit import core | ||
|
||
|
||
class Action: | ||
def __init__(self, username: str, passwd: str, host: str = 'cordcloud.biz'): | ||
self.username = username | ||
def __init__(self, email: str, passwd: str, code: str = '', host: str = 'cordcloud.site'): | ||
self.email = email | ||
self.passwd = passwd | ||
self.code = code | ||
self.host = host.replace('https://', '').replace('http://', '') | ||
self.session = requests.session() | ||
|
||
def format_url(self, path): | ||
def format_url(self, path) -> str: | ||
return f'https://{self.host}/{path}' | ||
|
||
def check_in(self) -> str: | ||
def login(self) -> dict: | ||
login_url = self.format_url('auth/login') | ||
check_in_url = self.format_url('user/checkin') | ||
form_data = { | ||
'email': self.username, | ||
'email': self.email, | ||
'passwd': self.passwd, | ||
'code': '' | ||
'code': self.code | ||
} | ||
self.session.post(login_url, data=form_data) | ||
resp = self.session.post(login_url, data=form_data) | ||
return resp.json() | ||
|
||
def check_in(self) -> dict: | ||
check_in_url = self.format_url('user/checkin') | ||
resp = self.session.post(check_in_url) | ||
return resp.json()['msg'] | ||
return resp.json() | ||
|
||
def run(self): | ||
res = self.login() | ||
if res['ret'] != 1: | ||
raise Exception(f'CordCloud 帐号登录异常,错误日志:{res}') | ||
core.info(f'帐号登录成功,结果:{res}') | ||
|
||
def run(self) -> str: | ||
return self.check_in() | ||
res = self.check_in() | ||
if res['ret'] != 1: | ||
raise Exception(f'CordCloud 帐号自动签到续命异常,错误日志:{res}') | ||
core.info(f'帐号续命成功,结果:{res}') |
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