Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
c8f8b818e0 | ||
|
08922ae284 | ||
|
51d606a54e | ||
|
2b76d71c67 | ||
|
67edd19eb8 | ||
|
eaaa526cfc | ||
|
843c0f6c37 | ||
|
44ebf38e47 | ||
|
d640e7d2ea | ||
|
66736519ed | ||
|
73f4c98be9 | ||
|
b2ff7fefaa | ||
|
c7cbbdd1c8 | ||
|
b599033c54 | ||
|
91778f43b7 | ||
|
e3602e83ce | ||
|
36742bf30b | ||
|
c842be3a52 | ||
|
a264fac2b4 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -8,9 +8,11 @@
|
||||
# Packages
|
||||
*.egg
|
||||
*.egg-info
|
||||
*.dist-info
|
||||
dist
|
||||
build
|
||||
eggs
|
||||
.eggs
|
||||
parts
|
||||
bin
|
||||
var
|
||||
|
23
.travis.yml
23
.travis.yml
@@ -5,16 +5,14 @@ python:
|
||||
- 3.4
|
||||
- 3.5
|
||||
- 3.6
|
||||
- pypy
|
||||
|
||||
env:
|
||||
global:
|
||||
# These two accounts are made specifically for this purpose, and the passwords are really only encrypted for obscurity
|
||||
# In reality, you could probably still login with the accounts by looking at log output from travis-ci.org
|
||||
- client1_email=travis.fbchat1@gmail.com # Facebook ID: 100023782141139
|
||||
- secure: "W1NON6qaLnvYIOVoC93MXkmbAIkUkHcGREBwN0BSVM3cLuMduk4VVkz6PY2T8bnntGYVwicXwcn5aNJ6pDue17TBZqGPk/tdpws8mnAZUtBYhpkIFTTlyh5kJSZejx9fd5s4nceGpH6ofCCnNxPp2PdHKU8piqnQYZVQ4cFNNDE=" # client1_password
|
||||
- client2_email=fbchat.travis2@gmail.com # Facebook ID: 100026538491708
|
||||
- secure: "V7RB3go2Tc/DdW1x9DkMI+vCfnOgiS3ygmFCABs/GjfPZjZL7VLMJgYGlx0cjeeeN+Oxa2GrhczRAKeMdGB6Ss2lGGAVs6cjJ56ODuBHWT6/FNzLjtDkTnjD+Kfh0l8ZOdxTF3MQ6M/9hU6z5ek+XYGr7u+/7wOYZ5L2cK5MaQ0=" # client2_password
|
||||
- group_id=1463789480385605
|
||||
# There are two accounts made specifically for Travis, and the passwords are really only encrypted for obscurity
|
||||
# The global env variables `client1_email`, `client1_password`, `client2_email`, `client2_password` and `group_id` are set on the Travis Settings page
|
||||
|
||||
install:
|
||||
- pip install -U -r requirements.txt
|
||||
- pip install -U -r dev-requirements.txt
|
||||
|
||||
before_script:
|
||||
- if [[ "$TRAVIS_PYTHON_VERSION" = "2.7" ]]; then export PYTEST_ADDOPTS='-m ""'; fi; # expensive tests (otherwise disabled in pytest.ini)
|
||||
@@ -22,14 +20,17 @@ before_script:
|
||||
|
||||
script: python -m pytest || python -m pytest --lf; # Run failed tests twice
|
||||
|
||||
cache: pip
|
||||
cache:
|
||||
pip: true
|
||||
directories:
|
||||
- .pytest_cache
|
||||
|
||||
deploy:
|
||||
provider: pypi
|
||||
user: madsmtm
|
||||
password:
|
||||
secure: "VA0MLSrwIW/T2KjMwjLZCzrLHw8pJT6tAvb48t7qpBdm8x192hax61pz1TaBZoJvlzyBPFKvluftuclTc7yEFwzXe7Gjqgd/ODKZl/wXDr36hQ7BBOLPZujdwmWLvTzMh3eJZlvkgcLCzrvK3j2oW8cM/+FZeVi/5/FhVuJ4ofs="
|
||||
distributions: sdist bdist_wheel
|
||||
on:
|
||||
python: 3.6
|
||||
branch: master
|
||||
tags: true
|
||||
|
@@ -1,4 +1,2 @@
|
||||
include LICENSE.txt
|
||||
include MANIFEST.in
|
||||
include README.rst
|
||||
include setup.py
|
||||
|
19
README.rst
19
README.rst
@@ -5,21 +5,25 @@ fbchat: Facebook Chat (Messenger) for Python
|
||||
:target: LICENSE.txt
|
||||
:alt: License: BSD
|
||||
|
||||
.. image:: https://img.shields.io/badge/python-2.7%2C%203.4%2C%203.5%2C%203.6-blue.svg
|
||||
.. image:: https://img.shields.io/badge/python-2.7%2C%203.4%2C%203.5%2C%203.6%20pypy-blue.svg
|
||||
:target: https://pypi.python.org/pypi/fbchat
|
||||
:alt: Supported python versions: 2.7, 3.4, 3.5 and 3.6
|
||||
:alt: Supported python versions: 2.7, 3.4, 3.5, 3.6 and pypy
|
||||
|
||||
.. image:: https://readthedocs.org/projects/fbchat/badge/?version=master
|
||||
:target: https://fbchat.readthedocs.io
|
||||
:alt: Documentation
|
||||
|
||||
.. image:: https://travis-ci.org/carpedm20/fbchat.svg?branch=master
|
||||
:target: https://travis-ci.org/carpedm20/fbchat
|
||||
:alt: Travis CI
|
||||
|
||||
Facebook Chat (`Messenger <https://www.facebook.com/messages/>`__) for Python.
|
||||
This project was inspired by `facebook-chat-api <https://github.com/Schmavery/facebook-chat-api>`__.
|
||||
|
||||
**No XMPP or API key is needed**. Just use your email and password.
|
||||
|
||||
Go to `Read the Docs <https://fbchat.readthedocs.io>`__ to see the full documentation,
|
||||
or jump right into the code by viewing the `examples <examples>`__
|
||||
or jump right into the code by viewing the `examples <https://github.com/carpedm20/fbchat/tree/master/examples>`__
|
||||
|
||||
Installation:
|
||||
|
||||
@@ -27,6 +31,15 @@ Installation:
|
||||
|
||||
$ pip install fbchat
|
||||
|
||||
You can also install from source, by using `setuptools` (You need at least version 30.3.0):
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ git clone https://github.com/carpedm20/fbchat.git
|
||||
$ cd fbchat
|
||||
$ python setup.py install
|
||||
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
|
2
dev-requirements.txt
Normal file
2
dev-requirements.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
pytest
|
||||
six
|
@@ -1,28 +1,28 @@
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from datetime import datetime
|
||||
from .client import *
|
||||
|
||||
|
||||
"""
|
||||
fbchat
|
||||
~~~~~~
|
||||
|
||||
Facebook Chat (Messenger) for Python
|
||||
|
||||
:copyright: (c) 2015 by Taehoon Kim.
|
||||
:copyright: (c) 2015 - 2018 by Taehoon Kim
|
||||
:license: BSD, see LICENSE for more details.
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
__copyright__ = 'Copyright 2015 - {} by Taehoon Kim'.format(datetime.now().year)
|
||||
__version__ = '1.3.8'
|
||||
from .client import *
|
||||
|
||||
__title__ = 'fbchat'
|
||||
__version__ = '1.3.9'
|
||||
__description__ = 'Facebook Chat (Messenger) for Python'
|
||||
|
||||
__copyright__ = 'Copyright 2015 - 2018 by Taehoon Kim'
|
||||
__license__ = 'BSD'
|
||||
|
||||
__author__ = 'Taehoon Kim; Moreels Pieter-Jan; Mads Marquart'
|
||||
__email__ = 'carpedm20@gmail.com'
|
||||
__source__ = 'https://github.com/carpedm20/fbchat/'
|
||||
__description__ = 'Facebook Chat (Messenger) for Python'
|
||||
|
||||
__all__ = [
|
||||
'Client',
|
||||
|
@@ -11,7 +11,10 @@ from .utils import *
|
||||
from .models import *
|
||||
from .graphql import *
|
||||
import time
|
||||
|
||||
try:
|
||||
from urllib.parse import urlparse, parse_qs
|
||||
except ImportError:
|
||||
from urlparse import urlparse, parse_qs
|
||||
|
||||
|
||||
class Client(object):
|
||||
@@ -209,7 +212,7 @@ class Client(object):
|
||||
self.ttstamp = ''
|
||||
|
||||
r = self._get(self.req_url.BASE)
|
||||
soup = bs(r.text, "lxml")
|
||||
soup = bs(r.text, "html.parser")
|
||||
|
||||
fb_dtsg_element = soup.find("input", {'name': 'fb_dtsg'})
|
||||
if fb_dtsg_element:
|
||||
@@ -252,7 +255,7 @@ class Client(object):
|
||||
if not (self.email and self.password):
|
||||
raise FBchatUserError("Email and password not found.")
|
||||
|
||||
soup = bs(self._get(self.req_url.MOBILE).text, "lxml")
|
||||
soup = bs(self._get(self.req_url.MOBILE).text, "html.parser")
|
||||
data = dict((elem['name'], elem['value']) for elem in soup.findAll("input") if elem.has_attr('value') and elem.has_attr('name'))
|
||||
data['email'] = self.email
|
||||
data['pass'] = self.password
|
||||
@@ -277,7 +280,7 @@ class Client(object):
|
||||
return False, r.url
|
||||
|
||||
def _2FA(self, r):
|
||||
soup = bs(r.text, "lxml")
|
||||
soup = bs(r.text, "html.parser")
|
||||
data = dict()
|
||||
|
||||
s = self.on2FACode()
|
||||
@@ -1313,6 +1316,25 @@ class Client(object):
|
||||
r = self._post(self.req_url.CONNECT, data)
|
||||
return r.ok
|
||||
|
||||
def removeFriend(self, friend_id=None):
|
||||
"""Removes a specifed friend from your friend list
|
||||
|
||||
:param friend_id: The id of the friend that you want to remove
|
||||
:return: Returns error if the removing was unsuccessful, returns True when successful.
|
||||
"""
|
||||
payload = {
|
||||
"friend_id": friend_id,
|
||||
"unref": "none",
|
||||
"confirm": "Confirm",
|
||||
}
|
||||
r = self._post(self.req_url.REMOVE_FRIEND, payload)
|
||||
query = parse_qs(urlparse(r.url).query)
|
||||
if "err" not in query:
|
||||
log.debug("Remove was successful!")
|
||||
return True
|
||||
else:
|
||||
log.warning("Error while removing friend")
|
||||
return False
|
||||
|
||||
"""
|
||||
LISTEN METHODS
|
||||
|
@@ -122,6 +122,7 @@ class ReqUrl(object):
|
||||
ATTACHMENT_PHOTO = "https://www.facebook.com/mercury/attachments/photo/"
|
||||
EVENT_REMINDER = "https://www.facebook.com/ajax/eventreminder/create"
|
||||
MODERN_SETTINGS_MENU = "https://www.facebook.com/bluebar/modern_settings_menu/"
|
||||
REMOVE_FRIEND = "https://m.facebook.com/a/removefriend.php"
|
||||
|
||||
pull_channel = 0
|
||||
|
||||
|
@@ -1,5 +1,3 @@
|
||||
requests
|
||||
lxml
|
||||
beautifulsoup4
|
||||
enum34; python_version < '3.4'
|
||||
six
|
||||
|
51
setup.cfg
Normal file
51
setup.cfg
Normal file
@@ -0,0 +1,51 @@
|
||||
[metadata]
|
||||
name = fbchat
|
||||
version = attr: fbchat.__version__
|
||||
license = BSD
|
||||
license_file = LICENSE.txt
|
||||
|
||||
author = Taehoon Kim
|
||||
author_email = carpedm20@gmail.com
|
||||
maintainer = Mads Marquart
|
||||
maintainer_email = madsmtm@gmail.com
|
||||
|
||||
description = Facebook Chat (Messenger) for Python
|
||||
long_description = file: README.rst
|
||||
long_description_content_type = text/x-rst
|
||||
|
||||
keywords = Facebook FB Messenger Chat Api Bot
|
||||
classifiers =
|
||||
Development Status :: 3 - Alpha
|
||||
Intended Audience :: Developers
|
||||
Intended Audience :: Information Technology
|
||||
License :: OSI Approved :: BSD License
|
||||
Operating System :: OS Independent
|
||||
Natural Language :: English
|
||||
Programming Language :: Python
|
||||
Programming Language :: Python :: 2.7
|
||||
Programming Language :: Python :: 3.4
|
||||
Programming Language :: Python :: 3.5
|
||||
Programming Language :: Python :: 3.6
|
||||
Programming Language :: Python :: Implementation :: CPython
|
||||
Programming Language :: Python :: Implementation :: PyPy
|
||||
Topic :: Communications :: Chat
|
||||
Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
||||
Topic :: Software Development :: Libraries :: Python Modules
|
||||
|
||||
url = https://github.com/carpedm20/fbchat/
|
||||
project_urls =
|
||||
Documentation = https://fbchat.readthedocs.io/
|
||||
Repository = https://github.com/carpedm20/fbchat/
|
||||
|
||||
[options]
|
||||
zip_safe = True
|
||||
include_package_data = True
|
||||
packages = find:
|
||||
python_requires = >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4.0
|
||||
install_requires =
|
||||
requests
|
||||
beautifulsoup4
|
||||
# May not work in pip with bdist_wheel
|
||||
# See https://wheel.readthedocs.io/en/latest/#defining-conditional-dependencies
|
||||
# It is therefore defined in setup.py
|
||||
# enum34; python_version < '3.4'
|
80
setup.py
Normal file → Executable file
80
setup.py
Normal file → Executable file
@@ -1,82 +1,8 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
"""
|
||||
Setup script for fbchat
|
||||
"""
|
||||
import os
|
||||
try:
|
||||
from setuptools import setup
|
||||
except ImportError:
|
||||
from distutils.core import setup
|
||||
|
||||
with open('README.rst') as f:
|
||||
readme_content = f.read().strip()
|
||||
|
||||
requirements = [
|
||||
'requests',
|
||||
'lxml',
|
||||
'beautifulsoup4'
|
||||
]
|
||||
|
||||
extras_requirements = {
|
||||
':python_version < "3.4"': ['enum34']
|
||||
}
|
||||
|
||||
version = None
|
||||
author = None
|
||||
email = None
|
||||
source = None
|
||||
description = None
|
||||
with open(os.path.join('fbchat', '__init__.py')) as f:
|
||||
for line in f:
|
||||
if line.strip().startswith('__version__'):
|
||||
version = line.split('=')[1].strip().replace('"', '').replace("'", '')
|
||||
elif line.strip().startswith('__author__'):
|
||||
author = line.split('=')[1].strip().replace('"', '').replace("'", '')
|
||||
elif line.strip().startswith('__email__'):
|
||||
email = line.split('=')[1].strip().replace('"', '').replace("'", '')
|
||||
elif line.strip().startswith('__source__'):
|
||||
source = line.split('=')[1].strip().replace('"', '').replace("'", '')
|
||||
elif line.strip().startswith('__description__'):
|
||||
description = line.split('=')[1].strip().replace('"', '').replace("'", '')
|
||||
elif None not in (version, author, email, source, description):
|
||||
break
|
||||
|
||||
setup(
|
||||
name='fbchat',
|
||||
author=author,
|
||||
author_email=email,
|
||||
license='BSD License',
|
||||
keywords=["facebook chat fbchat"],
|
||||
description=description,
|
||||
long_description=readme_content,
|
||||
classifiers=[
|
||||
'Development Status :: 2 - Pre-Alpha',
|
||||
'Intended Audience :: Developers',
|
||||
'Intended Audience :: Information Technology',
|
||||
'License :: OSI Approved :: BSD License',
|
||||
'Operating System :: OS Independent',
|
||||
'Programming Language :: Python :: 2.6',
|
||||
'Programming Language :: Python :: 2.7',
|
||||
'Programming Language :: Python :: 2.7',
|
||||
'Programming Language :: Python :: 3.2',
|
||||
'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',
|
||||
'Topic :: Software Development :: Libraries :: Python Modules',
|
||||
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
|
||||
'Topic :: Communications :: Chat',
|
||||
],
|
||||
include_package_data=True,
|
||||
packages=['fbchat'],
|
||||
install_requires=requirements,
|
||||
extras_require=extras_requirements,
|
||||
url=source,
|
||||
version=version,
|
||||
zip_safe=True,
|
||||
)
|
||||
setup(extras_require={':python_version < "3.4"': ['enum34']})
|
||||
|
Reference in New Issue
Block a user