Go to file
Luna 2ad3cd6ad7 ignore unknown guilds when deleting read states 2020-07-29 17:18:47 -03:00
attachments add attachments folder with .gitkeep 2018-12-08 23:22:38 -03:00
docs gateway.websocket: cast user_ids to List[Union[int, Any]] 2019-09-07 12:13:21 -03:00
images all: add guild icon support 2018-11-13 21:12:40 -03:00
litecord ignore unknown guilds when deleting read states 2020-07-29 17:18:47 -03:00
manage fix roles.permissions' datatype to bigint 2020-07-29 15:28:31 -03:00
static keep links as underlines (pre-hover) 2019-04-15 16:28:59 -03:00
tests Add test to ensure a removed state invalidates WS 2020-04-05 15:08:46 -03:00
.gitignore ignore .vscode 2019-03-01 19:42:50 +01:00
.gitlab-ci.yml .gitlab-ci.yml: run black fmt check 2020-03-31 16:38:59 -03:00
LICENSE LICENSE: make it gplv3-only 2018-12-06 19:02:03 -03:00
Pipfile pipfile: update depedencies 2020-06-10 16:01:01 -03:00
Pipfile.lock pipfile: update depedencies 2020-06-10 16:01:01 -03:00
README.md fix types (big) 2020-02-06 21:10:51 +00:00
__init__.py all: add GPL header 2018-12-07 02:14:58 -03:00
config.ci.py black fmt pass 2019-10-25 07:27:50 -03:00
config.example.py black fmt pass 2019-10-25 07:27:50 -03:00
discord_endpoints.txt small fixes 2018-12-03 01:46:37 +01:00
ecosystem.config.js ecosystem.config.js: add bind 2019-02-26 23:23:06 -03:00
manage.py black fmt pass 2019-10-25 07:27:50 -03:00
mypy.ini fix types (big) 2020-02-06 21:10:51 +00:00
nginx.conf nginx: update ports 2020-01-29 06:51:04 +00:00
requirements.txt Pipfile: add pyflakes 2018-11-12 18:11:04 -03:00
run.py fix api_index() accessing wrong fields 2020-06-26 22:30:41 -03:00
setup.py black fmt pass 2019-10-25 07:27:50 -03:00
tox.ini fix types (big) 2020-02-06 21:10:51 +00:00

README.md

Litecord logo

Litecord is an open source, clean-room design reimplementation of Discord's HTTP API and Gateway in Python 3.

This project is a rewrite of litecord-reference and litecord serviced.

Wait, two other Litecords?

The first version is litecord-reference, written in Python and used MongoDB as storage. It was rewritten into "litecord serviced" so that other developers could help writing it, defining a clear protocol between components (litebridge). Sadly, it didn't take off, so I (Luna), that wrote the other two, took a shot at writing it again. It works.

This is "Litecord" / "litecord". There are no rewrites planned.

Project Goals

  • Being able to unit test bots in an autonomous fashion.
  • Doing research and exploration on the Discord API.

Non-goals

  • Being used as a "self-hostable Discord alternative".

Caveats

  • Unit testing is incomplete.
  • Currently, there are no plans to support video in voice chats, or the Discord Store.
  • An unofficial Discord Client is recommended to connect (more on docs/clients.md). Litecord will not distribute official client code from Discord nor provide ways to modify the official client.

Implementation status, AKA "Does it work?"

Approximately 80% of the REST API is reimplemented in Litecord. A wild guess for the Gateway / Websockets API is 95%. Reminder that those do not count voice specific components, but do count things the official client uses, such as lazy guilds.

Tracking routes such as /api/science have dummy implementations so they don't crash the client. They do not store any information given by the client.

Also consider that reimplementing the Discord API is kind-of a moving target, as Discord can implement parts of the API that aren't documented at any point in time.

Liability

We (Litecord and contributors) are not liable for usage of this software, valid or invalid. If you intend to use this software as a "self-hostable Discord alternative", you are solely responsible for any legal action delivered by Discord if you are using their assets, intellectual property, etc.

All referenced material for implementation is based off of official Discord API documentation or third party libraries (such as Eris).

Installation

Requirements:

  • Python 3.8+
  • PostgreSQL (tested using 9.6+), SQL knowledge is recommended.
  • gifsicle for GIF emoji and avatar handling
  • pipenv

Optional requirement:

Download the code

$ git clone https://gitlab.com/litecord/litecord.git && cd litecord

Install packages

$ pipenv install --dev

Setting up the database

It's recommended to create a separate user for the litecord database.

# Create the PostgreSQL database.
$ createdb litecord

Copy the config.example.py file and edit it to configure your instance ( postgres credentials, etc):

$ cp config.example.py config.py
$ $EDITOR config.py

Then, you should run database migrations:

$ pipenv run ./manage.py migrate

Running

Hypercorn is used to run Litecord. By default, it will bind to 0.0.0.0:5000. This will expose your Litecord instance to the world. You can use the -b option to change it (e.g. -b 0.0.0.0:45000).

$ pipenv run hypercorn run:app

You can use --access-log - to output access logs to stdout.

It is recommended to run litecord behind NGINX. You can use the nginx.conf file at the root of the repository as a template.

Does it work?

You can check if your instance is running by performing an HTTP GET request on the /api/v6/gateway endpoint. For basic websocket testing, a tool such as ws can be used.

After checking that it actually works, docs/operating.md continues on common operations for a Litecord instance.

Updating

Update the code and run any new database migrations:

$ git pull
$ pipenv run ./manage.py migrate

Running tests

# Install tox:
$ pip install tox

# Run lints and tests:
$ tox