Split long strings, use format when creating strings
This commit is contained in:
@@ -311,7 +311,7 @@ class Client(object):
|
|||||||
if self.uid is None:
|
if self.uid is None:
|
||||||
raise FBchatException("Could not find c_user cookie")
|
raise FBchatException("Could not find c_user cookie")
|
||||||
self.uid = str(self.uid)
|
self.uid = str(self.uid)
|
||||||
self.user_channel = "p_" + self.uid
|
self.user_channel = "p_{}".format(self.uid)
|
||||||
self.ttstamp = ""
|
self.ttstamp = ""
|
||||||
|
|
||||||
r = self._get(self.req_url.BASE)
|
r = self._get(self.req_url.BASE)
|
||||||
@@ -508,9 +508,8 @@ class Client(object):
|
|||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
raise FBchatUserError(
|
raise FBchatUserError(
|
||||||
"Login failed. Check email/password. (Failed on url: {})".format(
|
"Login failed. Check email/password. "
|
||||||
login_url
|
"(Failed on url: {})".format(login_url)
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def logout(self):
|
def logout(self):
|
||||||
@@ -659,8 +658,6 @@ class Client(object):
|
|||||||
and user_id not in users_to_fetch
|
and user_id not in users_to_fetch
|
||||||
):
|
):
|
||||||
users_to_fetch.append(user_id)
|
users_to_fetch.append(user_id)
|
||||||
else:
|
|
||||||
pass
|
|
||||||
for user_id, user in self.fetchUserInfo(*users_to_fetch).items():
|
for user_id, user in self.fetchUserInfo(*users_to_fetch).items():
|
||||||
users.append(user)
|
users.append(user)
|
||||||
return users
|
return users
|
||||||
@@ -772,9 +769,7 @@ class Client(object):
|
|||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
log.warning(
|
log.warning(
|
||||||
"Unknown __typename: {} in {}".format(
|
"Unknown type {} in {}".format(repr(node["__typename"]), node)
|
||||||
repr(node["__typename"]), node
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return rtn
|
return rtn
|
||||||
@@ -1092,7 +1087,9 @@ class Client(object):
|
|||||||
"""
|
"""
|
||||||
if offset is not None:
|
if offset is not None:
|
||||||
log.warning(
|
log.warning(
|
||||||
"Using `offset` in `fetchThreadList` is no longer supported, since Facebook migrated to the use of GraphQL in this request. Use `before` instead"
|
"Using `offset` in `fetchThreadList` is no longer supported, "
|
||||||
|
"since Facebook migrated to the use of GraphQL in this request. "
|
||||||
|
"Use `before` instead."
|
||||||
)
|
)
|
||||||
|
|
||||||
if limit > 20 or limit < 1:
|
if limit > 20 or limit < 1:
|
||||||
@@ -1184,8 +1181,7 @@ class Client(object):
|
|||||||
"""
|
"""
|
||||||
thread_id, thread_type = self._getThread(thread_id, None)
|
thread_id, thread_type = self._getThread(thread_id, None)
|
||||||
message_info = self._forcedFetch(thread_id, mid).get("message")
|
message_info = self._forcedFetch(thread_id, mid).get("message")
|
||||||
message = graphql_to_message(message_info)
|
return graphql_to_message(message_info)
|
||||||
return message
|
|
||||||
|
|
||||||
def fetchPollOptions(self, poll_id):
|
def fetchPollOptions(self, poll_id):
|
||||||
"""
|
"""
|
||||||
@@ -1212,8 +1208,7 @@ class Client(object):
|
|||||||
"""
|
"""
|
||||||
data = {"event_reminder_id": plan_id}
|
data = {"event_reminder_id": plan_id}
|
||||||
j = self._post(self.req_url.PLAN_INFO, data, fix_request=True, as_json=True)
|
j = self._post(self.req_url.PLAN_INFO, data, fix_request=True, as_json=True)
|
||||||
plan = graphql_to_plan(j["payload"])
|
return graphql_to_plan(j["payload"])
|
||||||
return plan
|
|
||||||
|
|
||||||
def _getPrivateData(self):
|
def _getPrivateData(self):
|
||||||
j = self.graphql_request(GraphQL(doc_id="1868889766468115"))
|
j = self.graphql_request(GraphQL(doc_id="1868889766468115"))
|
||||||
@@ -1272,7 +1267,7 @@ class Client(object):
|
|||||||
timestamp = now()
|
timestamp = now()
|
||||||
data = {
|
data = {
|
||||||
"client": self.client,
|
"client": self.client,
|
||||||
"author": "fbid:" + str(self.uid),
|
"author": "fbid:{}".format(self.uid),
|
||||||
"timestamp": timestamp,
|
"timestamp": timestamp,
|
||||||
"source": "source:chat:web",
|
"source": "source:chat:web",
|
||||||
"offline_threading_id": messageAndOTID,
|
"offline_threading_id": messageAndOTID,
|
||||||
@@ -1355,9 +1350,8 @@ class Client(object):
|
|||||||
return message_ids[0][0]
|
return message_ids[0][0]
|
||||||
except (KeyError, IndexError, TypeError) as e:
|
except (KeyError, IndexError, TypeError) as e:
|
||||||
raise FBchatException(
|
raise FBchatException(
|
||||||
"Error when sending message: No message IDs could be found: {}".format(
|
"Error when sending message: "
|
||||||
j
|
"No message IDs could be found: {}".format(j)
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def send(self, message, thread_id=None, thread_type=ThreadType.USER):
|
def send(self, message, thread_id=None, thread_type=ThreadType.USER):
|
||||||
@@ -1756,8 +1750,8 @@ class Client(object):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
data[
|
data[
|
||||||
"log_message_data[added_participants][" + str(i) + "]"
|
"log_message_data[added_participants][{}]".format(i)
|
||||||
] = "fbid:" + str(user_id)
|
] = "fbid:{}".format(user_id)
|
||||||
|
|
||||||
return self._doSendRequest(data)
|
return self._doSendRequest(data)
|
||||||
|
|
||||||
@@ -1782,7 +1776,7 @@ class Client(object):
|
|||||||
admin_ids = require_list(admin_ids)
|
admin_ids = require_list(admin_ids)
|
||||||
|
|
||||||
for i, admin_id in enumerate(admin_ids):
|
for i, admin_id in enumerate(admin_ids):
|
||||||
data["admin_ids[" + str(i) + "]"] = str(admin_id)
|
data["admin_ids[{}]".format(i)] = str(admin_id)
|
||||||
|
|
||||||
j = self._post(self.req_url.SAVE_ADMINS, data, fix_request=True, as_json=True)
|
j = self._post(self.req_url.SAVE_ADMINS, data, fix_request=True, as_json=True)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user