Skip to content

Commit

Permalink
Update bika.py
Browse files Browse the repository at this point in the history
加入当前经验和等级通知
  • Loading branch information
zhonghuaifang authored Feb 7, 2023
1 parent 12da9c3 commit 3222f6e
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions function/bika/bika.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from http import client
from sendNotify import *
import random
import string
import sys

sys.path.append("My-Actions/function/bika/")
from sendNotify import *
from http import client

sendNotify = sendNotify()

Expand All @@ -17,7 +17,9 @@
pica_api_base_url = "https://%s/" % pica_api_host
sign_in_path = "auth/sign-in"
punch_in_path = "users/punch-in"
profile_path = "/users/profile"
POST = "POST"
GET = "GET"

# noinspection SpellCheckingInspection
api_key = "C69BAF41DA5ABD1FFEDC6D2FEA56B"
Expand All @@ -38,7 +40,8 @@

def send_request(path: string, method: string, body: string = None, token: string = None) -> dict:
current_time = str(int(time.time()))
nonce = "".join(random.choices(string.ascii_lowercase + string.digits, k=32))
nonce = "".join(random.choices(
string.ascii_lowercase + string.digits, k=32))
raw = path + current_time + nonce + method + api_key
raw = raw.lower()
h = hmac.new(api_secret.encode(), digestmod=hashlib.sha256)
Expand Down Expand Up @@ -77,6 +80,10 @@ def punch_in(token: string):
return send_request(punch_in_path, POST, token=token)


def profile(token: string):
return send_request(profile_path, GET, token=token)


if __name__ == '__main__':
if os.environ['BIKA_USER'] == "" or os.environ['BIKA_PASS'] == "":
print("未填写哔咔账号密码 取消运行")
Expand All @@ -91,5 +98,15 @@ def punch_in(token: string):
msg = '重复签到 - Already punch-in'
print(msg)

profile_msg = ''
profile_response = profile(current_token)
if profile_response["code"] == "200":
profile_result = profile_response["data"]["user"]
profile_msg = (
"\n用户名: %s" % profile_result["name"],
"\n等级: %s" % profile_result["level"],
"\n经验: %s" % profile_result["exp"],
)

if SEND_KEY == '':
sendNotify.send(title=u"哔咔漫画自动打哔咔", msg="【哔咔漫画自动签到】\n" + msg)
sendNotify.send(title=u"哔咔漫画自动打哔咔", msg="【哔咔漫画自动签到】\n" + msg+profile_msg)

0 comments on commit 3222f6e

Please sign in to comment.