├── .github └── workflows │ └── main.yml ├── .idea └── vcs.xml ├── README.md └── smzdm_auto_sign_bot.py /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | # This is a basic workflow to help you get started with Actions 2 | 3 | name: "GitHub Actions SMZDM Bot" 4 | 5 | # Controls when the action will run. Triggers the workflow on push or pull request 6 | # events but only for the main branch 7 | on: 8 | push: 9 | # branches: [ main ] 10 | pull_request: 11 | branches: [ main ] 12 | schedule: 13 | - cron: '0 23 * * *' 14 | 15 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 16 | jobs: 17 | # This workflow contains a single job called "build" 18 | build: 19 | # The type of runner that the job will run on 20 | runs-on: ubuntu-latest 21 | 22 | # Steps represent a sequence of tasks that will be executed as part of the job 23 | steps: 24 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 25 | - uses: actions/checkout@v2 26 | 27 | - name: Set up Python 28 | uses: actions/setup-python@v1 29 | with: 30 | python-version: 3.7 31 | 32 | # Runs a set of commands using the runners shell 33 | - name: Install requirements 34 | run: | 35 | pip install -r requirements.txt 36 | 37 | - name: Working 38 | env: 39 | COOKIES: ${{ secrets.SMZDM_COOKIE }} 40 | SERVERCHAN_SECRETKEY: ${{ secrets.SERVERCHAN_SECRETKEY }} 41 | run: python main.py #>SMZDM_Bot.log -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 什么值得买每日签到脚本 2 | === 3 | 4 | 5 | #### 失效停止维护!! 6 | 自己现在在用https://github.com/hex-ci/smzdm_script 7 | 8 | 也是青龙拉库直接可用,试用了几天效果蛮好,功能不止签到,还有抽奖等丰富功能,推荐! 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /smzdm_auto_sign_bot.py: -------------------------------------------------------------------------------- 1 | """ 2 | 什么值得买自动签到脚本 3 | 4 | 借鉴(copy)自lws1122,fork 自:https://gitee.com/lsw1122/smzdm_bot 5 | """ 6 | ''' 7 | cron: 0 1 * * * smzdm_auto_sign_bot.py 8 | new Env('张大妈自动签到'); 9 | ''' 10 | 11 | import requests, os, datetime, sys 12 | from sys import argv 13 | import requests 14 | import json 15 | import time 16 | import hmac 17 | import hashlib 18 | import base64 19 | import urllib.parse 20 | 21 | """ 22 | http headers 23 | """ 24 | DEFAULT_HEADERS = { 25 | 'Accept': '*/*', 26 | 'Accept-Encoding': 'gzip, deflate, br', 27 | 'Accept-Language': 'zh-CN,zh;q=0.9', 28 | 'Connection': 'keep-alive', 29 | 'Host': 'zhiyou.smzdm.com', 30 | 'Referer': 'https://www.smzdm.com/', 31 | 'Sec-Fetch-Dest': 'script', 32 | 'Sec-Fetch-Mode': 'no-cors', 33 | 'Sec-Fetch-Site': 'same-site', 34 | 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1 Edg/108.0.0.0', 35 | } 36 | 37 | # 签到用的url 38 | SIGN_URL = 'https://zhiyou.smzdm.com/user/checkin/jsonp_checkin' 39 | 40 | # 环境变量中用于存放cookie的key值 41 | KEY_OF_COOKIE = "SMZDM_COOKIE" 42 | 43 | TG_TOKEN = '' 44 | TG_USER_ID = '' 45 | # serverJ 46 | SCKEY = '' 47 | # push+ 48 | PUSH_PLUS_TOKEN = '' 49 | # 钉钉机器人 50 | DD_BOT_TOKEN = '' 51 | DD_BOT_SECRET = '' 52 | 53 | if "TG_BOT_TOKEN" in os.environ and len(os.environ["TG_BOT_TOKEN"]) > 1 and "TG_USER_ID" in os.environ and len( 54 | os.environ["TG_USER_ID"]) > 1: 55 | TG_TOKEN = os.environ["TG_BOT_TOKEN"] 56 | TG_USER_ID = os.environ["TG_USER_ID"] 57 | 58 | if "PUSH_KEY" in os.environ and len(os.environ["PUSH_KEY"]) > 1: 59 | SCKEY = os.environ["PUSH_KEY"] 60 | 61 | if "DD_BOT_TOKEN" in os.environ and len(os.environ["DD_BOT_TOKEN"]) > 1 and "DD_BOT_SECRET" in os.environ and len( 62 | os.environ["DD_BOT_SECRET"]) > 1: 63 | DD_BOT_TOKEN = os.environ["DD_BOT_TOKEN"] 64 | DD_BOT_SECRET = os.environ["DD_BOT_SECRET"] 65 | 66 | if "PUSH_PLUS_TOKEN" in os.environ and len(os.environ["PUSH_PLUS_TOKEN"]) > 1: 67 | PUSH_PLUS_TOKEN = os.environ["PUSH_PLUS_TOKEN"] 68 | 69 | 70 | def logout(self): 71 | print("[{0}]: {1}".format(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), self)) 72 | sys.stdout.flush() 73 | 74 | 75 | def push_via_boot(title, content): 76 | dingding_bot(title, content) 77 | telegram_bot(title, content) 78 | serverJ(title, content) 79 | push_plus_bot(title, content) 80 | 81 | 82 | def dingding_bot(title, content): 83 | if not DD_BOT_TOKEN or not DD_BOT_SECRET: 84 | print("钉钉推送服务的DD_BOT_TOKEN或者DD_BOT_SECRET未设置!!\n取消推送") 85 | return 86 | timestamp = str(round(time.time() * 1000)) # 时间戳 87 | secret_enc = DD_BOT_SECRET.encode('utf-8') 88 | string_to_sign = '{}\n{}'.format(timestamp, DD_BOT_SECRET) 89 | string_to_sign_enc = string_to_sign.encode('utf-8') 90 | hmac_code = hmac.new(secret_enc, string_to_sign_enc, digestmod=hashlib.sha256).digest() 91 | sign = urllib.parse.quote_plus(base64.b64encode(hmac_code)) # 签名 92 | print('开始使用 钉钉机器人 推送消息...', end='') 93 | url = f'https://oapi.dingtalk.com/robot/send?access_token={DD_BOT_TOKEN}×tamp={timestamp}&sign={sign}' 94 | headers = {'Content-Type': 'application/json;charset=utf-8'} 95 | data = { 96 | 'msgtype': 'text', 97 | 'text': {'content': f'{title}\n\n{content}'} 98 | } 99 | response = requests.post(url=url, data=json.dumps(data), headers=headers, timeout=15).json() 100 | if not response['errcode']: 101 | print('推送成功!') 102 | else: 103 | print('推送失败!') 104 | 105 | 106 | def telegram_bot(title, content): 107 | try: 108 | print("\n") 109 | bot_token = TG_TOKEN 110 | user_id = TG_USER_ID 111 | if not bot_token or not user_id: 112 | print("tg服务的bot_token或者user_id未设置!!\n取消推送") 113 | return 114 | print("tg服务启动") 115 | url = f"https://api.telegram.org/bot{TG_TOKEN}/sendMessage" 116 | 117 | headers = {'Content-Type': 'application/x-www-form-urlencoded'} 118 | payload = {'chat_id': str(TG_USER_ID), 'text': f'{title}\n\n{content}', 'disable_web_page_preview': 'true'} 119 | proxies = None 120 | 121 | try: 122 | response = requests.post(url=url, headers=headers, params=payload, proxies=proxies).json() 123 | except: 124 | print('推送失败!') 125 | if response['ok']: 126 | print('推送成功!') 127 | else: 128 | print('推送失败!') 129 | except Exception as e: 130 | print(e) 131 | 132 | 133 | # push推送 134 | def push_plus_bot(title, content): 135 | try: 136 | print("\n") 137 | if not PUSH_PLUS_TOKEN: 138 | print("PUSHPLUS服务的token未设置!!\n取消推送") 139 | return 140 | print("PUSHPLUS服务启动") 141 | url = 'http://pushplus.hxtrip.com/send' 142 | data = { 143 | "token": PUSH_PLUS_TOKEN, 144 | "title": title, 145 | "content": content 146 | } 147 | body = json.dumps(data).encode(encoding='utf-8') 148 | headers = {'Content-Type': 'application/json'} 149 | response = requests.post(url=url, data=body, headers=headers).json() 150 | if response['code'] == 200: 151 | print('推送成功!') 152 | else: 153 | print('推送失败!') 154 | except Exception as e: 155 | print(e) 156 | 157 | 158 | def serverJ(title, content): 159 | try: 160 | print("\n") 161 | if not SCKEY: 162 | print("server酱服务的SCKEY未设置!!\n取消推送") 163 | return 164 | print("serverJ服务启动") 165 | data = { 166 | "title": title, 167 | "desp": content.replace("\n", "\n\n") 168 | } 169 | response = requests.post("https://sctapi.ftqq.com/{SCKEY}.send", data=data).json() 170 | if response['errno'] == 0: 171 | print('推送成功!') 172 | else: 173 | print('推送失败!') 174 | except Exception as e: 175 | print(e) 176 | 177 | 178 | class SignBot(object): 179 | 180 | def __init__(self): 181 | self.session = requests.Session() 182 | # 添加 headers 183 | self.session.headers = DEFAULT_HEADERS 184 | 185 | def __json_check(self, msg): 186 | """ 187 | 对请求 盖乐世社区 返回的数据进行进行检查 188 | 1.判断是否 json 形式 189 | """ 190 | try: 191 | result = msg.json() 192 | return True 193 | except Exception as e: 194 | logout(f'Error : {e}') 195 | return False 196 | 197 | def load_cookie_str(self, cookies): 198 | """ 199 | 起一个什么值得买的,带cookie的session 200 | cookie 为浏览器复制来的字符串 201 | :param cookie: 登录过的社区网站 cookie 202 | """ 203 | self.session.headers['Cookie'] = cookies 204 | 205 | def checkin(self): 206 | """ 207 | 签到函数 208 | """ 209 | msg = self.session.get(SIGN_URL) 210 | if self.__json_check(msg): 211 | return msg.json() 212 | return msg.content 213 | 214 | 215 | if __name__ == '__main__': 216 | bot = SignBot() 217 | cookies = os.environ[KEY_OF_COOKIE] 218 | cookieList = cookies.split("&") 219 | logout("检测到{}个cookie记录\n开始签到".format(len(cookieList))) 220 | index = 0 221 | for c in cookieList: 222 | bot.load_cookie_str(c) 223 | result = bot.checkin() 224 | msg = "\n⭐⭐⭐签到成功{1}天⭐⭐⭐\n🏅🏅🏅金币[{2}]\n🏅🏅🏅积分[{3}]\n🏅🏅🏅经验[{4}],\n🏅🏅🏅等级[{5}]\n🏅🏅补签卡[{6}]".format( 225 | index, 226 | result['data']["checkin_num"], 227 | result['data']["gold"], 228 | result['data']["point"], 229 | result['data']["exp"], 230 | result['data']["rank"], 231 | result['data']["cards"]) 232 | logout(msg) 233 | logout("开始推送,暂时支持【Telegram】【钉钉】【push+】【serverJ】") 234 | push_via_boot("张大妈自动签到", msg) 235 | # telegram_bot("张大妈自动签到", msg) 236 | index += 1 237 | logout("签到结束") 238 | --------------------------------------------------------------------------------