Skip to content

Commit

Permalink
Allow specification of ssl verification for hipchat adapters.
Browse files Browse the repository at this point in the history
  • Loading branch information
Achimh3011 authored and gunthercox committed Jul 30, 2017
1 parent 0a95352 commit 04b064e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 5 additions & 2 deletions chatterbot/input/hipchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ def __init__(self, **kwargs):
self.hipchat_room = kwargs.get('hipchat_room')
self.session_id = str(self.chatbot.default_session.uuid)

import requests
self.session = requests.Session()
self.session.verify = kwargs.get('ssl_verify', True)

authorization_header = 'Bearer {}'.format(self.hipchat_access_token)

self.headers = {
Expand Down Expand Up @@ -48,15 +52,14 @@ def view_recent_room_history(self, room_id_or_name, max_results=1):
"""
https://www.hipchat.com/docs/apiv2/method/view_recent_room_history
"""
import requests

recent_histroy_url = '{}/v2/room/{}/history?max-results={}'.format(
self.hipchat_host,
room_id_or_name,
max_results
)

response = requests.get(
response = self.session.get(
recent_histroy_url,
headers=self.headers
)
Expand Down
8 changes: 5 additions & 3 deletions chatterbot/output/hipchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,21 @@ def __init__(self, **kwargs):
'Content-Type': 'application/json'
}

import requests
self.session = requests.Session()
self.session.verify = kwargs.get('ssl_verify', True)

def send_message(self, room_id_or_name, message):
"""
Send a message to a HipChat room.
https://www.hipchat.com/docs/apiv2/method/send_message
"""
import requests

message_url = "{}/v2/room/{}/message".format(
self.hipchat_host,
room_id_or_name
)

response = requests.post(
response = self.session.post(
message_url,
headers=self.headers,
data=json.dumps({
Expand Down

0 comments on commit 04b064e

Please sign in to comment.