├── assets ├── screenshot.png └── screenshot.zh-cn.png ├── requirements.txt ├── cookie.example.json ├── README.zh-cn.md ├── README.MD ├── bing.py └── LICENSE /assets/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pininkara/BingChatBot/HEAD/assets/screenshot.png -------------------------------------------------------------------------------- /assets/screenshot.zh-cn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pininkara/BingChatBot/HEAD/assets/screenshot.zh-cn.png -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | aiohttp==3.8.4 2 | EdgeGPT~=0.2.1 3 | pyTelegramBotAPI==4.10.0 4 | telebot~=0.0.5 5 | asyncio~=3.4.3 -------------------------------------------------------------------------------- /cookie.example.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "", 4 | "value": "", 5 | "domain": "", 6 | "hostOnly": false, 7 | "path": "", 8 | "secure": true, 9 | "httpOnly": false, 10 | "sameSite": "", 11 | "session": false, 12 | "firstPartyDomain": "", 13 | "partitionKey": null, 14 | "expirationDate": 1, 15 | "storeId": null 16 | }, 17 | 18 | { 19 | "name": "", 20 | "value": "", 21 | "domain": "", 22 | "hostOnly": false, 23 | "path": "/", 24 | "secure": true, 25 | "httpOnly": false, 26 | "sameSite": "", 27 | "session": false, 28 | "firstPartyDomain": "", 29 | "partitionKey": null, 30 | "expirationDate": 5, 31 | "storeId": null 32 | } 33 | ] -------------------------------------------------------------------------------- /README.zh-cn.md: -------------------------------------------------------------------------------- 1 | 语言:[English](README.MD) 简体中文 2 | # 介绍 3 | 4 | 使用非官方 [EdgeChat](https://github.com/acheong08/EdgeGPT) API 的 Python 实现的 Bing 聊天 Telegram 机器人 5 | 6 | ## 已知问题 7 | 8 | - 如果微软更改了对话中的消息数,Messages In Conversation在cookie更新前都会是5 9 | 10 | ## 截图 11 | 12 | ![](assets/screenshot.zh-cn.png) 13 | 14 | ## 命令列表 15 | 16 | ``` 17 | help - 帮助信息 18 | reset - 重置对话 19 | switch - 切换对话风格 ( creative , balanced , precise ) 20 | ``` 21 | 22 | # 安装 23 | 24 | ## 需求 25 | 26 | - python 3.8+ 27 | - 一个能访问 http://bing.com/chat的微软账号 (必须!) 28 | 29 | ## 检查访问权限 30 | 31 | - 安装最新版本的 Microsoft Edge 32 | - 访问 http://bing.com/chat 33 | - 如果你能看到聊天界面,说明你有访问权限 34 | 35 | ## 获取cookie 36 | 37 | - 安装cookie插件:[Chrome和Edge](https://chrome.google.com/webstore/detail/cookie-editor/hlkenndednhfkekhgcdicdfddnkalmdm) , [Firefox](https://addons.mozilla.org/en-US/firefox/addon/cookie-editor/) 38 | - 访问 http://bing.com/chat 39 | - 打开插件 40 | - 点击底部的Export按钮 (cookie将会复制到你的剪贴板) 41 | - 粘贴你的cookie到 `cookies.json`. json的格式参见 `cookie.exaple.json`(中间部分省略) 42 | 43 | ## 安装依赖 44 | 45 | ```shell 46 | pip install -r requirements.txt 47 | ``` 48 | 49 | ## 设置环境变量 50 | 51 | ### 必须变量 52 | 53 | ```shell 54 | export BOT_TOKEN='REPLACE YOUR BOT TOKEN' 55 | export ALLOWED_USER_IDS='XXXXXXXXX,XXXXXXXX,XXXXXXXX' 56 | ``` 57 | 58 | ### 可选变量 59 | 60 | ```shell 61 | #默认值为 './cookie.json' 62 | export COOKIE_PATH='xxxxxx' 63 | 64 | #默认值为 False , 如果你设置为True,任何人都可以使用bot 65 | export PUBLIC_MODE=False 66 | ``` 67 | 68 | :warning:即使设置PUBLIC_MODE为True,也请设置ALLOWED_USER_IDS,因为只有ALLOWED_USER_IDS才能切换对话风格 69 | 70 | 如果你想将bot添加至群聊,请设置这些环境变量,并授予bot管理员权限 71 | 72 | ```shell 73 | export BOT_ID='@YOURBOTID' #别忘了@ 74 | export GROUP_MODE=False #默认值为 False 75 | ``` 76 | 如果 GROUP_MODE 为True ,bot将会回复群组里所有消息 , 否则bot只会回复@它的消息。私聊消息一直会回复 77 | 78 | ## 运行 79 | 80 | ```shell 81 | python bing.py 82 | ``` 83 | 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /README.MD: -------------------------------------------------------------------------------- 1 | Language : English [简体中文](README.zh-cn.md) 2 | # Description 3 | 4 | Bing chat Telegram bot implemented in Python that utilizes unofficial [EdgeChat](https://github.com/acheong08/EdgeGPT) API 5 | 6 | ## Known issues 7 | 8 | - If Microsoft changes the message count in the conversation, the Messages In Conversation will be 5 until the cookie is updated. 9 | 10 | ## Screenshot 11 | 12 | ![](assets/screenshot.png) 13 | 14 | ## Command list 15 | 16 | ``` 17 | help - Show help message 18 | reset - Reset conversation 19 | switch - Switch conversation style ( creative , balanced , precise ) 20 | ``` 21 | 22 | # Setup 23 | 24 | ## Requirements 25 | 26 | - python 3.8+ 27 | - A Microsoft Account with early access to http://bing.com/chat (Required) 28 | 29 | ## Checking access (Required) 30 | 31 | - Install the latest version of Microsoft Edge 32 | - Open http://bing.com/chat 33 | - If you see a chat feature, you are good to go 34 | 35 | ## Getting authentication (Required) 36 | 37 | - Install the cookie editor extension for [Chrome and Edge](https://chrome.google.com/webstore/detail/cookie-editor/hlkenndednhfkekhgcdicdfddnkalmdm) or [Firefox](https://addons.mozilla.org/en-US/firefox/addon/cookie-editor/) 38 | - Go to `bing.com` 39 | - Open the extension 40 | - Click "Export" on the bottom right (This saves your cookies to clipboard) 41 | - Paste your cookies into a file `cookies.json`. The format of json refers to `cookie.exaple.json`(The middle field is omitted) 42 | 43 | ## Install requirements 44 | 45 | ```shell 46 | pip install -r requirements.txt 47 | ``` 48 | 49 | ## Set environment variables 50 | 51 | ### Required variable 52 | 53 | ```shell 54 | export BOT_TOKEN='REPLACE YOUR BOT TOKEN' 55 | export ALLOWED_USER_IDS='XXXXXXXXX,XXXXXXXX,XXXXXXXX' 56 | ``` 57 | 58 | ### Optional variable 59 | 60 | ```shell 61 | #Default value is './cookie.json' 62 | export COOKIE_PATH='xxxxxx' 63 | 64 | #Default value is False , if you set True , Anyone can use the robot 65 | export PUBLIC_MODE=False 66 | ``` 67 | 68 | :warning:Please set ALLOWED_USER_IDS even if PUBLIC_MODE is True , because only ALLOWED_USER_IDS can switch the conversation style 69 | 70 | If you want to add the bot to the group chat , please set these variables and give the bot admin permission 71 | 72 | ```shell 73 | export BOT_ID='@YOURBOTID' #DON'T forget @ 74 | export GROUP_MODE=False #Default value is False 75 | ``` 76 | If GROUP_MODE is True , The bot will reply to all messages in the group chat , else the bot will only reply to @ messages in the group chat. Private chat will always reply 77 | 78 | ## Run 79 | 80 | ```shell 81 | python bing.py 82 | ``` 83 | 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /bing.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import os 3 | import re 4 | 5 | import telebot 6 | from EdgeGPT import Chatbot, ConversationStyle 7 | from telebot.util import quick_markup 8 | 9 | BOT_TOKEN = os.getenv('BOT_TOKEN') 10 | ALLOWED_USER_IDS = os.getenv('ALLOWED_USER_IDS').split(',') 11 | BOT_ID = os.getenv('BOT_ID', '') 12 | COOKIE_PATH = os.getenv('COOKIE_PATH', './cookie.json') 13 | GROUP_MODE = os.getenv('GROUP_MODE', 'False') 14 | PUBLIC_MODE = os.getenv('PUBLIC_MODE', 'False') 15 | 16 | print("\033[1;33mThe startup is successful, the configuration is as follows : ") 17 | print("BOT_TOKEN: " + BOT_TOKEN) 18 | print("BOT_ID: " + BOT_ID) 19 | print("ALLOWED_USER_IDS: ") 20 | print(ALLOWED_USER_IDS) 21 | print("COOKIE_PATH: " + COOKIE_PATH) 22 | print("GROUP_MODE: " + GROUP_MODE) 23 | print("PUBLIC_MODE: " + PUBLIC_MODE + '\033[1;33m') 24 | 25 | bot = telebot.TeleBot(BOT_TOKEN) 26 | EDGES = {} 27 | 28 | not_allow_info = '⚠️You are not authorized to use this bot⚠️' 29 | 30 | markup = quick_markup({ 31 | 'Github': {'url': 'https://github.com/pininkara/BingChatBot'}, 32 | }, row_width=1) 33 | 34 | my_conversation_style = ConversationStyle.balanced 35 | 36 | 37 | @bot.message_handler(commands=['start', 'help']) 38 | def send_welcome(message): 39 | if is_allowed(message) or PUBLIC_MODE == "True" or message.chat.type == "group": 40 | bot.reply_to( 41 | message, "Bing Chat Bot By pininkara~\n/help - Show help message\n/reset - Reset conversation\n/switch - " 42 | "Switch conversation style (creative,balanced,precise)\n", reply_markup=markup) 43 | else: 44 | bot.reply_to(message, not_allow_info) 45 | 46 | 47 | @bot.message_handler(commands=['reset']) 48 | def send_reset(message): 49 | if is_allowed(message) or PUBLIC_MODE == "True" or message.chat.type == "group": 50 | try: 51 | if message.from_user.id not in EDGES: 52 | EDGES[message.from_user.id] = Chatbot(cookie_path=COOKIE_PATH) 53 | asyncio.run(EDGES[message.from_user.id].reset()) 54 | except Exception as e: 55 | print("\033[31mError: ", e) 56 | bot.reply_to(message, "Error : " + str(e), parse_mode='Markdown') 57 | else: 58 | bot.reply_to(message, "Reset successful🎉") 59 | else: 60 | bot.reply_to(message, not_allow_info) 61 | 62 | 63 | @bot.message_handler(commands=['switch']) 64 | def switch_style(message): 65 | if is_allowed(message): 66 | message_list = message.text.split(" ") 67 | if len(message_list) > 1: 68 | if message_list[1] == "creative": 69 | bot.reply_to( 70 | message, 71 | "Switch successful , current style is creative") 72 | elif message_list[1] == "balanced": 73 | conversation_style = ConversationStyle.balanced 74 | bot.reply_to( 75 | message, 76 | "Switch successful , current style is balanced") 77 | elif message_list[1] == "precise": 78 | conversation_style = ConversationStyle.precise 79 | bot.reply_to( 80 | message, 81 | "Switch successful , current style is precise") 82 | else: 83 | bot.reply_to( 84 | message, 85 | "Parameter error , please choose one of (creative,balanced,precise)\n(e.g./switch balanced") 86 | else: 87 | bot.reply_to( 88 | message, "Parameter error , please choose one of (creative,balanced,precise)\n(e.g./switch balanced") 89 | else: 90 | bot.reply_to( 91 | message, '⚠️You are not authorized to switch the conversation style⚠') 92 | 93 | 94 | @bot.message_handler(func=lambda msg: True) 95 | def response_all(message): 96 | print('\033[0;32mMessage: ' + message.text) 97 | print( 98 | 'From: ', message.from_user.first_name, message.from_user.last_name, ' @', message.from_user.username) 99 | 100 | message_text = '' 101 | is_reply = message.reply_to_message is not None and '@' + \ 102 | message.reply_to_message.from_user.username == BOT_ID 103 | if message.chat.type == "private" or GROUP_MODE == "True" or message.text.startswith(BOT_ID) or is_reply: 104 | if is_allowed(message) or PUBLIC_MODE == "True" or message.chat.type == "group": 105 | if message.text.startswith(BOT_ID) and BOT_ID != '': 106 | message_text = message.text[len(BOT_ID):] 107 | else: 108 | message_text = message.text 109 | response_list = asyncio.run(bing_chat(message_text, message)) 110 | print("\033[1;34mResponse: " + response_list[0]) 111 | if len(response_list[0]) > 4095: 112 | for x in range(0, len(response_list[0]), 4095): 113 | bot.reply_to( 114 | message, response_list[0][x:x + 4095], parse_mode='Markdown', reply_markup=response_list[1]) 115 | else: 116 | bot.reply_to( 117 | message, response_list[0], parse_mode='Markdown', reply_markup=response_list[1]) 118 | else: 119 | bot.reply_to(message, not_allow_info) 120 | else: 121 | print('\033[0;36mUntargeted message, ignored\033[0;36m') 122 | 123 | 124 | @bot.callback_query_handler(func=lambda msg: True) 125 | def callback_all(callback_query): 126 | print("\033[0;32mCallbackQuery: " + callback_query.data) 127 | print( 128 | 'From: ', callback_query.from_user.first_name, callback_query.from_user.last_name, '@', 129 | callback_query.from_user.username) 130 | try: 131 | response_list = asyncio.run( 132 | bing_chat(callback_query.data, callback_query)) 133 | except Exception as e: 134 | print("\033[31mError: ", e) 135 | bot.reply_to(callback_query.message, "Error : " + 136 | str(e), parse_mode='Markdown') 137 | else: 138 | print("\033[1;34mResponse: " + response_list[0] + '\033[1;34m') 139 | if len(response_list[0]) > 4095: 140 | for x in range(0, len(response_list[0]), 4095): 141 | bot.reply_to( 142 | callback_query.message, response_list[0][x:x + 143 | 4095], parse_mode='Markdown', 144 | reply_markup=response_list[1]) 145 | else: 146 | bot.reply_to( 147 | callback_query.message, response_list[0], parse_mode='Markdown', reply_markup=response_list[1]) 148 | 149 | 150 | async def bing_chat(message_text, message): 151 | if message.from_user.id not in EDGES: 152 | EDGES[message.from_user.id] = Chatbot(cookie_path=COOKIE_PATH) 153 | response_dict = await EDGES[message.from_user.id].ask(prompt=message_text, 154 | conversation_style=my_conversation_style) 155 | 156 | if 'text' in response_dict['item']['messages'][1]: 157 | response = re.sub(r'\[\^\d\^]', '', 158 | response_dict['item']['messages'][1]['text']) 159 | else: 160 | response = "Something wrong. Please reset chat" 161 | 162 | if 'suggestedResponses' in response_dict['item']['messages'][1]: 163 | suggested_responses0 = re.sub( 164 | r'\[\^\d\^]', '', response_dict['item']['messages'][1]['suggestedResponses'][0]['text']) 165 | suggested_responses1 = re.sub( 166 | r'\[\^\d\^]', '', response_dict['item']['messages'][1]['suggestedResponses'][1]['text']) 167 | suggested_responses2 = re.sub( 168 | r'\[\^\d\^]', '', response_dict['item']['messages'][1]['suggestedResponses'][2]['text']) 169 | markup = quick_markup({ 170 | suggested_responses0: { 171 | 'callback_data': suggested_responses0.encode('utf-8')[:64].decode('utf-8', 'ignore')}, 172 | suggested_responses1: { 173 | 'callback_data': suggested_responses1.encode('utf-8')[:64].decode('utf-8', 'ignore')}, 174 | suggested_responses2: {'callback_data': suggested_responses2.encode( 175 | 'utf-8')[:64].decode('utf-8', 'ignore')} 176 | }, row_width=1) 177 | else: 178 | markup = quick_markup({ 179 | 'No Suggested Responses': {'url': 'https://bing.com/chat'} 180 | }, row_width=1) 181 | 182 | if 'maxNumUserMessagesInConversation' in response_dict['item']['throttling'] and 'numUserMessagesInConversation' in \ 183 | response_dict['item']['throttling']: 184 | max_num_user_messages_in_conversation = response_dict['item'][ 185 | 'throttling']['maxNumUserMessagesInConversation'] 186 | num_user_messages_in_conversation = response_dict[ 187 | 'item']['throttling']['numUserMessagesInConversation'] 188 | response = response + "\n----------\n" 189 | response = response + "Messages In Conversation : %d / %d" % ( 190 | num_user_messages_in_conversation, max_num_user_messages_in_conversation) 191 | 192 | if num_user_messages_in_conversation >= max_num_user_messages_in_conversation: 193 | await EDGES[message.from_user.id].reset() 194 | response = response + "\nAutomatic reset succeeded🎉" 195 | 196 | if len(response_dict['item']['messages'][1]['sourceAttributions']) >= 3: 197 | provider_display_name0 = re.sub( 198 | r'\[\^\d\^]', '', response_dict['item']['messages'][1]['sourceAttributions'][0]['providerDisplayName']) 199 | see_more_url0 = re.sub( 200 | r'\[\^\d\^]', '', response_dict['item']['messages'][1]['sourceAttributions'][0]['seeMoreUrl']) 201 | provider_display_name1 = re.sub( 202 | r'\[\^\d\^]', '', response_dict['item']['messages'][1]['sourceAttributions'][1]['providerDisplayName']) 203 | see_more_url1 = re.sub( 204 | r'\[\^\d\^]', '', response_dict['item']['messages'][1]['sourceAttributions'][1]['seeMoreUrl']) 205 | provider_display_name2 = re.sub( 206 | r'\[\^\d\^]', '', response_dict['item']['messages'][1]['sourceAttributions'][2]['providerDisplayName']) 207 | see_more_url2 = re.sub( 208 | r'\[\^\d\^]', '', response_dict['item']['messages'][1]['sourceAttributions'][2]['seeMoreUrl']) 209 | response = response + "\n----------\nReference:\n" 210 | response = response + \ 211 | "1.[%s](%s)\n" % (provider_display_name0, see_more_url0) 212 | response = response + \ 213 | "2.[%s](%s)\n" % (provider_display_name1, see_more_url1) 214 | response = response + \ 215 | "3.[%s](%s)\n" % (provider_display_name2, see_more_url2) 216 | 217 | markup = quick_markup({ 218 | suggested_responses0: {'callback_data': suggested_responses0.encode('utf-8')[:64].decode('utf-8', 'ignore')}, 219 | suggested_responses1: {'callback_data': suggested_responses1.encode('utf-8')[:64].decode('utf-8', 'ignore')}, 220 | suggested_responses2: {'callback_data': suggested_responses2.encode( 221 | 'utf-8')[:64].decode('utf-8', 'ignore')} 222 | }, row_width=1) 223 | response_list = [response, markup] 224 | return response_list 225 | 226 | 227 | def is_allowed(message) -> bool: 228 | # Check if user is allowed 229 | if str(message.from_user.id) in ALLOWED_USER_IDS: 230 | return True 231 | 232 | return False 233 | 234 | 235 | bot.infinity_polling() 236 | -------------------------------------------------------------------------------- /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 | --------------------------------------------------------------------------------