# Source: https://gitee.com/yangro/ql/blob/main/fsy.py
# Raw: https://gitee.com/yangro/ql/raw/main/fsy.py
# Repo: yangro/ql
# Path: fsy.py
# UploadedAt: 2023-10-25T14:45:53+08:00
# SHA256: 97c05aeef8fab7dbfce623a6bfe368e162a692a788496fbadfe2598920d1b838
# Category: web版/抓包
# Evidence: web/H5关键词 + cookie/token/header

# coding=utf-8
"""
每日8:30
cron: 0 30 7 * * ?
new Env("飞速云机场")
"""

import requests
import notify
import utils.tool as TOOL
import utils.getCookie as getCookie

global msg

msg = """
名称|状态
:--:|:--:
"""


def main():
    users = getCookie.GetQlEnvs().getCookies('FSY_COOKIE')
    print("🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉\n")
    print("获取到: " + str(len(users)) + " 个用户")
    print("-------------------------------------------")

    for user in users:
        signIn(user)


# 签到
def signIn(user):
    global msg
    url = 'https://feisu261.xyz/user/checkin'
    data = " "
    headers = {
        "Host": "feisu261.xyz",
        "accept": "application/json, text/javascript, */*; q=0.01",
        "origin": "https://feisu261.xyz",
        "x-requested-with": "XMLHttpRequest",
        "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/79.0.3945.147 Safari/534.24 XiaoMi/MiuiBrowser/14.3.21",
        "sec-fetch-site": "same-origin",
        "sec-fetch-mode": "cors",
        "referer": "https://feisu261.xyz/user",
        "accept-language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
        "cookie": user['cookie']
    }
    res = requests.post(url=url, data=data, headers=headers)
    json = res.json()

    print(user['name'] + " ---> " + json['msg'] + "\n")
    msg += user['name'] + "|" + json['msg'] + "\n\n"

    print("-------------------------------------------\n")


main()

print("🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉")

notify.send("飞速云机场", msg)
