Skip to content

Commit

Permalink
Prepare for release 0.0.6
Browse files Browse the repository at this point in the history
Update to support Python3 for elements, appsecret_proofw
:
  • Loading branch information
drice committed Aug 1, 2016
1 parent 26b067e commit ec72b22
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pymessenger.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Metadata-Version: 1.1
Name: pymessenger
Version: 0.0.3.1
Version: 0.0.6.0
Summary: Python Wrapper for FB Messenger Bot
Home-page: https://github.com/davidchua/pymessenger
Author: David Chua
Author-email: [email protected]
License: UNKNOWN
Download-URL: https://github.com/davidchua/pymessenger/tarball/0.0.3
Download-URL: https://github.com/davidchua/pymessenger/tarball/0.0.6
Description: UNKNOWN
Keywords: facebook messenger,python,wrapper,bot,messenger bot
Platform: UNKNOWN
4 changes: 4 additions & 0 deletions pymessenger.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ setup.cfg
setup.py
pymessenger/__init__.py
pymessenger/bot.py
pymessenger/graph_api.py
pymessenger/receipt.py
pymessenger/user_profile.py
pymessenger/utils.py
pymessenger.egg-info/PKG-INFO
pymessenger.egg-info/SOURCES.txt
pymessenger.egg-info/dependency_links.txt
Expand Down
6 changes: 5 additions & 1 deletion pymessenger/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import json
import six

from .bot import Bot

class Element(dict):
__acceptable_keys = ['title', 'item_url', 'image_url', 'subtitle', 'buttons']
def __init__(self, *args, **kwargs):
kwargs = {k:v for k, v in kwargs.iteritems() if k in self.__acceptable_keys}
if six.PY2:
kwargs = {k:v for k, v in kwargs.iteritems() if k in self.__acceptable_keys}
else:
kwargs = {k:v for k, v in kwargs.items() if k in self.__acceptable_keys}
super(Element, self).__init__(*args, **kwargs)

def to_json(self):
Expand Down
6 changes: 5 additions & 1 deletion pymessenger/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import hashlib
import hmac
import six

def validate_hub_signature(app_secret, request_payload, hub_signature_header):
'''
Expand Down Expand Up @@ -31,6 +32,9 @@ def generate_appsecret_proof(access_token, app_secret):
appsecret_proof: HMAC-SHA256 hash of page access token
using app_secret as the key
'''
hmac_object = hmac.new(str(app_secret), unicode(access_token), hashlib.sha256)
if six.PY2:
hmac_object = hmac.new(str(app_secret), unicode(access_token), hashlib.sha256)
else:
hmac_object = hmac.new(bytearray(app_secret, 'utf8'), str(access_token).encode('utf8'), hashlib.sha256)
generated_hash = hmac_object.hexdigest()
return generated_hash
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pytest
requests
requests-toolbelt
six
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
setup(
name = 'pymessenger',
packages = ['pymessenger'],
version = '0.0.5.0',
version = '0.0.6.0',
install_requires=[
'requests',
'requests-toolbelt'
'requests-toolbelt',
'six'
],
description = "Python Wrapper for FB Messenger Bot",
author = 'David Chua',
author_email = '[email protected]',
url = 'https://github.com/davidchua/pymessenger',
download_url = 'https://github.com/davidchua/pymessenger/tarball/0.0.5',
download_url = 'https://github.com/davidchua/pymessenger/tarball/0.0.6',
keywords = ['facebook messenger', 'python', 'wrapper', 'bot', 'messenger bot'],
classifiers = [],
)

0 comments on commit ec72b22

Please sign in to comment.