Remove unused features
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
34
.github/ISSUE_TEMPLATE/bug_report.md
vendored
34
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -1,34 +0,0 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report if you're having trouble with `fbchat`
|
||||
|
||||
---
|
||||
|
||||
## Description of the problem
|
||||
Example: Logging in fails when the character `%` is in the password. A specific password that fails is `a_password_with_%`
|
||||
|
||||
## Code to reproduce
|
||||
```py
|
||||
# Example code
|
||||
from fbchat import Client
|
||||
client = Client("[REDACTED_USERNAME]", "a_password_with_%")
|
||||
```
|
||||
|
||||
## Traceback
|
||||
```
|
||||
Traceback (most recent call last):
|
||||
File "<test.py>", line 1, in <module>
|
||||
File "[site-packages]/fbchat/client.py", line 78, in __init__
|
||||
self.login(email, password, max_tries)
|
||||
File "[site-packages]/fbchat/client.py", line 407, in login
|
||||
raise FBchatException('Login failed. Check email/password. (Failed on URL: {})'.format(login_url))
|
||||
fbchat.FBchatException: Login failed. Check email/password. (Failed on URL: https://m.facebook.com/login.php?login_attempt=1)
|
||||
```
|
||||
|
||||
## Environment information
|
||||
- Python version
|
||||
- `fbchat` version
|
||||
- If relevant, output from `$ python -m pip list`
|
||||
|
||||
If you have done any research, include that.
|
||||
Make sure to redact all personal information.
|
19
.github/ISSUE_TEMPLATE/feature_request.md
vendored
19
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@@ -1,19 +0,0 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest a feature that you'd like to see implemented
|
||||
|
||||
---
|
||||
|
||||
## Description
|
||||
Example: There's no way to send messages to groups
|
||||
|
||||
## Research (if applicable)
|
||||
Example: I've found the URL `https://facebook.com/send_message.php`, to which you can send a POST requests with the following JSON:
|
||||
```json
|
||||
{
|
||||
"text": message_content,
|
||||
"fbid": group_id,
|
||||
"some_variable": ?
|
||||
}
|
||||
```
|
||||
But I don't know how what `some_variable` does, and it doesn't work without it. I've found some examples of `some_variable` to be: `MTIzNDU2Nzg5MA`, `MTIzNDU2Nzg5MQ` and `MTIzNDU2Nzg5Mg`
|
@@ -1,20 +0,0 @@
|
||||
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
|
||||
version: 2
|
||||
|
||||
formats:
|
||||
- pdf
|
||||
- htmlzip
|
||||
|
||||
python:
|
||||
version: 3.6
|
||||
install:
|
||||
- path: .
|
||||
extra_requirements:
|
||||
- docs
|
||||
|
||||
# Build documentation in the docs/ directory with Sphinx
|
||||
sphinx:
|
||||
configuration: docs/conf.py
|
||||
# Disabled, until we can find a way to get sphinx-autodoc-typehints play nice with our
|
||||
# module renaming!
|
||||
fail_on_warning: false
|
53
.travis.yml
53
.travis.yml
@@ -1,53 +0,0 @@
|
||||
sudo: false
|
||||
language: python
|
||||
python: 3.6
|
||||
|
||||
cache: pip
|
||||
|
||||
before_install: pip install flit
|
||||
# Use `--deps production` so that we don't install unnecessary dependencies
|
||||
install: flit install --deps production --extras test
|
||||
script: pytest
|
||||
|
||||
jobs:
|
||||
include:
|
||||
- python: 3.5
|
||||
- python: 3.6
|
||||
- python: 3.7
|
||||
- python: pypy3.5
|
||||
|
||||
- name: Lint
|
||||
before_install: skip
|
||||
install: pip install black
|
||||
script: black --check --verbose .
|
||||
|
||||
- stage: deploy
|
||||
name: GitHub Releases
|
||||
if: tag IS present
|
||||
install: skip
|
||||
script: flit build
|
||||
deploy:
|
||||
provider: releases
|
||||
api_key: $GITHUB_OAUTH_TOKEN
|
||||
file_glob: true
|
||||
file: dist/*
|
||||
skip_cleanup: true
|
||||
draft: false
|
||||
on:
|
||||
tags: true
|
||||
|
||||
- stage: deploy
|
||||
name: PyPI
|
||||
if: tag IS present
|
||||
install: skip
|
||||
script: skip
|
||||
deploy:
|
||||
provider: script
|
||||
script: flit publish
|
||||
on:
|
||||
tags: true
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_success: never
|
||||
on_failure: change
|
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"esbonio.sphinx.confDir": ""
|
||||
}
|
78
README.rst
78
README.rst
@@ -1,48 +1,6 @@
|
||||
This project is unmaintained
|
||||
============================
|
||||
|
||||
This project is officially marked as unmaintained, since my life is somewhere where I just do not have the time and energy to lead this project.
|
||||
|
||||
If there is someone out there willing to take the lead, please get in contact, but even if there is, I can't get in contact with the original author `@carpedm20 <https://github.com/carpedm20>`__ and get the ability to add others as maintainers, see `issue 390 <https://github.com/carpedm20/fbchat/issues/390>`__. So a fork might be preferable.
|
||||
|
||||
I have opened for further discussion `in issue 613 <https://github.com/carpedm20/fbchat/issues/613>`__.
|
||||
|
||||
Thanks for serving you all these years.
|
||||
|
||||
\- Mads Marquart / `@madsmtm <https://github.com/madsmtm>`__.
|
||||
|
||||
|
||||
Original project description below
|
||||
----------------------------------
|
||||
|
||||
|
||||
``fbchat`` - Facebook Messenger for Python
|
||||
==========================================
|
||||
|
||||
.. image:: https://badgen.net/pypi/v/fbchat
|
||||
:target: https://pypi.python.org/pypi/fbchat
|
||||
:alt: Project version
|
||||
|
||||
.. image:: https://badgen.net/badge/python/3.5,3.6,3.7,3.8,pypy?list=|
|
||||
:target: https://pypi.python.org/pypi/fbchat
|
||||
:alt: Supported python versions: 3.5, 3.6, 3.7, 3.8 and pypy
|
||||
|
||||
.. image:: https://badgen.net/pypi/license/fbchat
|
||||
:target: https://github.com/carpedm20/fbchat/tree/master/LICENSE
|
||||
:alt: License: BSD 3-Clause
|
||||
|
||||
.. image:: https://readthedocs.org/projects/fbchat/badge/?version=stable
|
||||
:target: https://fbchat.readthedocs.io
|
||||
:alt: Documentation
|
||||
|
||||
.. image:: https://badgen.net/travis/carpedm20/fbchat
|
||||
:target: https://travis-ci.org/carpedm20/fbchat
|
||||
:alt: Travis CI
|
||||
|
||||
.. image:: https://badgen.net/badge/code%20style/black/black
|
||||
:target: https://github.com/ambv/black
|
||||
:alt: Code style
|
||||
|
||||
A powerful and efficient library to interact with
|
||||
`Facebook's Messenger <https://www.facebook.com/messages/>`__, using just your email and password.
|
||||
|
||||
@@ -56,16 +14,13 @@ This is *not* an official API, Facebook has that `over here <https://developers.
|
||||
- Creating groups, setting the group emoji, changing nicknames, creating polls, etc.
|
||||
- Listening for, an reacting to messages and other events in real-time.
|
||||
- Type hints, and it has a modern codebase (e.g. only Python 3.5 and upwards).
|
||||
- ``async``/``await`` (COMING).
|
||||
|
||||
Essentially, everything you need to make an amazing Facebook bot!
|
||||
|
||||
|
||||
Version Warning
|
||||
---------------
|
||||
``v2`` is currently being developed at the ``master`` branch and it's highly unstable. If you want to view the old ``v1``, go `here <https://github.com/carpedm20/fbchat/tree/v1>`__.
|
||||
|
||||
Additionally, you can view the project's progress `here <https://github.com/carpedm20/fbchat/projects/2>`__.
|
||||
``v2`` is currently being developed at the ``master`` branch and it's highly unstable.
|
||||
|
||||
|
||||
Caveats
|
||||
@@ -76,14 +31,6 @@ Caveats
|
||||
However, there's a catch! **Using this library may not comply with Facebook's Terms Of Service!**, so be responsible Facebook citizens! We are not responsible if your account gets banned!
|
||||
|
||||
Additionally, **the APIs the library is calling is undocumented!** In theory, this means that your code could break tomorrow, without the slightest warning!
|
||||
If this happens to you, please report it, so that we can fix it as soon as possible!
|
||||
|
||||
.. inclusion-marker-intro-end
|
||||
.. This message doesn't make sense in the docs at Read The Docs, so we exclude it
|
||||
|
||||
With that out of the way, you may go to `Read The Docs <https://fbchat.readthedocs.io/>`__ to see the full documentation!
|
||||
|
||||
.. inclusion-marker-installation-start
|
||||
|
||||
|
||||
Installation
|
||||
@@ -91,17 +38,7 @@ Installation
|
||||
|
||||
.. code-block::
|
||||
|
||||
$ pip install fbchat
|
||||
|
||||
If you don't have `pip <https://pip.pypa.io/>`_, `this guide <http://docs.python-guide.org/en/latest/starting/installation/>`_ can guide you through the process.
|
||||
|
||||
You can also install directly from source, provided you have ``pip>=19.0``:
|
||||
|
||||
.. code-block::
|
||||
|
||||
$ pip install git+https://github.com/carpedm20/fbchat.git
|
||||
|
||||
.. inclusion-marker-installation-end
|
||||
$ pip install git+https://git.karaolidis.com/Nikas36/fbchat.git
|
||||
|
||||
|
||||
Example Usage
|
||||
@@ -112,18 +49,11 @@ Example Usage
|
||||
import getpass
|
||||
import fbchat
|
||||
session = fbchat.Session.login("<email/phone number>", getpass.getpass())
|
||||
user = fbchat.User(session=session, id=session.user_id)
|
||||
user = fbchat.User(session=session, id=session._user_id)
|
||||
user.send_text("Test message!")
|
||||
|
||||
More examples are available `here <https://github.com/carpedm20/fbchat/tree/master/examples>`__.
|
||||
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
No one, see notice at the top.
|
||||
|
||||
Acknowledgements
|
||||
----------------
|
||||
|
||||
This project was originally inspired by `facebook-chat-api <https://github.com/Schmavery/facebook-chat-api>`__.
|
||||
This project is a fork of `fbchat <https://github.com/fbchat-dev/fbchat>`__ and was originally inspired by `facebook-chat-api <https://github.com/Schmavery/facebook-chat-api>`__.
|
||||
|
@@ -1,19 +0,0 @@
|
||||
# Minimal makefile for Sphinx documentation
|
||||
#
|
||||
|
||||
# You can set these variables from the command line.
|
||||
SPHINXOPTS =
|
||||
SPHINXBUILD = sphinx-build
|
||||
SOURCEDIR = .
|
||||
BUILDDIR = _build
|
||||
|
||||
# Put it first so that "make" without argument is like "make help".
|
||||
help:
|
||||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
|
||||
.PHONY: help Makefile
|
||||
|
||||
# Catch-all target: route all unknown targets to Sphinx using the new
|
||||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
||||
%: Makefile
|
||||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
BIN
docs/_static/find-group-id.png
vendored
BIN
docs/_static/find-group-id.png
vendored
Binary file not shown.
Before Width: | Height: | Size: 59 KiB |
26
docs/_templates/layout.html
vendored
26
docs/_templates/layout.html
vendored
@@ -1,26 +0,0 @@
|
||||
{% extends '!layout.html' %}
|
||||
|
||||
{% block extrahead %}
|
||||
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
||||
<!-- Alabaster (krTheme++) Hacks, modified version of Kenneth Reitz' https://github.com/kennethreitz/requests/blob/master/docs/_templates/hacks.html -->
|
||||
<style type="text/css">
|
||||
/* Rezzy requires precise alignment. */
|
||||
img.logo {margin-left: -20px!important;}
|
||||
/* "Quick Search" should be capitalized. */
|
||||
div#searchbox h3 {text-transform: capitalize;}
|
||||
/* Go button should be behind input field */
|
||||
div.sphinxsidebar div#searchbox input[type="text"] {width: 160px}
|
||||
div#searchbox form div {display: inline-block;}
|
||||
/* Make the document a little wider, less code is cut-off. */
|
||||
div.document {width: 1008px;}
|
||||
/* Much-improved spacing around code blocks. */
|
||||
div.highlight pre {padding: 11px 14px;}
|
||||
/* Remain Responsive! */
|
||||
@media screen and (max-width: 1008px) {
|
||||
div.sphinxsidebar {display: none;}
|
||||
div.document {width: 100%!important;}
|
||||
/* Have code blocks escape the document right-margin. */
|
||||
div.highlight pre {margin-right: -30px;}
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
13
docs/_templates/sidebar.html
vendored
13
docs/_templates/sidebar.html
vendored
@@ -1,13 +0,0 @@
|
||||
<h3>
|
||||
<a href="{{ pathto(master_doc) }}">{{ _(project) }}</a>
|
||||
</h3>
|
||||
|
||||
<p>
|
||||
<a class="github-button" href="https://github.com/carpedm20/fbchat" data-size="large" data-show-count="true" aria-label="Star carpedm20/fbchat on GitHub">Star</a>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
{{ _(shorttitle) }}
|
||||
</p>
|
||||
|
||||
{{ toctree() }}
|
@@ -1,13 +0,0 @@
|
||||
Attachments
|
||||
===========
|
||||
|
||||
.. autoclass:: Attachment()
|
||||
.. autoclass:: ShareAttachment()
|
||||
.. autoclass:: Sticker()
|
||||
.. autoclass:: LocationAttachment()
|
||||
.. autoclass:: LiveLocationAttachment()
|
||||
.. autoclass:: FileAttachment()
|
||||
.. autoclass:: AudioAttachment()
|
||||
.. autoclass:: ImageAttachment()
|
||||
.. autoclass:: VideoAttachment()
|
||||
.. autoclass:: ImageAttachment()
|
@@ -1,4 +0,0 @@
|
||||
Client
|
||||
======
|
||||
|
||||
.. autoclass:: Client
|
@@ -1,4 +0,0 @@
|
||||
Events
|
||||
======
|
||||
|
||||
.. autoclass:: Listener
|
@@ -1,11 +0,0 @@
|
||||
Exceptions
|
||||
==========
|
||||
|
||||
.. autoexception:: FacebookError()
|
||||
.. autoexception:: HTTPError()
|
||||
.. autoexception:: ParseError()
|
||||
.. autoexception:: NotLoggedIn()
|
||||
.. autoexception:: ExternalError()
|
||||
.. autoexception:: GraphQLError()
|
||||
.. autoexception:: InvalidParameters()
|
||||
.. autoexception:: PleaseRefresh()
|
@@ -1,21 +0,0 @@
|
||||
.. module:: fbchat
|
||||
|
||||
.. Note: we're using () to hide the __init__ method where relevant
|
||||
|
||||
Full API
|
||||
========
|
||||
|
||||
If you are looking for information on a specific function, class, or method, this part of the documentation is for you.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
session
|
||||
client
|
||||
threads
|
||||
thread_data
|
||||
messages
|
||||
exceptions
|
||||
attachments
|
||||
events
|
||||
misc
|
@@ -1,8 +0,0 @@
|
||||
Messages
|
||||
========
|
||||
|
||||
.. autoclass:: Message
|
||||
.. autoclass:: Mention
|
||||
.. autoclass:: EmojiSize(Enum)
|
||||
:undoc-members:
|
||||
.. autoclass:: MessageData()
|
@@ -1,20 +0,0 @@
|
||||
Miscellaneous
|
||||
=============
|
||||
|
||||
.. autoclass:: ThreadLocation(Enum)
|
||||
:undoc-members:
|
||||
.. autoclass:: ActiveStatus()
|
||||
|
||||
.. autoclass:: QuickReply
|
||||
.. autoclass:: QuickReplyText
|
||||
.. autoclass:: QuickReplyLocation
|
||||
.. autoclass:: QuickReplyPhoneNumber
|
||||
.. autoclass:: QuickReplyEmail
|
||||
|
||||
.. autoclass:: Poll
|
||||
.. autoclass:: PollOption
|
||||
|
||||
.. autoclass:: Plan
|
||||
.. autoclass:: PlanData()
|
||||
.. autoclass:: GuestStatus(Enum)
|
||||
:undoc-members:
|
@@ -1,4 +0,0 @@
|
||||
Session
|
||||
=======
|
||||
|
||||
.. autoclass:: Session()
|
@@ -1,6 +0,0 @@
|
||||
Thread Data
|
||||
===========
|
||||
|
||||
.. autoclass:: PageData()
|
||||
.. autoclass:: UserData()
|
||||
.. autoclass:: GroupData()
|
@@ -1,8 +0,0 @@
|
||||
Threads
|
||||
=======
|
||||
|
||||
.. autoclass:: ThreadABC()
|
||||
.. autoclass:: Thread
|
||||
.. autoclass:: Page
|
||||
.. autoclass:: User
|
||||
.. autoclass:: Group
|
194
docs/conf.py
194
docs/conf.py
@@ -1,194 +0,0 @@
|
||||
# Configuration file for the Sphinx documentation builder.
|
||||
#
|
||||
# This file does only contain a selection of the most common options. For a
|
||||
# full list see the documentation:
|
||||
# http://www.sphinx-doc.org/en/master/config
|
||||
|
||||
# -- Path setup --------------------------------------------------------------
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, os.path.abspath(".."))
|
||||
|
||||
os.environ["_FBCHAT_DISABLE_FIX_MODULE_METADATA"] = "1"
|
||||
|
||||
import fbchat
|
||||
|
||||
del os.environ["_FBCHAT_DISABLE_FIX_MODULE_METADATA"]
|
||||
|
||||
# -- Project information -----------------------------------------------------
|
||||
|
||||
project = fbchat.__name__
|
||||
copyright = "Copyright 2015 - 2018 by Taehoon Kim and 2018 - 2020 by Mads Marquart"
|
||||
author = "Taehoon Kim; Moreels Pieter-Jan; Mads Marquart"
|
||||
description = fbchat.__doc__.split("\n")[0]
|
||||
|
||||
# The short X.Y version
|
||||
version = fbchat.__version__
|
||||
# The full version, including alpha/beta/rc tags
|
||||
release = fbchat.__version__
|
||||
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
#
|
||||
needs_sphinx = "2.0"
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = [
|
||||
"sphinx.ext.autodoc",
|
||||
"sphinx.ext.intersphinx",
|
||||
"sphinx.ext.viewcode",
|
||||
"sphinx.ext.napoleon",
|
||||
"sphinxcontrib.spelling",
|
||||
"sphinx_autodoc_typehints",
|
||||
]
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ["_templates"]
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = "index"
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
# This pattern also affects html_static_path and html_extra_path.
|
||||
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
|
||||
|
||||
rst_prolog = ".. currentmodule:: " + project
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all
|
||||
# documents.
|
||||
#
|
||||
default_role = "any"
|
||||
|
||||
# Make the reference parsing more strict
|
||||
#
|
||||
nitpicky = True
|
||||
|
||||
# Prefer strict Python highlighting
|
||||
#
|
||||
highlight_language = "python3"
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
#
|
||||
add_function_parentheses = False
|
||||
|
||||
|
||||
# -- Options for HTML output -------------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
#
|
||||
html_theme = "alabaster"
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#
|
||||
html_theme_options = {
|
||||
"show_powered_by": False,
|
||||
"github_user": "carpedm20",
|
||||
"github_repo": project,
|
||||
"github_banner": True,
|
||||
"show_related": False,
|
||||
}
|
||||
|
||||
# Custom sidebar templates, must be a dictionary that maps document names
|
||||
# to template names.
|
||||
#
|
||||
# The default sidebars (for documents that don't match any pattern) are
|
||||
# defined by theme itself. Builtin themes are using these templates by
|
||||
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
|
||||
# 'searchbox.html']``.
|
||||
#
|
||||
html_sidebars = {"**": ["sidebar.html", "searchbox.html"]}
|
||||
|
||||
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
||||
#
|
||||
html_show_sphinx = False
|
||||
|
||||
# If true, links to the reST sources are added to the pages.
|
||||
#
|
||||
html_show_sourcelink = False
|
||||
|
||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||
#
|
||||
html_short_title = description
|
||||
|
||||
|
||||
# -- Options for HTMLHelp output ---------------------------------------------
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = project + "doc"
|
||||
|
||||
|
||||
# -- Options for LaTeX output ------------------------------------------------
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title,
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [(master_doc, project + ".tex", project, author, "manual")]
|
||||
|
||||
|
||||
# -- Options for manual page output ------------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [(master_doc, project, project, [x.strip() for x in author.split(";")], 1)]
|
||||
|
||||
|
||||
# -- Options for Texinfo output ----------------------------------------------
|
||||
|
||||
# Grouping the document tree into Texinfo files. List of tuples
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
(master_doc, project, project, author, project, description, "Miscellaneous",)
|
||||
]
|
||||
|
||||
|
||||
# -- Options for Epub output -------------------------------------------------
|
||||
|
||||
# A list of files that should not be packed into the epub file.
|
||||
epub_exclude_files = ["search.html"]
|
||||
|
||||
|
||||
# -- Extension configuration -------------------------------------------------
|
||||
|
||||
# -- Options for autodoc extension ---------------------------------------
|
||||
|
||||
autoclass_content = "class"
|
||||
autodoc_member_order = "bysource"
|
||||
autodoc_default_options = {"members": True}
|
||||
|
||||
# -- Options for intersphinx extension ---------------------------------------
|
||||
|
||||
# Example configuration for intersphinx: refer to the Python standard library.
|
||||
intersphinx_mapping = {"https://docs.python.org/": None}
|
||||
|
||||
# -- Options for napoleon extension ----------------------------------------------
|
||||
|
||||
# Use Google style docstrings
|
||||
napoleon_google_docstring = True
|
||||
napoleon_numpy_docstring = False
|
||||
|
||||
# napoleon_use_admonition_for_examples = False
|
||||
# napoleon_use_admonition_for_notes = False
|
||||
# napoleon_use_admonition_for_references = False
|
||||
|
||||
# -- Options for spelling extension ----------------------------------------------
|
||||
|
||||
spelling_word_list_filename = [
|
||||
"spelling/names.txt",
|
||||
"spelling/technical.txt",
|
||||
"spelling/fixes.txt",
|
||||
]
|
||||
spelling_ignore_wiki_words = False
|
||||
# spelling_ignore_acronyms = False
|
||||
spelling_ignore_python_builtins = False
|
||||
spelling_ignore_importable_modules = False
|
@@ -1,55 +0,0 @@
|
||||
.. _examples:
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
These are a few examples on how to use ``fbchat``. Remember to swap out ``<email>`` and ``<password>`` for your email and password
|
||||
|
||||
|
||||
Basic example
|
||||
-------------
|
||||
|
||||
This will show basic usage of ``fbchat``
|
||||
|
||||
.. literalinclude:: ../examples/basic_usage.py
|
||||
|
||||
|
||||
Interacting with Threads
|
||||
------------------------
|
||||
|
||||
This will interact with the thread in every way ``fbchat`` supports
|
||||
|
||||
.. literalinclude:: ../examples/interract.py
|
||||
|
||||
|
||||
Fetching Information
|
||||
--------------------
|
||||
|
||||
This will show the different ways of fetching information about users and threads
|
||||
|
||||
.. literalinclude:: ../examples/fetch.py
|
||||
|
||||
|
||||
``Echobot``
|
||||
-----------
|
||||
|
||||
This will reply to any message with the same message
|
||||
|
||||
.. literalinclude:: ../examples/echobot.py
|
||||
|
||||
|
||||
Remove Bot
|
||||
----------
|
||||
|
||||
This will remove a user from a group if they write the message ``Remove me!``
|
||||
|
||||
.. literalinclude:: ../examples/removebot.py
|
||||
|
||||
|
||||
"Prevent changes"-Bot
|
||||
---------------------
|
||||
|
||||
This will prevent chat color, emoji, nicknames and chat name from being changed.
|
||||
It will also prevent people from being added and removed
|
||||
|
||||
.. literalinclude:: ../examples/keepbot.py
|
23
docs/faq.rst
23
docs/faq.rst
@@ -1,23 +0,0 @@
|
||||
Frequently Asked Questions
|
||||
==========================
|
||||
|
||||
The new version broke my application
|
||||
------------------------------------
|
||||
|
||||
``fbchat`` follows `Scemantic Versioning <https://semver.org/>`__ quite rigorously!
|
||||
|
||||
That means that breaking changes can *only* occur in major versions (e.g. ``v1.9.6`` -> ``v2.0.0``).
|
||||
|
||||
If you find that something breaks, and you didn't update to a new major version, then it is a bug, and we would be grateful if you reported it!
|
||||
|
||||
In case you're stuck with an old codebase, you can downgrade to a previous version of ``fbchat``, e.g. version ``1.9.6``:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
$ pip install fbchat==1.9.6
|
||||
|
||||
|
||||
Will you be supporting creating posts/events/pages and so on?
|
||||
-------------------------------------------------------------
|
||||
|
||||
We won't be focusing on anything else than chat-related things. This library is called ``fbCHAT``, after all!
|
@@ -1,23 +0,0 @@
|
||||
.. highlight:: sh
|
||||
.. See README.rst for explanation of these markers
|
||||
|
||||
.. include:: ../README.rst
|
||||
:end-before: inclusion-marker-intro-end
|
||||
|
||||
With that said, let's get started!
|
||||
|
||||
.. include:: ../README.rst
|
||||
:start-after: inclusion-marker-installation-start
|
||||
:end-before: inclusion-marker-installation-end
|
||||
|
||||
|
||||
Documentation Overview
|
||||
----------------------
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
intro
|
||||
examples
|
||||
faq
|
||||
api/index
|
152
docs/intro.rst
152
docs/intro.rst
@@ -1,152 +0,0 @@
|
||||
Introduction
|
||||
============
|
||||
|
||||
Welcome, this page will guide you through the basic concepts of using ``fbchat``.
|
||||
|
||||
The hardest, and most error prone part is logging in, and managing your login session, so that is what we will look at first.
|
||||
|
||||
|
||||
Logging In
|
||||
----------
|
||||
|
||||
Everything in ``fbchat`` starts with getting an instance of `Session`. Currently there are two ways of doing that, `Session.login` and `Session.from_cookies`.
|
||||
|
||||
The follow example will prompt you for you password, and use it to login::
|
||||
|
||||
import getpass
|
||||
import fbchat
|
||||
session = fbchat.Session.login("<email/phone number>", getpass.getpass())
|
||||
# If your account requires a two factor authentication code:
|
||||
session = fbchat.Session.login(
|
||||
"<your email/phone number>",
|
||||
getpass.getpass(),
|
||||
lambda: getpass.getpass("2FA code"),
|
||||
)
|
||||
|
||||
However, **this is not something you should do often!** Logging in/out all the time *will* get your Facebook account locked!
|
||||
|
||||
Instead, you should start by using `Session.login`, and then store the cookies with `Session.get_cookies`, so that they can be used instead the next time your application starts.
|
||||
|
||||
Usability-wise, this is also better, since you won't have to re-type your password every time you want to login.
|
||||
|
||||
The following, quite lengthy, yet very import example, illustrates a way to do this:
|
||||
|
||||
.. literalinclude:: ../examples/session_handling.py
|
||||
|
||||
Assuming you have successfully completed the above, congratulations! Using ``fbchat`` should be mostly trouble free from now on!
|
||||
|
||||
|
||||
Understanding Thread Ids
|
||||
------------------------
|
||||
|
||||
At the core of any thread is its unique identifier, its ID.
|
||||
|
||||
A thread basically just means "something I can chat with", but more precisely, it can refer to a few things:
|
||||
- A Messenger group thread (`Group`)
|
||||
- The conversation between you and a single Facebook user (`User`)
|
||||
- The conversation between you and a Facebook Page (`Page`)
|
||||
|
||||
You can get your own user ID from `Session.user` with ``session.user.id``.
|
||||
|
||||
Getting the ID of a specific group thread is fairly trivial, you only need to login to `<https://www.messenger.com/>`_, click on the group you want to find the ID of, and then read the id from the address bar.
|
||||
The URL will look something like this: ``https://www.messenger.com/t/1234567890``, where ``1234567890`` would be the ID of the group.
|
||||
|
||||
The same method can be applied to some user accounts, though if they have set a custom URL, then you will have to use a different method.
|
||||
|
||||
An image to illustrate the process is shown below:
|
||||
|
||||
.. image:: /_static/find-group-id.png
|
||||
:alt: An image illustrating how to find the ID of a group
|
||||
|
||||
Once you have an ID, you can use it to create a `Group` or a `User` instance, which will allow you to do all sorts of things. To do this, you need a valid, logged in session::
|
||||
|
||||
group = fbchat.Group(session=session, id="<The id you found>")
|
||||
# Or for user threads
|
||||
user = fbchat.User(session=session, id="<The id you found>")
|
||||
|
||||
Just like threads, every message, poll, plan, attachment, action etc. you send or do on Facebook has a unique ID.
|
||||
|
||||
Below is an example of using such a message ID to get a `Message` instance::
|
||||
|
||||
# Provide the thread the message was created in, and it's ID
|
||||
message = fbchat.Message(thread=user, id="<The message id>")
|
||||
|
||||
|
||||
Fetching Information
|
||||
--------------------
|
||||
|
||||
Managing these ids yourself quickly becomes very cumbersome! Luckily, there are other, easier ways of getting `Group`/`User` instances.
|
||||
|
||||
You would start by creating a `Client` instance, which is basically just a helper on top of `Session`, that will allow you to do various things::
|
||||
|
||||
client = fbchat.Client(session=session)
|
||||
|
||||
Now, you could search for threads using `Client.search_for_threads`, or fetch a list of them using `Client.fetch_threads`::
|
||||
|
||||
# Fetch the 5 most likely search results
|
||||
# Uses Facebook's search functions, you don't have to specify the whole name, first names will usually be enough
|
||||
threads = list(client.search_for_threads("<name of the thread to search for>", limit=5))
|
||||
# Fetch the 5 most recent threads in your account
|
||||
threads = list(client.fetch_threads(limit=5))
|
||||
|
||||
Note the `list` statements; this is because the methods actually return `generators <https://wiki.python.org/moin/Generators>`__. If you don't know what that means, don't worry, it is just something you can use to make your code faster later.
|
||||
|
||||
The examples above will actually fetch `UserData`/`GroupData`, which are subclasses of `User`/`Group`. These model have extra properties, so you could for example print the names and ids of the fetched threads like this::
|
||||
|
||||
for thread in threads:
|
||||
print(f"{thread.id}: {thread.name}")
|
||||
|
||||
Once you have a thread, you can use that to fetch the messages therein::
|
||||
|
||||
for message in thread.fetch_messages(limit=20):
|
||||
print(message.text)
|
||||
|
||||
|
||||
Interacting with Threads
|
||||
------------------------
|
||||
|
||||
Once you have a `User`/`Group` instance, you can do things on them as described in `ThreadABC`, since they are subclasses of that.
|
||||
|
||||
Some functionality, like adding users to a `Group`, or blocking a `User`, logically only works the relevant threads, so see the full API documentation for that.
|
||||
|
||||
With that out of the way, let's see some examples!
|
||||
|
||||
The simplest way of interacting with a thread is by sending a message::
|
||||
|
||||
# Send a message to the user
|
||||
message = user.send_text("test message")
|
||||
|
||||
There are many types of messages you can send, see the full API documentation for more.
|
||||
|
||||
Notice how we held on to the sent message? The return type i a `Message` instance, so you can interact with it afterwards::
|
||||
|
||||
# React to the message with the 😍 emoji
|
||||
message.react("😍")
|
||||
|
||||
Besides sending messages, you can also interact with threads in other ways. An example is to change the thread color::
|
||||
|
||||
# Will change the thread color to the default blue
|
||||
thread.set_color("#0084ff")
|
||||
|
||||
|
||||
Listening & Events
|
||||
------------------
|
||||
|
||||
Now, we are finally at the point we have all been waiting for: Creating an automatic Facebook bot!
|
||||
|
||||
To get started, you create the functions you want to call on certain events::
|
||||
|
||||
def my_function(event: fbchat.MessageEvent):
|
||||
print(f"Message from {event.author.id}: {event.message.text}")
|
||||
|
||||
Then you create a `fbchat.Listener` object::
|
||||
|
||||
listener = fbchat.Listener(session=session, chat_on=False, foreground=False)
|
||||
|
||||
Which you can then use to receive events, and send them to your functions::
|
||||
|
||||
for event in listener.listen():
|
||||
if isinstance(event, fbchat.MessageEvent):
|
||||
my_function(event)
|
||||
|
||||
View the :ref:`examples` to see some more examples illustrating the event system.
|
@@ -1,35 +0,0 @@
|
||||
@ECHO OFF
|
||||
|
||||
pushd %~dp0
|
||||
|
||||
REM Command file for Sphinx documentation
|
||||
|
||||
if "%SPHINXBUILD%" == "" (
|
||||
set SPHINXBUILD=sphinx-build
|
||||
)
|
||||
set SOURCEDIR=.
|
||||
set BUILDDIR=_build
|
||||
|
||||
if "%1" == "" goto help
|
||||
|
||||
%SPHINXBUILD% >NUL 2>NUL
|
||||
if errorlevel 9009 (
|
||||
echo.
|
||||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
||||
echo.installed, then set the SPHINXBUILD environment variable to point
|
||||
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
||||
echo.may add the Sphinx directory to PATH.
|
||||
echo.
|
||||
echo.If you don't have Sphinx installed, grab it from
|
||||
echo.http://sphinx-doc.org/
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
|
||||
goto end
|
||||
|
||||
:help
|
||||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
|
||||
|
||||
:end
|
||||
popd
|
@@ -1,3 +0,0 @@
|
||||
premade
|
||||
todo
|
||||
emoji
|
@@ -1,3 +0,0 @@
|
||||
Facebook
|
||||
GraphQL
|
||||
GitHub
|
@@ -1,17 +0,0 @@
|
||||
iterables
|
||||
iterable
|
||||
mimetype
|
||||
timestamp
|
||||
metadata
|
||||
spam
|
||||
spammy
|
||||
admin
|
||||
admins
|
||||
unsend
|
||||
unsends
|
||||
unmute
|
||||
spritemap
|
||||
online
|
||||
inbox
|
||||
subclassing
|
||||
codebase
|
@@ -1,64 +0,0 @@
|
||||
[tool.black]
|
||||
line-length = 88
|
||||
target-version = ['py36', 'py37', 'py38']
|
||||
|
||||
[build-system]
|
||||
requires = ["flit"]
|
||||
build-backend = "flit.buildapi"
|
||||
|
||||
[tool.flit.metadata]
|
||||
module = "fbchat"
|
||||
author = "Taehoon Kim"
|
||||
author-email = "carpedm20@gmail.com"
|
||||
maintainer = "Mads Marquart"
|
||||
maintainer-email = "madsmtm@gmail.com"
|
||||
home-page = "https://github.com/carpedm20/fbchat/"
|
||||
requires = [
|
||||
"attrs>=19.1",
|
||||
"requests~=2.19",
|
||||
"beautifulsoup4~=4.0",
|
||||
"paho-mqtt~=1.5",
|
||||
]
|
||||
description-file = "README.rst"
|
||||
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 :: 3",
|
||||
"Programming Language :: Python :: 3 :: Only",
|
||||
"Programming Language :: Python :: 3.5",
|
||||
"Programming Language :: Python :: 3.6",
|
||||
"Programming Language :: Python :: 3.7",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: Implementation :: CPython",
|
||||
"Programming Language :: Python :: Implementation :: PyPy",
|
||||
"Topic :: Communications :: Chat",
|
||||
"Topic :: Internet :: WWW/HTTP",
|
||||
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
|
||||
"Topic :: Software Development :: Libraries",
|
||||
"Topic :: Software Development :: Libraries :: Python Modules",
|
||||
]
|
||||
requires-python = ">=3.5, <4.0"
|
||||
keywords = "Facebook FB Messenger Library Chat Api Bot"
|
||||
license = "BSD 3-Clause"
|
||||
|
||||
[tool.flit.metadata.urls]
|
||||
Documentation = "https://fbchat.readthedocs.io/"
|
||||
Repository = "https://github.com/carpedm20/fbchat/"
|
||||
|
||||
[tool.flit.metadata.requires-extra]
|
||||
test = [
|
||||
"pytest>=4.3,<6.0",
|
||||
]
|
||||
docs = [
|
||||
"sphinx~=2.0",
|
||||
"sphinxcontrib-spelling~=4.0",
|
||||
"sphinx-autodoc-typehints~=1.10",
|
||||
]
|
||||
lint = [
|
||||
"black",
|
||||
]
|
10
pytest.ini
10
pytest.ini
@@ -1,10 +0,0 @@
|
||||
[pytest]
|
||||
xfail_strict = true
|
||||
markers =
|
||||
online: Online tests, that require a user account set up. Meant to be used \
|
||||
manually, to check whether Facebook has broken something.
|
||||
addopts =
|
||||
--strict
|
||||
-m "not online"
|
||||
testpaths = tests
|
||||
filterwarnings = error
|
Reference in New Issue
Block a user