├── pylintrc ├── setup.py ├── docker ├── Dockerfile └── healthcheck.sh ├── girlfriend ├── __init__.py ├── test │ ├── __init__.py │ ├── confirm_friend.py │ └── learn_itchat.py ├── utils │ ├── __init__.py │ └── tencent.py ├── components │ ├── __init__.py │ ├── crontab.py │ ├── mass_texting.py │ ├── ai_robot.py │ ├── ai_picture.py │ ├── ai_ocr.py │ └── ai_youtu.py └── plugins │ ├── __init__.py │ ├── message │ └── __init__.py │ ├── one │ └── __init__.py │ └── weather │ └── __init__.py ├── misc ├── dev-requirements.txt └── prod-requirements.txt ├── images └── love-grilfriend.png ├── .dockerignore ├── weather.sh ├── config ├── config-dev.yml └── config-prod.yml ├── .github └── workflows │ └── pythonapp.yml ├── .gitignore ├── README.md ├── docs └── README_EN.md └── LICENSE /pylintrc: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docker/healthcheck.sh: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /girlfriend/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /girlfriend/test/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /girlfriend/utils/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /girlfriend/components/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /girlfriend/components/crontab.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /girlfriend/plugins/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /girlfriend/plugins/message/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /girlfriend/plugins/one/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /girlfriend/plugins/weather/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /misc/dev-requirements.txt: -------------------------------------------------------------------------------- 1 | -r prod-requirements.txt 2 | ipython 3 | pylint 4 | pycodestyle 5 | -------------------------------------------------------------------------------- /misc/prod-requirements.txt: -------------------------------------------------------------------------------- 1 | itchat==1.3.10 2 | pyyaml 3 | requests 4 | beautifulsoup4 5 | apscheduler 6 | -------------------------------------------------------------------------------- /images/love-grilfriend.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EscapeLife/love-grilfriend/HEAD/images/love-grilfriend.png -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | .* 3 | !config/config-prod.yml 4 | !docker/healthcheck.sh 5 | !grilfriend 6 | !misc/requirements-prod.txt 7 | -------------------------------------------------------------------------------- /weather.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eux 4 | 5 | CITY="Xi'an" 6 | LANGUAGE="zh-CN" 7 | UNIT=m 8 | UA="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36" 9 | 10 | curl \ 11 | -H "Accept-Language: $LANGUAGE" \ 12 | -H "User-Agent: $UA" \ 13 | -o result.html \ 14 | wttr.in/$CITY?format=4\&$UNIT 15 | -------------------------------------------------------------------------------- /config/config-dev.yml: -------------------------------------------------------------------------------- 1 | # --------- 常用功能设置 --------- 2 | auto_hot_login: True 3 | 4 | 5 | # --------- 自动回复设置 --------- 6 | auto_replay: True 7 | 8 | auto_rebot: False 9 | rebot_conf: 10 | client_token: 'a8105204604a0b11e916f3879aae3b0b' 11 | 12 | replay_user_conf: 13 | - '文件传输助手' 14 | 15 | replay_group_conf: 16 | - group_name: 'ipython' 17 | at_key: True 18 | replay_key: 'ipython' 19 | 20 | 21 | # --------- 定时任务设置 --------- 22 | auto_alarm: True 23 | alarm_conf: 24 | alarm_time: '12:00' 25 | 26 | gril_friend: 27 | - wechat_alias: '文件传输助手' 28 | nickname: '小助手' 29 | city_name: '北京' 30 | alarm_time: '17:00' 31 | send_type: 32 | - one 33 | - weather 34 | send_message: 35 | - '把今天上传的图片整理成相册' 36 | love_date: '20190214' 37 | 38 | group_friend: 39 | - group_name: 'ipython' 40 | city_name: '西安' 41 | alarm_time: '21:00' 42 | send_type: 43 | - one 44 | - weather 45 | send_message: 46 | - 'I love ipython very much.' 47 | build_date: '20190601' 48 | -------------------------------------------------------------------------------- /config/config-prod.yml: -------------------------------------------------------------------------------- 1 | # --------- 常用功能设置 --------- 2 | 3 | # 是否启用微信热登录 4 | auto_hot_login: False 5 | 6 | 7 | # --------- 自动回复设置 --------- 8 | 9 | # 是否开启女友/群聊自动回复(默认为False) 10 | auto_replay: False 11 | 12 | # 是否开启自动回复智能机器人(默认为False) 13 | auto_rebot: False 14 | rebot_conf: 15 | client_token: 'a8105204604a0b11e916f3879aae3b0b' 16 | 17 | # 自动回复的女友/群聊名单(可为空|可添加多个) 18 | replay_user_conf: 19 | - '一只会飞的小猪' # 女友 20 | - '梦里花落知多少' # 女友 21 | 22 | # 自动回复的女友/群聊名单(可为空|可添加多个) 23 | replay_group_conf: 24 | - group_name: '袁家村狂狼分队' # 群聊 25 | at_key: False # 只有@自己时才会发送对应消息 26 | replay_key: '天气' # 只有触发特定关键词时才会发送对应消息 27 | 28 | 29 | # --------- 定时任务设置 --------- 30 | 31 | # 是否开启定时任务(默认为False) 32 | auto_alarm: False 33 | alarm_conf: 34 | alarm_time: '12:00' 35 | 36 | # 定时回复的女友名单(可为空|可添加多个) 37 | gril_friend: 38 | - wechat_alias: '一只会飞的小猪' # 微信昵称或备注名 39 | nickname: '小猪猪' # 回复消息的昵称 40 | city_name: '北京' # 所在城市 41 | alarm_time: '12:00' # 发送时间 42 | send_type: # 发送消息类型 43 | - one # 散文 44 | - weather # 天气 45 | send_message: # 发送文本消息 46 | - '今天中午我看见了一个美女' # 文本消息内容 47 | love_date: '20190214' # 相爱的日期 48 | - wechat_alias: '梦里花落知多少' 49 | nickname: '小花花' 50 | city_name: '上海' 51 | alarm_time: '17:00' 52 | send_type: 53 | - one 54 | - weather 55 | send_message: 56 | - '今天中午我看见了一个美女' 57 | love_date: '20190214' 58 | 59 | # 定时回复的群聊名单(可为空|可添加多个) 60 | group_friend: 61 | - group_name: '袁家村狂狼分队' 62 | city_name: '深圳' 63 | alarm_time: '21:00' 64 | send_type: 65 | - one 66 | - weather 67 | send_message: 68 | - '今天中午我看见了一个美女' 69 | build_date: '20190601' 70 | -------------------------------------------------------------------------------- /.github/workflows/pythonapp.yml: -------------------------------------------------------------------------------- 1 | # 定义workflow的名称 2 | name: love-grilfriend 3 | 4 | # 指定触发方式 5 | on: 6 | push: 7 | branches: 8 | - master 9 | schedule: 10 | - cron: '0 0 0 */12 0' 11 | 12 | # 定义job任务列表 13 | jobs: 14 | # 项目lint检查 15 | build_job: 16 | # 指定运行所需要的虚拟机环境 17 | runs-on: ubuntu-latest 18 | strategy: 19 | matrix: 20 | python-version: [3.6, 3.7] 21 | 22 | # 指定具体需要执行步骤和命令 23 | steps: 24 | - name: Checkout Codes 25 | uses: actions/checkout@v1 26 | - name: Setup Python 27 | uses: actions/setup-python@v1 28 | with: 29 | python-version: ${{ matrix.python-version }} 30 | architecture: x64 31 | # 步骤名称 32 | - name: Install Dependencies 33 | # 该步骤运行的命令或者action 34 | run: | 35 | python -m pip install --upgrade pip 36 | pip install -r requirements.txt 37 | - name: Python Lint 38 | run: inv lint 39 | - name: Python Test 40 | run: | 41 | pip install pytest 42 | pytest 43 | 44 | # 报错发送邮件 45 | send_mail_job: 46 | runs-on: ubuntu-latest 47 | steps: 48 | - name: Checkout Codes 49 | uses: actions/checkout@v1 50 | - name: Get Weather 51 | run: bash ./weather.sh 52 | - name: Send Mail 53 | uses: dawidd6/action-send-mail@master 54 | with: 55 | server_address: smtp.163.com 56 | server_port: 465 57 | username: ${{ secrets.MAIL_USERNAME }} 58 | password: ${{ secrets.MAIL_PASSWORD }} 59 | subject: Xi'an Weather Report 60 | body: file://result.html 61 | to: escapehack@gmail.com 62 | from: GitHub Actions 63 | content_type: text/html 64 | -------------------------------------------------------------------------------- /girlfriend/components/mass_texting.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | 一个消息群发助手 4 | 5 | Usage: 6 | itchat.auto_login(hotReload=True, enableCmdQR=2) 7 | MASS = MassMSG() 8 | MASS.send_all_friends_msg() 9 | MASS.send_special_group_msg() 10 | """ 11 | 12 | import time 13 | import itchat 14 | 15 | 16 | class MassMSG: 17 | """消息群发助手""" 18 | def __init__(self, greetings='Happy New Year', chatroom_name='mass_group'): 19 | self.greetings = greetings 20 | self.chatroom_name = chatroom_name 21 | 22 | def send_all_friends_msg(self): 23 | """给所有好友发送消息""" 24 | # 获取的好友列表首位是自己 25 | friends_list = itchat.get_friends(update=True)[1:] 26 | for friend in friends_list: 27 | # 如果用于演示则使用print方法 28 | itchat.send(f'{self.greetings} | {friend["NickName"]}', friend['UserName']) 29 | print(f'>>> send {friend["NickName"]} is finished.') 30 | time.sleep(3) 31 | 32 | def send_special_group_msg(self): 33 | """给指定群组内的成员发送消息""" 34 | itchat.get_friends(update=True) 35 | chatrooms = itchat.search_chatrooms(name=self.chatroom_name) 36 | if chatrooms is None: 37 | print(f'The {self.chatroom_name} is not found.') 38 | else: 39 | chatroom = itchat.update_chatroom(chatrooms[0]['UserName']) 40 | for friend in chatroom['MemberList']: 41 | friend = itchat.search_friends(userName=friend['UserName']) 42 | # 如果用于演示则使用print方法 43 | itchat.send(f'{self.greetings} | {friend["NickName"]}', friend['UserName']) 44 | print(f'>>> send {friend["NickName"]} is finished.') 45 | time.sleep(3) 46 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | 106 | # macos 107 | .DS_Store 108 | 109 | # vscode 110 | .vscode/ 111 | -------------------------------------------------------------------------------- /girlfriend/utils/tencent.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """腾讯AI平台请求通用函数""" 3 | 4 | import time 5 | import random 6 | import string 7 | import base64 8 | import hashlib 9 | from urllib import parse 10 | 11 | import requests 12 | 13 | 14 | USERAGENT = { 15 | 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 \ 16 | (KHTML, like Gecko) Chrome/68.0.3440.75 Safari/537.36' 17 | } 18 | 19 | 20 | def get_time_stamp(): 21 | """生成请求时间戳""" 22 | return int(time.time()) 23 | 24 | def get_nonce_str(): 25 | """生成随机字符串""" 26 | return ''.join(random.sample(string.ascii_letters + string.digits, random.randint(10, 16))) 27 | 28 | def md5_encode(app_id): 29 | """生成会话标识 30 | :param app_id => 应用标识 31 | """ 32 | if not isinstance(app_id, str): 33 | app_id = str(app_id) 34 | md5 = hashlib.md5() 35 | md5.update(app_id.encode('utf-8')) 36 | encoded_str = md5.hexdigest().upper() 37 | return encoded_str 38 | 39 | def get_request_sign(parser, app_key): 40 | """获取请求签名 41 | :param app_key => 应用标识 42 | """ 43 | params = sorted(parser.items()) 44 | uri_str = parse.urlencode(params, encoding="UTF-8") 45 | sign_str = '{}&app_key={}'.format(uri_str, app_key) 46 | hash_md5 = hashlib.md5(sign_str.encode("UTF-8")) 47 | return hash_md5.hexdigest().upper() 48 | 49 | def get_base64(pic_param): 50 | """获取媒体的Base64字符串 51 | :param media_param => 媒体URL或者图片文件的BufferedReader对象 52 | """ 53 | if isinstance(pic_param, str): 54 | pic_data = requests.get(pic_param, headers=USERAGENT).content 55 | elif hasattr(pic_param, 'read'): 56 | pic_data = pic_param.read() 57 | else: 58 | raise TypeError('The picture media must be URL or BufferedReader.') 59 | # 将图片内容进行转码存储 60 | image = base64.b64encode(pic_data).decode("utf-8") 61 | return image 62 | -------------------------------------------------------------------------------- /girlfriend/components/ai_robot.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | 利用腾讯AI平台实现一个自动回复的聊天机器人 4 | 5 | Usage: 6 | from girlfriend.components.ai_robot import Chatbot 7 | it = Chatbot('your_app_id', 'your_app_key') 8 | it.run('text') 9 | """ 10 | 11 | from urllib import parse 12 | import requests 13 | 14 | from girlfriend.utils.tencent import get_time_stamp, get_nonce_str 15 | from girlfriend.utils.tencent import md5_encode, get_request_sign 16 | 17 | CONTENTTYPE = { 18 | 'Content-Type': 'application/x-www-form-urlencoded' 19 | } 20 | 21 | class Chatbot: 22 | """腾讯聊天机器人""" 23 | def __init__(self, app_id=None, app_key=None): 24 | self.app_id = app_id 25 | self.app_key = app_key 26 | self.tencent_chat_url = 'https://api.ai.qq.com/fcgi-bin/nlp/nlp_textchat' 27 | 28 | def make_params(self, text): 29 | """获取调用接口的参数""" 30 | if self.app_id is None or self.app_key is None: 31 | print('The app_id or app_key is none, please check.') 32 | params = { 33 | 'app_id': self.app_id, # 应用标识 34 | 'time_stamp': get_time_stamp(), # 请求时间戳(秒级) 35 | 'nonce_str': get_nonce_str(), # 随机字符串 36 | 'session': md5_encode(self.app_id), # 会话标识 37 | 'question': text # 用户输入的聊天内容 38 | } 39 | params['sign'] = get_request_sign(params, self.app_key) # 签名信息 40 | return params 41 | 42 | def run(self, text): 43 | """执行方法(可多次执行)""" 44 | params = self.make_params(text) 45 | response = requests.post(self.tencent_chat_url, 46 | data=parse.urlencode(params).encode("utf-8"), 47 | headers=CONTENTTYPE) 48 | if response.status_code == 200: 49 | data_dict = response.json() 50 | if data_dict['ret'] == 0: 51 | print(data_dict['data']['answer']) 52 | -------------------------------------------------------------------------------- /girlfriend/components/ai_picture.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | 利用腾讯AI平台识别图片内容信息并自动生成文字描述 4 | 5 | Usage: 6 | from girlfriend.components.ai_picture import PicToText 7 | it = PicToText('your_app_id', 'your_app_key') 8 | it.run('URL' or 'FileObj') 9 | """ 10 | 11 | from urllib import parse 12 | import requests 13 | 14 | from girlfriend.utils.tencent import get_time_stamp, get_nonce_str 15 | from girlfriend.utils.tencent import get_request_sign, get_base64 16 | 17 | CONTENTTYPE = { 18 | 'Content-Type': 'application/x-www-form-urlencoded' 19 | } 20 | 21 | 22 | class PicToText: 23 | """看图说话""" 24 | def __init__(self, app_id=None, app_key=None): 25 | self.app_id = app_id 26 | self.app_key = app_key 27 | self.tencent_pic_url = 'https://api.ai.qq.com/fcgi-bin/vision/vision_imgtotext' 28 | 29 | def make_params(self, pic_param): 30 | """获取调用接口的参数""" 31 | if self.app_id is None or self.app_key is None: 32 | print('The app_id or app_key is none, please check.') 33 | params = { 34 | 'app_id': self.app_id, # 应用标识 35 | 'time_stamp': get_time_stamp(), # 请求时间戳(秒级) 36 | 'nonce_str': get_nonce_str(), # 随机字符串 37 | 'image': get_base64(pic_param), # 图片内容 38 | 'session_id': get_time_stamp() # 会话标识 39 | } 40 | params['sign'] = get_request_sign(params, self.app_key) # 签名信息 41 | return params 42 | 43 | def run(self, pic_param): 44 | """执行方法(可多次执行)""" 45 | params = self.make_params(pic_param) 46 | response = requests.post(self.tencent_pic_url, 47 | data=parse.urlencode(params).encode("utf-8"), 48 | headers=CONTENTTYPE) 49 | if response.status_code == 200: 50 | data_dict = response.json() 51 | if data_dict['ret'] == 0: 52 | print(data_dict['data']['text']) 53 | -------------------------------------------------------------------------------- /girlfriend/components/ai_ocr.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | 利用腾讯AI平台实现实现图片的识别和提取 4 | Usage: 5 | from girlfriend.components.ai_ocr import PictureOCR 6 | it = PictureOCR('your_app_id', 'your_app_key') 7 | it.run('URL' or 'FileObj') 8 | """ 9 | 10 | from urllib import parse 11 | import requests 12 | 13 | from girlfriend.utils.tencent import get_time_stamp, get_nonce_str 14 | from girlfriend.utils.tencent import get_request_sign, get_base64 15 | 16 | CONTENTTYPE = { 17 | 'Content-Type': 'application/x-www-form-urlencoded' 18 | } 19 | 20 | 21 | class PictureOCR: 22 | """识别图片转文字""" 23 | def __init__(self, app_id=None, app_key=None, image_path=None, image_name=None): 24 | self.app_id = app_id 25 | self.app_key = app_key 26 | self.image_path = image_path 27 | self.image_name = image_name 28 | 29 | def make_params(self, pic_param): 30 | """获取调用接口的参数""" 31 | if self.app_id is None or self.app_key is None: 32 | print('The app_id or app_key is none, please check.') 33 | params = { 34 | 'app_id': self.app_id, # 应用标识 35 | 'image': get_base64(pic_param), # 图片内容 36 | 'card_type': 0, # 仅识别正面照片 37 | 'time_stamp': get_time_stamp(), # 请求时间戳(秒级) 38 | 'nonce_str': get_nonce_str() # 随机字符串 39 | } 40 | params['sign'] = get_request_sign(params, self.app_key) # 签名信息 41 | return params 42 | 43 | def id_card_run(self, pic_param): 44 | """识别身份证图片(正面照片)(可多次执行)""" 45 | id_card_url = 'https://api.ai.qq.com/fcgi-bin/ocr/ocr_idcardocr' 46 | params = self.make_params(pic_param) 47 | response = requests.post(id_card_url, 48 | data=parse.urlencode(params).encode("utf-8"), 49 | headers=CONTENTTYPE) 50 | if response.status_code == 200: 51 | data_dict = response.json() 52 | if data_dict['ret'] == 0: 53 | id_card_data = data_dict['data'] 54 | print(', '.join([id_card_data['name'], id_card_data['sex'], 55 | id_card_data['nation'], id_card_data['birth'], 56 | id_card_data['address'], id_card_data['id']])) 57 | -------------------------------------------------------------------------------- /girlfriend/test/confirm_friend.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | 检测是否有删除自己或把自己拉入黑名单的朋友 4 | 原理: 将好友拉入群聊时,非好友和黑名单好友不会被拉入群聊 5 | 隐蔽: 群聊在第一次产生普通消息时才会被除创建者以外的人发现的(系统消息不算普通消息) 6 | 7 | Usage: 8 | itchat.auto_login(hotReload=True, enableCmdQR=2) 9 | CONFIRM = ConfirmFriend() 10 | CONFIRM.get_friend_status() 11 | """ 12 | 13 | import itchat 14 | 15 | 16 | class ConfirmFriend: 17 | """自动检测好友关系""" 18 | def __init__(self, chatroom=None, chatroom_name='friends'): 19 | self.chatroom = chatroom 20 | self.chatroom_name = chatroom_name 21 | self.status_dict = {3: '该好友已经将你加入黑名单', 4: '该好友已经将你删除'} 22 | 23 | def get_chatroom(self): 24 | """获取群组信息""" 25 | if self.chatroom is None: 26 | itchat.get_chatrooms(update=True) 27 | chatrooms = itchat.search_chatrooms(self.chatroom) 28 | if chatrooms: 29 | return chatrooms[0] 30 | room = itchat.create_chatroom(itchat.get_friends()[1:4], topic=self.chatroom_name) 31 | if room['BaseResponse']['ErrMsg'] == '': 32 | self.chatroom = {'UserName': room['ChatRoomName']} 33 | return self.chatroom 34 | return self.chatroom 35 | 36 | def get_friend_status(self): 37 | """获取好友状态""" 38 | own_account = itchat.get_friends(update=True)[0] 39 | friends_total_number = len(itchat.get_friends()) 40 | for num in range(friends_total_number): 41 | friend = itchat.get_friends()[num] 42 | if friend['UserName'] == own_account['UserName']: 43 | return "This account is not checked for my account." 44 | if itchat.search_friends(userName=friend['UserName']) is None: 45 | return "The user is not exist." 46 | 47 | chatroom = self.chatroom or self.get_chatroom() 48 | if chatroom is None: 49 | return '无法自动创建群聊请手动创建 | 创建后请将群聊保存到通讯录' 50 | room = itchat.add_member_into_chatroom(chatroom['UserName'], [friend]) 51 | if room['BaseResponse']['ErrMsg'] == '': 52 | friend_status = room['MemberList'][0]['MemberStatus'] 53 | itchat.delete_member_from_chatroom(chatroom['UserName'], [friend]) 54 | return self.status_dict.get(friend_status, '该好友仍旧与你是好友关系') 55 | return u'无法获取好友状态,预计已经达到接口调用限制。' 56 | -------------------------------------------------------------------------------- /girlfriend/test/learn_itchat.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """简单介绍了关于itchat模块的使用技巧""" 3 | 4 | import time 5 | import json 6 | 7 | import itchat 8 | 9 | 10 | # ------------------------------------------------ 11 | # 发送消息给好友 12 | # ------------------------------------------------ 13 | friend = itchat.search_friends(nickName='Escape')[0] 14 | print(json.dumps(friend, sort_keys=True, indent=4, separators=(',', ':'))) 15 | friend.send('Happy New Year.') 16 | 17 | # ------------------------------------------------ 18 | # 发送消息给群聊 19 | # ------------------------------------------------ 20 | chatroom = itchat.search_chatrooms(name='EscapeGroup')[0] 21 | print(json.dumps(chatroom, sort_keys=True, indent=4, separators=(',', ':'))) 22 | chatroom.send('Happy New Year.') 23 | 24 | 25 | 26 | # ------------------------------------------------ 27 | # 各类型消息的注册 28 | # 就日常的各种信息进行获取与回复 29 | # ------------------------------------------------ 30 | @itchat.msg_register([itchat.content.TEXT, itchat.content.MAP, itchat.content.CARD, itchat.content.NOTE, itchat.content.SHARING]) 31 | def text_friend_reply(msg): 32 | msg.user.send('%s: %s' % (msg.type, msg.text)) 33 | 34 | @itchat.msg_register([itchat.content.PICTURE, itchat.content.RECORDING, itchat.content.ATTACHMENT, itchat.content.VIDEO]) 35 | def download_files(msg): 36 | msg.download(msg.fileName) 37 | typeSymbol = { 38 | itchat.content.PICTURE: 'img', 39 | itchat.content.VIDEO: 'vid', }.get(msg.type, 'fil') 40 | return '@%s@%s' % (typeSymbol, msg.fileName) 41 | 42 | @itchat.msg_register(itchat.content.FRIENDS) 43 | def add_friend(msg): 44 | msg.user.verify() 45 | msg.user.send('Nice to meet you!') 46 | 47 | @itchat.msg_register(itchat.content.TEXT, isGroupChat=True) 48 | def text_chatroom_reply(msg): 49 | if msg.isAt: 50 | msg.user.send(u'@%s\u2005I received: %s' % (msg.actualNickName, msg.text)) 51 | 52 | itchat.auto_login(hotReload=True, enableCmdQR=2) 53 | itchat.run(debug=True, blockThread=True) 54 | 55 | # ------------------------------------------------ 56 | # 实现微信消息的获取 57 | # 文本对应 itchat.content.TEXT 58 | # 图片对应 itchat.content.PICTURE 59 | # 语音对应 itchat.content.RECORDING 60 | # 名片对应 itchat.content.CARD 61 | # ------------------------------------------------ 62 | @itchat.msg_register(itchat.content.TEXT) 63 | def print_content(msg): 64 | print(msg['Text']) 65 | 66 | itchat.auto_login(hotReload=True, enableCmdQR=2) 67 | itchat.run(debug=True, blockThread=True) 68 | 69 | # ------------------------------------------------ 70 | # 实现微信消息的发送 71 | # 微信可以发送各类消息/文本/图片/文件等 72 | # ------------------------------------------------ 73 | itchat.auto_login(hotReload=True, enableCmdQR=2) 74 | itchat.send(u'测试消息发送', 'filehelper') 75 | 76 | 77 | 78 | # ------------------------------------------------ 79 | # 退出及登陆完成后调用特定方法 80 | # ------------------------------------------------ 81 | def lc(): 82 | print('### login wechat ###') 83 | 84 | def ec(): 85 | print('### logout wechat ###') 86 | 87 | itchat.auto_login(hotReload=True, enableCmdQR=2, loginCallback=lc, exitCallback=ec) 88 | time.sleep(3) 89 | itchat.logout() 90 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | Raspi-X 4 | 5 |

