diff --git a/.gitignore b/.gitignore index 99a2186..4befed3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,92 +1,2 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -env/ -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -*.egg-info/ -.installed.cfg -*.egg - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*,cover -.hypothesis/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -target/ - -# IPython Notebook -.ipynb_checkpoints - -# pyenv -.python-version - -# celery beat schedule file -celerybeat-schedule - -# dotenv -.env - -# virtualenv -venv/ -ENV/ - -# Spyder project settings -.spyderproject - -# Rope project settings -.ropeproject - .DS_Store .idea diff --git a/CNAME b/CNAME new file mode 100644 index 0000000..9489863 --- /dev/null +++ b/CNAME @@ -0,0 +1 @@ +python.openset.wang \ No newline at end of file diff --git a/Example/Fibonacci.py b/Example/Fibonacci.py deleted file mode 100644 index 8a70426..0000000 --- a/Example/Fibonacci.py +++ /dev/null @@ -1,9 +0,0 @@ -# Python 3: Fibonacci series up to n -def fib(n): - a, b = 0, 1 - while a < n: - print(a, end = ' ') - a, b = b, a+b - # print() - -fib(1000) diff --git a/Example/Hello.py b/Example/Hello.py deleted file mode 100644 index fafe8ee..0000000 --- a/Example/Hello.py +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/python -# -*- coding: UTF-8 -*- -#coding=utf-8 - -print("Hello, World!"); -print("你好世界!"); \ No newline at end of file diff --git a/Example/Input.py b/Example/Input.py deleted file mode 100644 index eb7bc4e..0000000 --- a/Example/Input.py +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env python -# -*- coding: UTF-8 -*- - -# Input, assignment -name = input('What is your name?\n') -print('Hi, %s.' % name) - -# Read a full line of input from stdin and save it to our dynamically typed variable, input_string. -input_string = input() - -# Print a string literal saying "Hello, World." to stdout. -print('Hello, World.') - -# TODO: Write a line of code here that prints the contents of input_string to stdout. -print(input_string) \ No newline at end of file diff --git a/Example/datatype.py b/Example/datatype.py deleted file mode 100644 index 4da4eb2..0000000 --- a/Example/datatype.py +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/python -# -*- coding: UTF-8 -*- - -counter = 100 # 整型变量 -miles = 1000.0 # 浮点型变量 -name = "runoob" # 字符串 - -print (counter) -print (miles) -print (name) \ No newline at end of file diff --git a/Example/datetime_user.py b/Example/datetime_user.py deleted file mode 100644 index 3303d85..0000000 --- a/Example/datetime_user.py +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/python -# -*- coding: UTF-8 -*- - -import time; # 引入time模块 -import calendar - -ticks = time.time() -print(time.localtime()) -print("当前时间戳为:", ticks) - - -cal = calendar.month(2016,1) -print("以下输出2016年1月份的日历:") -print(cal) \ No newline at end of file diff --git a/Example/dict.py b/Example/dict.py deleted file mode 100644 index 2456b49..0000000 --- a/Example/dict.py +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/python - -dict = {} -dict['one'] = "菜鸟教程" -dict[2] = "菜鸟工具" - -tinydict = {'name': 'runoob','code':1, 'site': 'www.runoob.com'} - - -print (dict['one']) # 输出键为 'one' 的值 -print (dict[2]) # 输出键为 2 的值 -print (tinydict) # 输出完整的字典 -print (tinydict.keys()) # 输出所有键 -print (tinydict.values()) # 输出所有值 \ No newline at end of file diff --git a/Example/dir.py b/Example/dir.py deleted file mode 100644 index 3096bb3..0000000 --- a/Example/dir.py +++ /dev/null @@ -1,7 +0,0 @@ -# 导入内置math模块 -import math - -content = dir(math) - -print(content) -print(math.__name__) \ No newline at end of file diff --git a/Example/fibon.py b/Example/fibon.py deleted file mode 100644 index 2ee87e6..0000000 --- a/Example/fibon.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/python -# -*- coding: UTF-8 -*- - -# generator version -def fibon(n): - a = b = 1 - for i in range(n): - yield a - a, b = b, a + b - - -for x in fibon(100): - print(x) diff --git a/Example/is_leap.py b/Example/is_leap.py deleted file mode 100644 index f1b05af..0000000 --- a/Example/is_leap.py +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/python3 - -def is_leap(year): - - # Write your logic here - return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0) - -year = int(input()) -print(is_leap(year)) \ No newline at end of file diff --git a/Example/learning.py b/Example/learning.py deleted file mode 100644 index 7222f3a..0000000 --- a/Example/learning.py +++ /dev/null @@ -1,106 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -r''' -learning.py - -A Python 3 tutorial from http://www.liaoxuefeng.com - -Usage: - -python3 learning.py -''' - -import sys - -def check_version(): - v = sys.version_info - if v.major == 3 and v.minor >= 4: - return True - print('Your current python is %d.%d. Please use Python 3.4.' % (v.major, v.minor)) - return False - -if not check_version(): - exit(1) - -import os, io, json, subprocess, tempfile -from urllib import parse -from wsgiref.simple_server import make_server - -EXEC = sys.executable -PORT = 39093 -HOST = 'local.liaoxuefeng.com:%d' % PORT -TEMP = tempfile.mkdtemp(suffix='_py', prefix='learn_python_') -INDEX = 0 - -def main(): - httpd = make_server('127.0.0.1', PORT, application) - print('Ready for Python code on port %d...' % PORT) - httpd.serve_forever() - -def get_name(): - global INDEX - INDEX = INDEX + 1 - return 'test_%d' % INDEX - -def write_py(name, code): - fpath = os.path.join(TEMP, '%s.py' % name) - with open(fpath, 'w', encoding='utf-8') as f: - f.write(code) - print('Code wrote to: %s' % fpath) - return fpath - -def decode(s): - try: - return s.decode('utf-8') - except UnicodeDecodeError: - return s.decode('gbk') - -def application(environ, start_response): - host = environ.get('HTTP_HOST') - method = environ.get('REQUEST_METHOD') - path = environ.get('PATH_INFO') - if method == 'GET' and path == '/': - start_response('200 OK', [('Content-Type', 'text/html')]) - return [b'
%s = %s' % (k, str(v))
- L.append(p.encode('utf-8'))
- L.append(b'')
- return L
- if host != HOST or method != 'POST' or path != '/run' or not environ.get('CONTENT_TYPE', '').lower().startswith('application/x-www-form-urlencoded'):
- start_response('400 Bad Request', [('Content-Type', 'application/json')])
- return [b'{"error":"bad_request"}']
- s = environ['wsgi.input'].read(int(environ['CONTENT_LENGTH']))
- qs = parse.parse_qs(s.decode('utf-8'))
- if not 'code' in qs:
- start_response('400 Bad Request', [('Content-Type', 'application/json')])
- return [b'{"error":"invalid_params"}']
- name = qs['name'][0] if 'name' in qs else get_name()
- code = qs['code'][0]
- headers = [('Content-Type', 'application/json')]
- origin = environ.get('HTTP_ORIGIN', '')
- if origin.find('.liaoxuefeng.com') == -1:
- start_response('400 Bad Request', [('Content-Type', 'application/json')])
- return [b'{"error":"invalid_origin"}']
- headers.append(('Access-Control-Allow-Origin', origin))
- start_response('200 OK', headers)
- r = dict()
- try:
- fpath = write_py(name, code)
- print('Execute: %s %s' % (EXEC, fpath))
- r['output'] = decode(subprocess.check_output([EXEC, fpath], stderr=subprocess.STDOUT, timeout=5))
- except subprocess.CalledProcessError as e:
- r = dict(error='Exception', output=decode(e.output))
- except subprocess.TimeoutExpired as e:
- r = dict(error='Timeout', output='执行超时')
- except subprocess.CalledProcessError as e:
- r = dict(error='Error', output='执行错误')
- print('Execute done.')
- return [json.dumps(r).encode('utf-8')]
-
-if __name__ == '__main__':
- main()
diff --git a/Example/module.py b/Example/module.py
deleted file mode 100644
index 36ec6c2..0000000
--- a/Example/module.py
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-
-' A test module '
-
-__author__ = 'Sandy Wang'
-
-import sys
-
-
-def test():
- args = sys.argv
- if len(args) == 1:
- print('Hello, world!')
- elif len(args) == 2:
- print('Hello, %s!' % args[1])
- else:
- print('Too many arguments!\n', args)
-
-
-if __name__ == '__main__':
- test()
diff --git a/Example/note.py b/Example/note.py
deleted file mode 100644
index 5561c82..0000000
--- a/Example/note.py
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/python
-# -*- coding: UTF-8 -*-
-# 文件名:test.py
-
-'''
-这是多行注释,使用单引号。
-这是多行注释,使用单引号。
-这是多行注释,使用单引号。
-'''
-
-"""
-这是多行注释,使用双引号。
-这是多行注释,使用双引号。
-这是多行注释,使用双引号。
-"""
-
-if True:
- print("Answer")
- print( "True")
-else:
- print( "Answer")
- # 没有严格缩进,在执行时保持
- print( "False")
\ No newline at end of file
diff --git a/Example/py.py b/Example/py.py
deleted file mode 100644
index 7825677..0000000
--- a/Example/py.py
+++ /dev/null
@@ -1,3 +0,0 @@
-n=2;
-for i in range(10):
- print(str(n) + ' x ' + str(i+1) + ' = ' + str(n*(i+1)))
diff --git a/Example/smtp.py b/Example/smtp.py
deleted file mode 100644
index 0d61b1f..0000000
--- a/Example/smtp.py
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/usr/bin/python
-# -*- coding: UTF-8 -*-
-
-import smtplib
-from email.mime.text import MIMEText
-from email.header import Header
-
-# 第三方 SMTP 服务
-mail_host="smtp.exmail.qq.com" #设置服务器
-mail_user="user@mail.com" #用户名
-mail_pass="******" #口令
-sender = 'user@mail.com'
-receivers = ['user@mail.com'] # 接收邮件,可设置为你的QQ邮箱或者其他邮箱
-
-# 三个参数:第一个为文本内容,第二个 plain 设置文本格式,第三个 utf-8 设置编码
-message = MIMEText('Python 邮件发送测试...', 'plain', 'utf-8')
-message['From'] = Header("Sandy", 'utf-8')
-message['To'] = Header("测试", 'utf-8')
-
-subject = 'Python SMTP 邮件测试'
-message['Subject'] = Header(subject, 'utf-8')
-
-
-try:
- smtpObj = smtplib.SMTP()
- smtpObj.connect(mail_host, 25) # 25 为 SMTP 端口号
- smtpObj.login(mail_user,mail_pass)
- smtpObj.sendmail(sender, receivers, message.as_string())
- print("邮件发送成功")
-except smtplib.SMTPException:
- print("Error: 无法发送邮件")
diff --git a/Example/string_user.py b/Example/string_user.py
deleted file mode 100644
index 42beda1..0000000
--- a/Example/string_user.py
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/usr/bin/python3
-
-str = 'Runoob'
-
-print (str) # 输出字符串
-print (str[0:-1]) # 输出第一个个到倒数第二个的所有字符
-print (str[0]) # 输出字符串第一个字符
-print (str[2:5]) # 输出从第三个开始到第五个的字符
-print (str[2:]) # 输出从第三个开始的后的所有字符
-print (str * 2) # 输出字符串两次
-print (str + "TEST") # 连接字符串
\ No newline at end of file
diff --git a/Example/test.py b/Example/test.py
deleted file mode 100644
index 48eebd1..0000000
--- a/Example/test.py
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/usr/bin/python
-# -*- coding: UTF-8 -*-
-
-def test_var_args(f_arg, *args):
- print("first normal arg:", f_arg)
- for arg in args:
- print("another arg through *argv:", arg)
-
-
-# test_var_args('a', 'b', 'c', 'd')
-
-def greet_me(**kwargs):
- for key, value in kwargs.items():
- print("{0} == {1}".format(key, value))
-
-
-greet_me(name="yasoob")
diff --git a/Example/tickets.py b/Example/tickets.py
deleted file mode 100644
index 939a369..0000000
--- a/Example/tickets.py
+++ /dev/null
@@ -1,26 +0,0 @@
-# coding: utf-8
-"""Train tickets query via command-line.
-
-Usage:
- tickets [-gdtkz]
" in content:
- [people, content] = content.split(':
', 1)
- groupName = srcName
- srcName = self.getUserRemarkName(people)
- dstName = 'GROUP'
- else:
- groupName = srcName
- srcName = 'SYSTEM'
- elif msg['raw_msg']['ToUserName'][:2] == '@@':
- # 自己发给群的消息
- groupName = dstName
- dstName = 'GROUP'
-
- # 收到了红包
- if content == '收到红包,请在手机上查看':
- msg['message'] = content
-
- # 指定了消息内容
- if 'message' in list(msg.keys()):
- content = msg['message']
-
- if groupName != None:
- print('%s |%s| %s -> %s: %s' % (
- message_id, groupName.strip(), srcName.strip(), dstName.strip(), content.replace('
', '\n')))
- logging.info('%s |%s| %s -> %s: %s' % (message_id, groupName.strip(),
- srcName.strip(), dstName.strip(), content.replace('
', '\n')))
- else:
- print('%s %s -> %s: %s' % (message_id, srcName.strip(), dstName.strip(), content.replace('
', '\n')))
- logging.info('%s %s -> %s: %s' % (message_id, srcName.strip(),
- dstName.strip(), content.replace('
', '\n')))
-
- def handleMsg(self, r):
- for msg in r['AddMsgList']:
- print('[*] 你有新的消息,请注意查收')
- logging.debug('[*] 你有新的消息,请注意查收')
-
- if self.DEBUG:
- fn = 'msg' + str(int(random.random() * 1000)) + '.json'
- with open(fn, 'w') as f:
- f.write(json.dumps(msg))
- print('[*] 该消息已储存到文件: ' + fn)
- logging.debug('[*] 该消息已储存到文件: %s' % (fn))
-
- msgType = msg['MsgType']
- name = self.getUserRemarkName(msg['FromUserName'])
- content = msg['Content'].replace('<', '<').replace('>', '>')
- msgid = msg['MsgId']
-
- if msgType == 1:
- raw_msg = {'raw_msg': msg}
- self._showMsg(raw_msg)
- # 自己加的代码-------------------------------------------#
- # if self.autoReplyRevokeMode:
- # store
- # 自己加的代码-------------------------------------------#
- if self.autoReplyMode:
- ans = self._xiaodoubi(content) + '\n[微信机器人自动回复]'
- if self.webwxsendmsg(ans, msg['FromUserName']):
- print('自动回复: ' + ans)
- logging.info('自动回复: ' + ans)
- else:
- print('自动回复失败')
- logging.info('自动回复失败')
- elif msgType == 3:
- image = self.webwxgetmsgimg(msgid)
- raw_msg = {'raw_msg': msg,
- 'message': '%s 发送了一张图片: %s' % (name, image)}
- self._showMsg(raw_msg)
- self._safe_open(image)
- elif msgType == 34:
- voice = self.webwxgetvoice(msgid)
- raw_msg = {'raw_msg': msg,
- 'message': '%s 发了一段语音: %s' % (name, voice)}
- self._showMsg(raw_msg)
- self._safe_open(voice)
- elif msgType == 42:
- info = msg['RecommendInfo']
- print('%s 发送了一张名片:' % name)
- print('=========================')
- print('= 昵称: %s' % info['NickName'])
- print('= 微信号: %s' % info['Alias'])
- print('= 地区: %s %s' % (info['Province'], info['City']))
- print('= 性别: %s' % ['未知', '男', '女'][info['Sex']])
- print('=========================')
- raw_msg = {'raw_msg': msg, 'message': '%s 发送了一张名片: %s' % (
- name.strip(), json.dumps(info))}
- self._showMsg(raw_msg)
- elif msgType == 47:
- url = self._searchContent('cdnurl', content)
- raw_msg = {'raw_msg': msg,
- 'message': '%s 发了一个动画表情,点击下面链接查看: %s' % (name, url)}
- self._showMsg(raw_msg)
- self._safe_open(url)
- elif msgType == 49:
- appMsgType = defaultdict(lambda: "")
- appMsgType.update({5: '链接', 3: '音乐', 7: '微博'})
- print('%s 分享了一个%s:' % (name, appMsgType[msg['AppMsgType']]))
- print('=========================')
- print('= 标题: %s' % msg['FileName'])
- print('= 描述: %s' % self._searchContent('des', content, 'xml'))
- print('= 链接: %s' % msg['Url'])
- print('= 来自: %s' % self._searchContent('appname', content, 'xml'))
- print('=========================')
- card = {
- 'title': msg['FileName'],
- 'description': self._searchContent('des', content, 'xml'),
- 'url': msg['Url'],
- 'appname': self._searchContent('appname', content, 'xml')
- }
- raw_msg = {'raw_msg': msg, 'message': '%s 分享了一个%s: %s' % (
- name, appMsgType[msg['AppMsgType']], json.dumps(card))}
- self._showMsg(raw_msg)
- elif msgType == 51:
- raw_msg = {'raw_msg': msg, 'message': '[*] 成功获取联系人信息'}
- self._showMsg(raw_msg)
- elif msgType == 62:
- video = self.webwxgetvideo(msgid)
- raw_msg = {'raw_msg': msg,
- 'message': '%s 发了一段小视频: %s' % (name, video)}
- self._showMsg(raw_msg)
- self._safe_open(video)
- elif msgType == 10002:
- raw_msg = {'raw_msg': msg, 'message': '%s 撤回了一条消息' % name}
- self._showMsg(raw_msg)
- else:
- logging.debug('[*] 该消息类型为: %d,可能是表情,图片, 链接或红包: %s' %
- (msg['MsgType'], json.dumps(msg)))
- raw_msg = {
- 'raw_msg': msg, 'message': '[*] 该消息类型为: %d,可能是表情,图片, 链接或红包' % msg['MsgType']}
- self._showMsg(raw_msg)
-
- def listenMsgMode(self):
- print('[*] 进入消息监听模式 ... 成功')
- logging.debug('[*] 进入消息监听模式 ... 成功')
- self._run('[*] 进行同步线路测试 ... ', self.testsynccheck)
- playWeChat = 0
- redEnvelope = 0
- while True:
- self.lastCheckTs = time.time()
- [retcode, selector] = self.synccheck()
- if self.DEBUG:
- print('retcode: %s, selector: %s' % (retcode, selector))
- logging.debug('retcode: %s, selector: %s' % (retcode, selector))
- if retcode == '1100':
- print('[*] 你在手机上登出了微信,债见')
- logging.debug('[*] 你在手机上登出了微信,债见')
- break
- if retcode == '1101':
- print('[*] 你在其他地方登录了 WEB 版微信,债见')
- logging.debug('[*] 你在其他地方登录了 WEB 版微信,债见')
- break
- elif retcode == '0':
- if selector == '2':
- r = self.webwxsync()
- if r is not None:
- self.handleMsg(r)
- elif selector == '6':
- # TODO
- redEnvelope += 1
- print('[*] 收到疑似红包消息 %d 次' % redEnvelope)
- logging.debug('[*] 收到疑似红包消息 %d 次' % redEnvelope)
- elif selector == '7':
- playWeChat += 1
- print('[*] 你在手机上玩微信被我发现了 %d 次' % playWeChat)
- logging.debug('[*] 你在手机上玩微信被我发现了 %d 次' % playWeChat)
- r = self.webwxsync()
- elif selector == '0':
- time.sleep(1)
- if (time.time() - self.lastCheckTs) <= 20:
- time.sleep(time.time() - self.lastCheckTs)
-
- def sendMsg(self, name, word, isfile=False):
- id = self.getUSerID(name)
- if id:
- if isfile:
- with open(word, 'r') as f:
- for line in f.readlines():
- line = line.replace('\n', '')
- self._echo('-> ' + name + ': ' + line)
- if self.webwxsendmsg(line, id):
- print(' [成功]')
- else:
- print(' [失败]')
- time.sleep(1)
- else:
- if self.webwxsendmsg(word, id):
- print('[*] 消息发送成功')
- logging.debug('[*] 消息发送成功')
- else:
- print('[*] 消息发送失败')
- logging.debug('[*] 消息发送失败')
- else:
- print('[*] 此用户不存在')
- logging.debug('[*] 此用户不存在')
-
- def sendMsgToAll(self, word):
- for contact in self.ContactList:
- name = contact['RemarkName'] if contact[
- 'RemarkName'] else contact['NickName']
- id = contact['UserName']
- self._echo('-> ' + name + ': ' + word)
- if self.webwxsendmsg(word, id):
- print(' [成功]')
- else:
- print(' [失败]')
- time.sleep(1)
-
- def sendImg(self, name, file_name):
- response = self.webwxuploadmedia(file_name)
- media_id = ""
- if response is not None:
- media_id = response['MediaId']
- user_id = self.getUSerID(name)
- response = self.webwxsendmsgimg(user_id, media_id)
-
- def sendEmotion(self, name, file_name):
- response = self.webwxuploadmedia(file_name)
- media_id = ""
- if response is not None:
- media_id = response['MediaId']
- user_id = self.getUSerID(name)
- response = self.webwxsendmsgemotion(user_id, media_id)
-
- @catchKeyboardInterrupt
- def start(self):
- self._echo('[*] 微信网页版 ... 开动')
- print()
- logging.debug('[*] 微信网页版 ... 开动')
- while True:
- self._run('[*] 正在获取 uuid ... ', self.getUUID)
- self._echo('[*] 正在获取二维码 ... 成功')
- print()
- logging.debug('[*] 微信网页版 ... 开动')
- self.genQRCode()
- print('[*] 请使用微信扫描二维码以登录 ... ')
- if not self.waitForLogin():
- continue
- print('[*] 请在手机上点击确认以登录 ... ')
- if not self.waitForLogin(0):
- continue
- break
-
- self._run('[*] 正在登录 ... ', self.login)
- self._run('[*] 微信初始化 ... ', self.webwxinit)
- self._run('[*] 开启状态通知 ... ', self.webwxstatusnotify)
- self._run('[*] 获取联系人 ... ', self.webwxgetcontact)
- self._echo('[*] 应有 %s 个联系人,读取到联系人 %d 个' %
- (self.MemberCount, len(self.MemberList)))
- print()
- self._echo('[*] 共有 %d 个群 | %d 个直接联系人 | %d 个特殊账号 | %d 公众号或服务号' % (len(self.GroupList),
- len(self.ContactList),
- len(self.SpecialUsersList),
- len(self.PublicUsersList)))
- print()
- self._run('[*] 获取群 ... ', self.webwxbatchgetcontact)
- logging.debug('[*] 微信网页版 ... 开动')
- if self.DEBUG:
- print(self)
- logging.debug(self)
-
- if self.interactive and input('[*] 是否开启自动回复模式(y/n): ') == 'y':
- self.autoReplyMode = True
- print('[*] 自动回复模式 ... 开启')
- logging.debug('[*] 自动回复模式 ... 开启')
- else:
- print('[*] 自动回复模式 ... 关闭')
- logging.debug('[*] 自动回复模式 ... 关闭')
-
- if sys.platform.startswith('win'):
- import _thread
- _thread.start_new_thread(self.listenMsgMode())
- else:
- listenProcess = multiprocessing.Process(target=self.listenMsgMode)
- listenProcess.start()
-
- while True:
- text = input('')
- if text == 'quit':
- listenProcess.terminate()
- print('[*] 退出微信')
- logging.debug('[*] 退出微信')
- exit()
- elif text[:2] == '->':
- [name, word] = text[2:].split(':')
- if name == 'all':
- self.sendMsgToAll(word)
- else:
- self.sendMsg(name, word)
- elif text[:3] == 'm->':
- [name, file] = text[3:].split(':')
- self.sendMsg(name, file, True)
- elif text[:3] == 'f->':
- print('发送文件')
- logging.debug('发送文件')
- elif text[:3] == 'i->':
- print('发送图片')
- [name, file_name] = text[3:].split(':')
- self.sendImg(name, file_name)
- logging.debug('发送图片')
- elif text[:3] == 'e->':
- print('发送表情')
- [name, file_name] = text[3:].split(':')
- self.sendEmotion(name, file_name)
- logging.debug('发送表情')
-
- def _safe_open(self, path):
- if self.autoOpen:
- if platform.system() == "Linux":
- os.system("xdg-open %s &" % path)
- else:
- os.system('open %s &' % path)
-
- def _run(self, str, func, *args):
- self._echo(str)
- if func(*args):
- print('成功')
- logging.debug('%s... 成功' % (str))
- else:
- print('失败\n[*] 退出程序')
- logging.debug('%s... 失败' % (str))
- logging.debug('[*] 退出程序')
- exit()
-
- def _echo(self, str):
- sys.stdout.write(str)
- sys.stdout.flush()
-
- def _printQR(self, mat):
- for i in mat:
- BLACK = '\033[40m \033[0m'
- WHITE = '\033[47m \033[0m'
- print(''.join([BLACK if j else WHITE for j in i]))
-
- def _str2qr(self, str):
- print(str)
- qr = qrcode.QRCode()
- qr.border = 1
- qr.add_data(str)
- qr.make()
- # img = qr.make_image()
- # img.save("qrcode.png")
- # mat = qr.get_matrix()
- # self._printQR(mat) # qr.print_tty() or qr.print_ascii()
- qr.print_ascii(invert=True)
-
- def _transcoding(self, data):
- if not data:
- return data
- result = None
- if type(data) == str:
- result = data
- elif type(data) == str:
- result = data.decode('utf-8')
- return result
-
- def _get(self, url: object, api: object = None, timeout: object = None) -> object:
- request = urllib.request.Request(url=url)
- request.add_header('Referer', 'https://wx.qq.com/')
- if api == 'webwxgetvoice':
- request.add_header('Range', 'bytes=0-')
- if api == 'webwxgetvideo':
- request.add_header('Range', 'bytes=0-')
- try:
- response = urllib.request.urlopen(request, timeout=timeout) if timeout else urllib.request.urlopen(request)
- data = response.read().decode('utf-8')
- logging.debug(url)
- return data
- except urllib.error.HTTPError as e:
- logging.error('HTTPError = ' + str(e.code))
- except urllib.error.URLError as e:
- logging.error('URLError = ' + str(e.reason))
- except http.client.HTTPException as e:
- logging.error('HTTPException')
- except timeout_error as e:
- pass
- except ssl.CertificateError as e:
- pass
- except Exception:
- import traceback
- logging.error('generic exception: ' + traceback.format_exc())
- return ''
-
- def _post(self, url: object, params: object, jsonfmt: object = True) -> object:
- if jsonfmt:
- data = (json.dumps(params)).encode()
-
- request = urllib.request.Request(url=url, data=data)
- request.add_header(
- 'ContentType', 'application/json; charset=UTF-8')
- else:
- request = urllib.request.Request(url=url, data=urllib.parse.urlencode(params).encode(encoding='utf-8'))
-
- try:
- response = urllib.request.urlopen(request)
- data = response.read()
- if jsonfmt:
- return json.loads(data.decode('utf-8')) # object_hook=_decode_dict)
- return data
- except urllib.error.HTTPError as e:
- logging.error('HTTPError = ' + str(e.code))
- except urllib.error.URLError as e:
- logging.error('URLError = ' + str(e.reason))
- except http.client.HTTPException as e:
- logging.error('HTTPException')
- except Exception:
- import traceback
- logging.error('generic exception: ' + traceback.format_exc())
-
- return ''
-
- def _xiaodoubi(self, word):
- url = 'http://www.xiaodoubi.com/bot/chat.php'
- try:
- r = requests.post(url, data={'chat': word})
- return r.content
- except:
- return "让我一个人静静 T_T..."
-
- def _simsimi(self, word):
- key = ''
- url = 'http://sandbox.api.simsimi.com/request.p?key=%s&lc=ch&ft=0.0&text=%s' % (
- key, word)
- r = requests.get(url)
- ans = r.json()
- if ans['result'] == '100':
- return ans['response']
- else:
- return '你在说什么,风太大听不清列'
-
- def _searchContent(self, key, content, fmat='attr'):
- if fmat == 'attr':
- pm = re.search(key + '\s?=\s?"([^"<]+)"', content)
- if pm:
- return pm.group(1)
- elif fmat == 'xml':
- pm = re.search('<{0}>([^<]+){0}>'.format(key), content)
- if not pm:
- pm = re.search(
- '<{0}><\!\[CDATA\[(.*?)\]\]>{0}>'.format(key), content)
- if pm:
- return pm.group(1)
- return '未知'
-
-
-class UnicodeStreamFilter:
- def __init__(self, target):
- self.target = target
- self.encoding = 'utf-8'
- self.errors = 'replace'
- self.encode_to = self.target.encoding
-
- def write(self, s):
- if type(s) == str:
- s = s.encode().decode('utf-8')
- s = s.encode(self.encode_to, self.errors).decode(self.encode_to)
- self.target.write(s)
-
- def flush(self):
- self.target.flush()
-
-
-if sys.stdout.encoding == 'cp936':
- sys.stdout = UnicodeStreamFilter(sys.stdout)
-
-if __name__ == '__main__':
- logger = logging.getLogger(__name__)
- if not sys.platform.startswith('win'):
- import coloredlogs
-
- coloredlogs.install(level='DEBUG')
-
- webwx = WebWeixin()
- webwx.start()
diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index 05d30a9..0000000
--- a/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) 2017 Shuo Wang
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/README.md b/README.md
index 3c408d4..f0d91ed 100644
--- a/README.md
+++ b/README.md
@@ -1,15 +1 @@
-# [Python 指南](https://openset.github.io/python-guide/)
-Python is an easy to learn, powerful programming language.
-
-## 目录
- - [基础学习](#基础学习)
- - [进阶学习](#进阶学习)
-
-## 基础学习
- - [The Python Tutorial:](https://docs.python.org/3/tutorial/index.html) 官方文档
- - [Python Guide:](http://docs.python-guide.org/en/latest/) Hitchhiker's Guide to Python
- - [Python 指南:](http://pythonguidecn.readthedocs.io/zh/latest/) Python最佳实践指南
- - [Php2Python:](http://www.php2python.com/) Python alternatives for PHP functions
-
-## 进阶学习
- - [Awesome Python:](https://awesome-python.com/) A curated list of awesome Python frameworks, libraries, software and resources.
+# ©2018 Openset. All rights reserved.
diff --git a/_config.yml b/_config.yml
new file mode 100644
index 0000000..e2e2216
--- /dev/null
+++ b/_config.yml
@@ -0,0 +1,4 @@
+lang: zh-CN
+owner_name: Openset
+google_analytics: UA-103591670-1
+theme: jekyll-theme-cayman
diff --git a/_layouts/default.html b/_layouts/default.html
new file mode 100644
index 0000000..92e454f
--- /dev/null
+++ b/_layouts/default.html
@@ -0,0 +1,55 @@
+
+
+
+
+ {% seo %}
+
+
+
+
+
+
+
+
+
+