Skip to content

Commit

Permalink
Notification Push Via Pushplus
Browse files Browse the repository at this point in the history
  • Loading branch information
VermiIIi0n committed Nov 15, 2022
1 parent 2e70b9a commit f852066
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
13 changes: 8 additions & 5 deletions fucker.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
from base64 import b64encode, b64decode
from random import randint, random
from datetime import datetime
from functools import partial
from threading import Thread
from getpass import getpass
from ObjDict import ObjDict
from logger import logger
from push import pusher
from sign import sign
import urllib.request
import websockets
Expand All @@ -19,7 +21,6 @@
import json
import re
import os
from push import pusher

"""
⠄⠄⠄⢰⣧⣼⣯⠄⣸⣠⣶⣶⣦⣾⠄⠄⠄⠄⡀⠄⢀⣿⣿⠄⠄⠄⢸⡇⠄⠄
Expand Down Expand Up @@ -51,7 +52,8 @@ def __init__(self, cookies: dict = None,
proxies: dict = None,
limit: int = 0,
speed: float = None,
end_thre: float = None):
end_thre: float = None,
push_token: str = '',):
"""
### Fucker Class
* `cookies`: dict, optional, cookies to use for the session
Expand Down Expand Up @@ -92,6 +94,7 @@ def __init__(self, cookies: dict = None,
self.prefix = " |" # prefix for tree view
self.context = ObjDict(default=None) # context for methods
self.courses = ObjDict(default=None) # store courses info
self._push = partial(pusher, token=push_token) if push_token else lambda *args, **kwargs: None

@property # cannot directly manipulate _cookies property, we need to parse uuid from cookies
def cookies(self):
Expand Down Expand Up @@ -377,19 +380,19 @@ def fuckZhidaoCourse(self, RAC_id:str, tree_view:bool=True):
self.fuckZhidaoVideo(RAC_id, video.videoId)
except TimeLimitExceeded as e:
logger.info(f"Fucking time limit exceeded: {e}")
pusher("fuckZHS","刷课已完成")
self._push("fuckZHS","刷课已完成")
tprint(prefix)
tprint(f"{prefix}##Fucking time limit exceeded: {e}\n")
return
except CaptchaException:
logger.info("Captcha required")
pusher("fuckZHS","需要提供验证码")
self._push("fuckZHS","需要提供验证码")
tprint(prefix)
tprint(f"{prefix}##Captcha required\a\n")
return
except Exception as e:
logger.exception(e)
pusher("fuckZHS",e)
self._push("fuckZHS",e)
tprint(f"{prefix*3}##Failed: {e}"[:w_lim])
except KeyboardInterrupt:
logger.info("User interrupted")
Expand Down
10 changes: 8 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
"show_in_terminal": True,
"ensure_unicode": False
},
"config_version": "1.0.1"
"push": {
"enable": False,
"token": ""
},
"config_version": "1.1.0"
}
# get config or create one if not exist
if os.path.isfile(getConfigPath()):
Expand Down Expand Up @@ -67,6 +71,7 @@
ensure_unicode = qr_extra.ensure_unicode or False
logger.setLevel("DEBUG" if args.debug else (config.logLevel or "WARNING"))
proxies = config.proxies or {}
push_token = config.push.enable and config.push.token or ""

if logger.getLevel() == "DEBUG":
print("*****************************\n"+
Expand Down Expand Up @@ -106,7 +111,8 @@
print("*Failed to check update\n")

### create an instance, now we are talking... or fucking
fucker = Fucker(proxies=proxies, speed=args.speed, end_thre=args.threshold, limit=args.limit)
fucker = Fucker(proxies=proxies, speed=args.speed,
end_thre=args.threshold, limit=args.limit, push_token=push_token)

### first you need to login to get cookies
try:
Expand Down
2 changes: 1 addition & 1 deletion meta.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.3.8",
"version": "2.4.0",
"branch": "master",
"author": "VermiIIi0n"
}
8 changes: 5 additions & 3 deletions push.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import requests
token = ""
def pusher(title,content):
requests.get(f"http://www.pushplus.plus/send?token={token}&title={title}&content={content}")


def pusher(title: str, content, token: str) -> None:
requests.get(
f"http://www.pushplus.plus/send?token={token}&title={title}&content={content}")

0 comments on commit f852066

Please sign in to comment.