6 | 7 |

8 | love_girlfriend ❤️爱自己女朋友就是爱自己 9 |

10 | 11 |

12 | love_girlfriend 13 | love_girlfriend 14 | love_girlfriend 15 | love_girlfriend 16 |

17 | 18 | ![https://github.com/EscapeLife/love-grilfriend](./images/love-grilfriend.png) 19 | 20 | ## 1. 项目介绍 21 | 22 | > **👊 女朋友 -> 老婆 👰🏻** 23 | 24 | 俗话说得好,爱自己的女朋友就是爱自己。那问题的关键就来了,我们需要怎么爱呢?该项目就是为了关心女友而创建,借鉴 [EverydayWechat](https://github.com/sfyc23/EverydayWechat) 项目,主要包含以下爱护功能: 25 | 26 | - **每日定时给好友发送特定消息** 27 | - 暖心话 28 | - 定时提醒 29 | - **机器人自动回复好友消息** 30 | - 忙碌时自动回复 31 | - 非工作时间勿扰 32 | - **附加扩展功能** 33 | - 天气信息 34 | - 每日一句 35 | - 每日诗歌 36 | - 票房数据 37 | 38 | ## 2. API 接口 39 | 40 | > **介绍项目中主要使用的 API 接口信息** 41 | 42 | - **天气信息** 43 | - [**`SOJSON`**](sojson.com/blog/305.html) 44 | - [**`RollToolsApi`**](https://github.com/MZCretin/RollToolsApi#%E8%8E%B7%E5%8F%96%E7%89%B9%E5%AE%9A%E5%9F%8E%E5%B8%82%E4%BB%8A%E6%97%A5%E5%A4%A9%E6%B0%94) 45 | - **每日一句** 46 | - [**`One`**](http://wufazhuce.com) 47 | - [**`一言`**](hitokoto.cn) 48 | - **智能机器人** 49 | - [**`腾讯智能闲聊`**](ai.qq.com/product/nlpchat.shtml) 50 | - **票房数据** 51 | - [**`猫眼实时票房`**](piaofang.maoyan.com/dashboard) 52 | - **空气质量** 53 | - [**`aqicn`**](http://aqicn.org/here) 54 | 55 | ## 3. 配置文件 56 | 57 | > **介绍配置文件的配置方式和方法** 58 | 59 | ```yaml 60 | 61 | ``` 62 | 63 | ## 4. 效果展示 64 | 65 | > **请看效果截图** 66 | 67 | ![love_girlfriend]() 68 | 69 | ## 5. 计划列表 70 | 71 | > **准备或者预计实现的功能和特性** 72 | 73 | - 将定时发送消息转换成图片形式 74 | - 附加扩展功能支持每日诗歌 75 | - 附加扩展功能支持地图查询([高德地图](https://lbs.amap.com/)|[腾讯地图](https://lbs.qq.com/webservice_v1/index.html)) 76 | - 附加扩展功能支持新闻资讯([feedly](https://developer.feedly.com/)|[HackerNews](https://github.com/HackerNews/API)|[纽约时报](https://developer.nytimes.com/)) 77 | - 附加扩展功能支持图片摄影([px500](https://github.com/500px/legacy-api-documentation)) 78 | 79 | ## 6. 参考项目 80 | 81 | > **下面是该项目参考项目** 82 | 83 | - [**`ItChat` - 微信个人号接口、微信机器人及命令行微信**](https://github.com/littlecodersh/ItChat) 84 | - [**`EverydayWechat` - 基于 Python3 与 Itchat 的微信小工具**](https://github.com/sfyc23/EverydayWechat) 85 | - [**`daily-warm` - 每天定时发邮件给你关心的人**](https://github.com/BarryYan/daily-warm) 86 | 87 | ## 7. 联系方式 88 | 89 | > **以下是我的个人联系方式** 90 | 91 |

92 | WX 93 |

94 | 95 | - **💭 [Name] 💭** 96 | - 🐠 **[`EscapeLife`](https://www.escapelife.site)** 😏 97 | - **💭 [Induction] 💭** 98 | - 🏦 **[`Focusing P.A.I`](https://www.paodingai.com)** 😂 99 | - **💭 [Email] 💭** 100 | - 📫 **[`wenpanhappy@gmail.com`](https://www.escapelife.site)** 🤔 101 | - **💭 [Myblog] 💭** 102 | - 🍺 **[`https://www.escapelife.site`](https://www.escapelife.site)** 😚 103 | - **💭 [License] 💭** 104 | - 🚧 [**`Apache License, Version 2.0`**](http://www.apache.org/licenses/LICENSE-2.0.html)😝 105 | -------------------------------------------------------------------------------- /docs/README_EN.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | Raspi-X 4 | 5 |

6 | 7 |

8 | love_girlfriend 9 |

10 | 11 |

12 | love_girlfriend 13 | love_girlfriend 14 | love_girlfriend 15 | love_girlfriend 16 |

17 | 18 | ## 1. Introduction 19 | 20 | > **👊 girlfriend - > the wife 👰** 21 | 22 | As the saying goes, love your girlfriend is love yourself. That's the question, how do we need to love? This project is created to care about my girlfriend. It borrows from EverydayWechat project and mainly contains the following functions: 23 | 24 | - **send specific messages to friends at regular times every day** 25 | - warm heart words 26 | - regular reminders 27 | - **the robot automatically replies to friend messages** 28 | - auto reply when busy 29 | - not during non-working hours 30 | - **additional extensions** 31 | - weather information 32 | - sentence of the day 33 | - poetry of the day 34 | - box office data 35 | 36 | ## 2. API 37 | 38 | > **Describes the main API interface information used in the project** 39 | 40 | - **Weather information** 41 | - [**`SOJSON`**](sojson.com/blog/305.html) 42 | - [**`RollToolsApi`**](https://github.com/MZCretin/RollToolsApi#%E8%8E%B7%E5%8F%96%E7%89%B9%E5%AE%9A%E5%9F%8E%E5%B8%82%E4%BB%8A%E6%97%A5%E5%A4%A9%E6%B0%94) 43 | - **Daily sentence** 44 | - [**`One`**](http://wufazhuce.com) 45 | - [**`Hitokoto`**](hitokoto.cn) 46 | - **Intelligent robot** 47 | - [**`TencentChat`**](ai.qq.com/product/nlpchat.shtml ) 48 | - **Sales data** 49 | - [**`Maoyan`**](piaofang.maoyan.com/dashboard) 50 | - **Air quality** 51 | - [**`Aqicn`**](http://aqicn.org/here) 52 | 53 | ## 3. Configuration 54 | 55 | > **Describes the configuration methods and methods of configuration files** 56 | 57 | ```yaml 58 | 59 | ``` 60 | 61 | ## 4. Exhibition 62 | 63 | > **Please see the screenshot.** 64 | 65 | ![exhibition]() 66 | 67 | ## 5. TodoList 68 | 69 | > **Functions and features to be prepared or expected to be implemented** 70 | 71 | - Converts a timed send message into a picture 72 | - Additional extensions support daily poetry 73 | 74 | ## 6. Credits 75 | 76 | > **The following is the project reference project** 77 | 78 | - [**`ItChat`**](https://github.com/littlecodersh/ItChat) 79 | - [**`EverydayWechat`**](https://github.com/sfyc23/EverydayWechat) 80 | - [**`daily-warm`**](https://github.com/BarryYan/daily-warm) 81 | 82 | ## 7. Contact 83 | 84 | > **Below is my personal contact information.** 85 | 86 |

87 | WX 88 |

89 | 90 | - **💭 [Name] 💭** 91 | - 🐠 **[`EscapeLife`](https://escapelife.github.io)** 😏 92 | - **💭 [Induction] 💭** 93 | - 🏦 **[`Focusing P.A.I`](https://paodingai.com/)** 😂 94 | - **💭 [Email] 💭** 95 | - 📫 **[`wenpanhappy@gmail.com`](https://escapelife.github.io)** 🤔 96 | - **💭 [Myblog] 💭** 97 | - 🍺 **[`https://escapelife.github.io`](https://escapelife.github.io)** 😚 98 | - **💭 [License] 💭** 99 | - 🚧 [**`Apache License, Version 2.0`**](http://www.apache.org/licenses/LICENSE-2.0.html)😝 100 | -------------------------------------------------------------------------------- /girlfriend/components/ai_youtu.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | 利用腾讯万象优图平台实现图片的识别和提取 4 | 5 | 项目地址 6 | https://github.com/tencentyun/image-python-sdk-v2.0 7 | """ 8 | 9 | from qcloud_image import Client 10 | from qcloud_image import CIUrl, CIFile, CIBuffer, CIUrls, CIFiles, CIBuffers 11 | 12 | 13 | class CloudImage: 14 | """万象优图(付费服务)""" 15 | def __init__(self, app_id, secret_id, secret_key, bucket, 16 | image_surface=None, image_url=None, image_file=None): 17 | self.app_id = app_id 18 | self.secret_id = secret_id 19 | self.secret_key = secret_key 20 | self.bucket = bucket 21 | self.image_surface = image_surface 22 | self.image_url = image_url 23 | self.image_file = image_file 24 | 25 | def get_client(self): 26 | """获取连接对象""" 27 | client = Client(self.app_id, self.secret_id, self.secret_key, self.bucket) 28 | client.use_http() 29 | client.set_timeout(30) 30 | return client 31 | 32 | def id_card_url_ocr(self): 33 | """OCR-URL-身份证识别""" 34 | client = self.get_client() 35 | if len(self.image_url) >= 0 and self.image_surface == 'front': 36 | # 返回正面URL图片信息 37 | print(client.idcard_detect(CIUrls(self.image_url), 0)) 38 | elif len(self.image_url) >= 0 and self.image_surface == 'backend': 39 | # 返回反面URL图片信息 40 | print(client.idcard_detect(CIUrls(self.image_url), 1)) 41 | 42 | def id_card_file_ocr(self): 43 | """OCR-File-身份证识别""" 44 | client = self.get_client() 45 | if len(self.image_file) >= 0 and self.image_surface == 'front': 46 | # 返回正面文件图片信息 47 | print(client.idcard_detect(CIUrls(self.image_file), 0)) 48 | elif len(self.image_file) >= 0 and self.image_surface == 'backend': 49 | # 返回反面文件图片信息 50 | print(client.idcard_detect(CIUrls(self.image_file), 1)) 51 | 52 | def id_card_diff_ocr(self): 53 | """OCR-身份证识别对比""" 54 | client = self.get_client() 55 | if len(self.image_url) >= 0: 56 | # 身份证URL图片信息 57 | print(client.face_idcardcompare('ID CARD NUM', 'NAME', CIUrl(self.image_url[0]))) 58 | if len(self.image_file) >= 0: 59 | # 身份证文件图片信息 60 | print(client.face_idcardcompare('ID CARD NUM', 'NAME', CIFile(self.image_file[0]))) 61 | 62 | def image_as_yellow_ocr(self): 63 | """OCR-图片鉴黄""" 64 | client = self.get_client() 65 | if len(self.image_url) >= 0: 66 | # URL图片信息 67 | print(client.porn_detect(CIUrls(self.image_url))) 68 | if len(self.image_file) >= 0: 69 | # 文件图片信息 70 | print(client.porn_detect(CIFiles(self.image_file))) 71 | 72 | def business_card_ocr(self): 73 | """OCR-名片识别""" 74 | client = self.get_client() 75 | if len(self.image_url) >= 0: 76 | # URL图片信息 77 | print(client.namecard_detect(CIUrls(self.image_url))) 78 | if len(self.image_file) >= 0: 79 | # 文件图片信息 80 | print(client.namecard_detect(CIFiles(self.image_file))) 81 | 82 | def face_detection(self): 83 | """Face-人脸检测""" 84 | client = self.get_client() 85 | if len(self.image_url) >= 0: 86 | # URL图片信息 87 | print(client.face_detect(CIUrls(self.image_url))) 88 | if len(self.image_file) >= 0: 89 | # 文件图片信息 90 | print(client.face_detect(CIFiles(self.image_file))) 91 | 92 | def facial_detection(self): 93 | """Face-五官定位""" 94 | client = self.get_client() 95 | if len(self.image_url) >= 0: 96 | # URL图片信息 97 | print(client.face_shape(CIUrls(self.image_url), 1)) 98 | if len(self.image_file) >= 0: 99 | # 文件图片信息 100 | print(client.face_shape(CIFiles(self.image_file), 1)) 101 | 102 | def face_diff(self): 103 | """Face-人脸对比""" 104 | client = self.get_client() 105 | if len(self.image_url) >= 0: 106 | # URL图片信息 107 | print(client.face_compare(CIFile(self.image_url[0]), CIFile(self.image_url[1]))) 108 | if len(self.image_file) >= 0: 109 | # 文件图片信息 110 | print(client.face_compare(CIUrl(self.image_url[0]), CIUrl(self.image_url[1]))) 111 | if len(self.image_url) >= 0 and len(self.image_file) >= 0: 112 | # URL图片信息和文件图片信息 113 | print(client.face_compare(CIUrl(self.image_url[0]), CIFile(self.image_file[0]))) 114 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------