From 2857557deba6627cd06e1ef725798f1c2b629279 Mon Sep 17 00:00:00 2001 From: wannaphongcom Date: Fri, 16 Oct 2015 11:44:12 +0700 Subject: [PATCH 01/11] Update client.py --- fbchat/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fbchat/client.py b/fbchat/client.py index aa382de..d7b7005 100644 --- a/fbchat/client.py +++ b/fbchat/client.py @@ -65,7 +65,7 @@ class Client(object): self.threads = [] self.threads = [] - self.data = data + #self.data = data def _console(self, msg): if self.debug: print(msg) From e6cf2a709f816655f72231b2af25fe6775790fc8 Mon Sep 17 00:00:00 2001 From: wannaphongcom Date: Fri, 16 Oct 2015 11:50:45 +0700 Subject: [PATCH 02/11] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 86edeb7..a96e7ad 100644 --- a/setup.py +++ b/setup.py @@ -68,7 +68,7 @@ setup( packages=['fbchat'], install_requires=[ 'requests', - 'bs4' + 'beautifulsoup4' ], url=source, version=version, From c032969fb05a9fc56aea3daf78b7ba9daf587ea5 Mon Sep 17 00:00:00 2001 From: wannaphongcom Date: Fri, 16 Oct 2015 11:59:36 +0700 Subject: [PATCH 03/11] Update utils.py --- fbchat/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fbchat/utils.py b/fbchat/utils.py index 82ab364..8e10d31 100644 --- a/fbchat/utils.py +++ b/fbchat/utils.py @@ -1,7 +1,7 @@ import re import json from time import time - +from random import random, choice USER_AGENTS = [ "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/601.1.10 (KHTML, like Gecko) Version/8.0.5 Safari/601.1.10", From 2d445c6c922a0fb0964dbb2c84126be042f69b89 Mon Sep 17 00:00:00 2001 From: wannaphongcom Date: Fri, 16 Oct 2015 12:01:00 +0700 Subject: [PATCH 04/11] Update setup.py --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index a96e7ad..ec05f26 100644 --- a/setup.py +++ b/setup.py @@ -57,6 +57,7 @@ setup( 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy', 'Programming Language :: Python', From 80bc6b79536b67ab0f205ee75962cc9118ba0a72 Mon Sep 17 00:00:00 2001 From: wannaphongcom Date: Fri, 16 Oct 2015 12:01:26 +0700 Subject: [PATCH 05/11] Update __init__.py --- fbchat/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fbchat/__init__.py b/fbchat/__init__.py index 412d42e..5ce8559 100644 --- a/fbchat/__init__.py +++ b/fbchat/__init__.py @@ -15,7 +15,7 @@ from .client import * __copyright__ = 'Copyright 2015 by Taehoon Kim' -__version__ = '0.0.2' +__version__ = '0.0.3' __license__ = 'BSD' __author__ = 'Taehoon Kim' __email__ = 'carpedm20@gmail.com' From bf1cdec4d09ae0306879cd71ac0eaf84c2932516 Mon Sep 17 00:00:00 2001 From: wannaphongcom Date: Fri, 16 Oct 2015 12:05:56 +0700 Subject: [PATCH 06/11] Update client.py --- fbchat/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fbchat/client.py b/fbchat/client.py index d7b7005..e27706f 100644 --- a/fbchat/client.py +++ b/fbchat/client.py @@ -193,7 +193,7 @@ class Client(object): 'message_batch[0][has_attachment]' : False } - r = self._post("https://www.facebook.com/ajax/mercury/send_messages.php", form) + r = self._post("https://www.facebook.com/ajax/mercury/send_messages.php", data) return r.ok def getThreadList(self, start, end=None): From 53c7f71f158ea66c4851bd2b3029b80adacc5883 Mon Sep 17 00:00:00 2001 From: wannaphongcom Date: Fri, 16 Oct 2015 12:13:10 +0700 Subject: [PATCH 07/11] have bug AttributeError: 'str' object has no attribute 'decode' --- fbchat/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fbchat/utils.py b/fbchat/utils.py index 8e10d31..bd746fb 100644 --- a/fbchat/utils.py +++ b/fbchat/utils.py @@ -15,7 +15,7 @@ def now(): return int(time()*1000) def get_json(text): - return json.loads(re.sub(r"for.*(;;).*;", '', text.decode("unicode-escape").encode('utf-8'), 1)) + return json.loads(re.sub(r"for.*(;;).*;", '', text.decode("unicode-escape").encode('utf-8'), 1)) # have bug !!! AttributeError: 'str' object has no attribute 'decode' def digit_to_char(digit): if digit < 10: From 7259746b2be8a87db8bf8c080aa6e75e8a148d8e Mon Sep 17 00:00:00 2001 From: wannaphongcom Date: Fri, 16 Oct 2015 12:51:51 +0700 Subject: [PATCH 08/11] Update utils.py --- fbchat/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fbchat/utils.py b/fbchat/utils.py index bd746fb..65c0de1 100644 --- a/fbchat/utils.py +++ b/fbchat/utils.py @@ -15,7 +15,7 @@ def now(): return int(time()*1000) def get_json(text): - return json.loads(re.sub(r"for.*(;;).*;", '', text.decode("unicode-escape").encode('utf-8'), 1)) # have bug !!! AttributeError: 'str' object has no attribute 'decode' + return json.loads(re.sub(r"for.*(.*;.*;.*).*;", '', text.decode("unicode-escape").encode('utf-8'))) # have bug !!! AttributeError: 'str' object has no attribute 'decode' def digit_to_char(digit): if digit < 10: From 4d47431c9fd72cacd7bae1b118b5bc4f4fe5d8c4 Mon Sep 17 00:00:00 2001 From: wannaphongcom Date: Fri, 16 Oct 2015 12:54:18 +0700 Subject: [PATCH 09/11] Update utils.py --- fbchat/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fbchat/utils.py b/fbchat/utils.py index 65c0de1..561d8d1 100644 --- a/fbchat/utils.py +++ b/fbchat/utils.py @@ -15,7 +15,7 @@ def now(): return int(time()*1000) def get_json(text): - return json.loads(re.sub(r"for.*(.*;.*;.*).*;", '', text.decode("unicode-escape").encode('utf-8'))) # have bug !!! AttributeError: 'str' object has no attribute 'decode' + return json.loads(re.sub(r"for.*(;;).*;", '', text.decode("unicode-escape"), 1)) # have bug !!! AttributeError: 'str' object has no attribute 'decode' def digit_to_char(digit): if digit < 10: From ace4c19a9e97ff74a1ee1f221e417fa95601c2b1 Mon Sep 17 00:00:00 2001 From: wannaphongcom Date: Fri, 16 Oct 2015 13:10:03 +0700 Subject: [PATCH 10/11] fix bug --- fbchat/utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fbchat/utils.py b/fbchat/utils.py index 561d8d1..868a2bb 100644 --- a/fbchat/utils.py +++ b/fbchat/utils.py @@ -15,7 +15,7 @@ def now(): return int(time()*1000) def get_json(text): - return json.loads(re.sub(r"for.*(;;).*;", '', text.decode("unicode-escape"), 1)) # have bug !!! AttributeError: 'str' object has no attribute 'decode' + return json.loads(re.sub(r"for.*(.*;.*;.*).*;", '', text.encode('utf-8').decode("unicode-escape"), 1)) def digit_to_char(digit): if digit < 10: @@ -34,4 +34,3 @@ def generateMessageID(client_id=None): k = now() l = int(random() * 4294967295) return ("<%s:%s-%s@mail.projektitan.com>" % (k, l, client_id)); - From dfe2108792920874e7c0805792459f7f9b5a3673 Mon Sep 17 00:00:00 2001 From: wannaphongcom Date: Fri, 16 Oct 2015 13:10:35 +0700 Subject: [PATCH 11/11] Update client.py --- fbchat/client.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fbchat/client.py b/fbchat/client.py index e27706f..fbe8acb 100644 --- a/fbchat/client.py +++ b/fbchat/client.py @@ -65,7 +65,7 @@ class Client(object): self.threads = [] self.threads = [] - #self.data = data + def _console(self, msg): if self.debug: print(msg) @@ -150,12 +150,12 @@ class Client(object): r = self._get("https://www.facebook.com/ajax/typeahead/search.php", payload) self.j = j = get_json(r.text) self.r = r - + users = [] for entry in j['payload']['entries']: if entry['type'] == 'user': users.append(User(entry)) - return users + return users # have bug TypeError: __repr__ returned non-string (type bytes) def sendMessage(self, message, thread_id): timestamp = now()