Coder Social home page Coder Social logo

architus / architus Goto Github PK

View Code? Open in Web Editor NEW
28.0 28.0 11.0 10.14 MB

Multi-purpose Discord bot implemented using the discord.py library

Home Page: https://archit.us

License: MIT License

Python 65.79% Shell 0.40% Dockerfile 1.19% ANTLR 0.12% TeX 0.03% Rust 26.62% Go 2.49% Starlark 3.37%
bot discord discord-py python

architus's Introduction

Architus

API Uptime Style Discord Server

Architus is a multi-purpose Discord bot implemented using the discord.py library that empowers both admins and server members with the tools and features to have a more streamlined and enjoyable experience.

๐Ÿ“š Features

  • Web-interface
  • Custom responses
  • Role management
  • Music
  • Starboard
  • Events

๐ŸŽŸ Invite

You can invite architus to your discord server with this link or through the web-interface.

๐Ÿš€ Installing

  1. Create a discord app: https://discordapp.com/developers/applications/me
  2. Install docker-compose
  3. Create architus.env from example.env
  4. Build and start containers docker-compose up --build

โ“ Getting Help

If you have an issue about the bot, web dashboard, or have any other questions, feel free to create a new issue or join our Discord server

๐Ÿ“œ License

FOSSA Status

architus's People

Contributors

alexapplemanzer avatar dependabot[bot] avatar jammiess avatar jazeved0 avatar jchu60 avatar johnyburd avatar lvwirian avatar mgordon34 avatar nbennett30 avatar stevenman42 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

architus's Issues

Fix Gulag Command dropping some people's votes

There is an issue right now where discord.py just won't count some people's votes.

The fix is already in the pugs command.

To minimize the impact of discord api being weird, have the gulag command look at all of the reactions every time there is a react event instead of adding the last react.

Database migrations are manual and difficult to version

We should include a versioned migration system for our primary datastore postgres service. However, since the service can be used by multiple other services, the migration handler should reside outside of any language-specific ORM, and use plain SQL preferably.

Channel Recording Feature

Add a new record command.

On invocation, architus will join the author's voice channel and begin recording each member's audio in the channel.
Upon receiving a record stop (or similar) command, architus will post a link to a cdn link to an mp3 (if possible) audio file, in which each member's audio is contained in its own channel

There should be a reasonable maximum length for the recording, and the recording should end if architus is the only user in the voice channel.

If a play or record command is invoked by a member in a different voice channel, architus should inform the user that the current recording must be stopped first.

youtube-dl needs to be updated frequently and randomly

Our music service relies on a program called youtube-dl to download videos from youtube. It's not supported by google, so youtube regularly breaks it and then youtube-dl updates to fix. We need to update youtube-dl regularly in order to stay on top of these changes.

  • Find the best solution for a scheduled task in docker (maybe cron idk)
  • Schedule python3 -m pip install youtube-dl --upgrade to run every hour

All emojis disappeared

Suddenly Architus deleted all emojis from my server:

image

and put them in cache: https://cdn.archit.us/assets/878159977922301966.png

If I type any emoji in chat (e.g., :ksoo:), Architus neither replaces the string with an emoji nor takes the emoji from cache back into the server (even though it is in cache). How can I get my emojis back?

Thanks for the help!

Change Authentication Format

Modify /token-exchange route to return the following:

JSON Response

{
    "user": "{ ...User object }",
    "token": "<jwt_token>"
}

JWT Format

Uses standard JWT encoding with data schema as follows:

{
    "accessToken": "<encrypted Discord access token>",
    "refreshToken": "<encrypted Discord refresh token>",
    "id": "User snowflake ID",
    "issuedAt": "ISO 8601 utc issuance date",
    "expiresIn": "seconds until expiration",
    "permissions": "<any>"
}

Rationale

accessToken and refreshToken should use asymmetric encryption so that the server is the only one capable of reading their values. This is because the JWT is supposed to serve two purposes:

  1. Eliminate the need for a session store on the server (make the user store their own session data)
  2. Act as an intermediate authorization source between the user and the Discord API by limiting the actions that the token can be used for to actions possible through the Architus API. This results in a smaller attack surface in case a user's token is leaked somehow. By encrypting the Discord access/refresh tokens, we ensure that a leaked token won't let attackers gain access to these more powerful direct authorization methods.

Permissions

The permissions key is designed to provide an extensible means of implementing some sort of guild-based authorization/permission level for the backend and its APIs without changing the typings on the frontend. Because of this, any data in this key-value pair will not be consumed by the frontend at all.

Spam botnet protection

Design a system to automatically ban users that spam an inhuman number of messages. Add a settings category and include options for disable/enable and maximum allowed rate and ban/ban + purge

Docker build fails locally due to missing pip3 dependency on manager service

Steps to reproduce

On develop, run:

docker-compose build

The build for the manager service fails.

See output

$ docker-compose build
...
Building manager
Step 1/11 : FROM alpine:edge
edge: Pulling from library/alpine
0d6b48c80e92: Pull complete
Digest: sha256:c22dc21793cd8d713df961ea1617b09de924f3dd5291970705037ff190f228a7
Status: Downloaded newer image for alpine:edge
 ---> 5737d7d248e9
Step 2/11 : RUN mkdir -p /var/www
 ---> Running in f4deb8796c57
Removing intermediate container f4deb8796c57
 ---> 3b424e2794a5
Step 3/11 : WORKDIR /app
 ---> Running in a2d5355d50eb
Removing intermediate container a2d5355d50eb
 ---> 13c022bbb05a
Step 4/11 : COPY ./manager/requirements.txt /app
 ---> 96b94bd801dc
Step 5/11 : RUN apk update && apk add build-base python3 python3-dev
 ---> Running in d6a67abb2862
fetch http://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
v3.12.0-522-g5bb0d036ac [http://dl-cdn.alpinelinux.org/alpine/edge/main]
v3.12.0-531-g8efa6cf1b4 [http://dl-cdn.alpinelinux.org/alpine/edge/community]
OK: 12806 distinct packages available
(1/33) Upgrading musl (1.1.24-r6 -> 1.1.24-r8)
(2/33) Installing libgcc (9.3.0-r2)
(3/33) Installing libstdc++ (9.3.0-r2)
(4/33) Installing binutils (2.34-r1)
(5/33) Installing libmagic (5.38-r0)
(6/33) Installing file (5.38-r0)
(7/33) Installing gmp (6.2.0-r0)
(8/33) Installing isl (0.18-r0)
(9/33) Installing libgomp (9.3.0-r2)
(10/33) Installing libatomic (9.3.0-r2)
(11/33) Installing libgphobos (9.3.0-r2)
(12/33) Installing mpfr4 (4.0.2-r4)
(13/33) Installing mpc1 (1.1.0-r1)
(14/33) Installing gcc (9.3.0-r2)
(15/33) Installing musl-dev (1.1.24-r8)
(16/33) Installing libc-dev (0.7.2-r3)
(17/33) Installing g++ (9.3.0-r2)
(18/33) Installing make (4.3-r0)
(19/33) Installing fortify-headers (1.1-r0)
(20/33) Installing patch (2.7.6-r6)
(21/33) Installing build-base (0.5-r2)
(22/33) Installing libbz2 (1.0.8-r1)
(23/33) Installing expat (2.2.9-r1)
(24/33) Installing libffi (3.3-r2)
(25/33) Installing gdbm (1.13-r1)
(26/33) Installing xz-libs (5.2.5-r0)
(27/33) Installing ncurses-terminfo-base (6.2_p20200606-r0)
(28/33) Installing ncurses-libs (6.2_p20200606-r0)
(29/33) Installing readline (8.0.4-r0)
(30/33) Installing sqlite-libs (3.32.2-r0)
(31/33) Installing python3 (3.8.3-r0)
(32/33) Installing pkgconf (1.7.3-r0)
(33/33) Installing python3-dev (3.8.3-r0)
Executing busybox-1.31.1-r14.trigger
OK: 299 MiB in 46 packages
Removing intermediate container d6a67abb2862
 ---> 0c08207cde9f
Step 6/11 : RUN python3 -m pip install --trusted-host pypi.python.org -r requirements.txt
 ---> Running in 8a2a6cadde84
/usr/bin/python3: No module named pip
ERROR: Service 'manager' failed to build: The command '/bin/sh -c python3 -m pip install --trusted-host pypi.python.org -r requirements.txt' returned a non-zero code: 1

System details

Arch Linux
Kernel 5.6.14-arch1-1 amd64
docker-compose version 1.25.5, build unknown
Docker version 19.03.9-ce, build 9d988398e7

Better role management UX

update the role feature to allow users to get a role by reacting to a message instead of typing a command

Remove IPC RPC dependence on json

All the ipc remote calls encode their arguments in json. When passing images around, this requires us to encode them in base64 strings and then decode them on the other side.

Determine the best way to modify/extend the rpc systems to properly support binary data and implement it so that it doesn't break existing

Dynamic eval timeout

Have the eval feature of autoresponses dynamically evaluate a timeout so webrequests don't cause timeouts all the time.

Add PR templates

Add pull request templates to this repo.

Include requirements:

  • link to issue
  • Tested locally
  • additional issue created in docs repo

Emoji manager replaces messages with foreign Nitro emotes

The emoji manager will perform its replacement on messages that contain foreign, fully-resolved emotes (sent by a user with Nitro), replacing the message with the current server's version.

While this isn't harmful, it's unnecessary since the emoji would be displayed otherwise.

Potential regressions

This might make it harder for Nitro users to trigger a load of a guild-specific emote if they have another foreign emote from some other server that shares the same shortcode.

Upgrade purge command

Proposed updated command:

!purge [user, channel, number] <--global>

Example:
    !purge 50
    > deletes the most recent 50 messages in the current channel

Arguments:
    number: Number of messages to delete <required>
    user: Target user (default: every user)
    channel: Target channel (default: current channel)
    --global: Purges messages in all channels, totaling the number

Check Stock Price

It would be nice to use a command to check stock prices, such as โ€œ!price [ticker_symbol]โ€ and give the current price and ideally a nice graph of historical prices.

Latex Error Messages

When the latex compilation fails, send the user meaningful information about why it failed / where it failed.

Emoji Manager - basic functionality API support

Frontend ticket: architus/archit.us#56

Emoji Obj

  • id: str
  • name: str
  • authorId: str?
  • loaded: bool
  • numUses: int
  • discordId: str?
  • url: str

GET /emojis/{guild.id}/ - authenticated

returns a list of every emoji in the guild

GET /emojis/{guild.id}/{emoji.id}/ - authenticated

returns a single emoji object

POST /emojis/{guild.id}/{emoji.id}/ - authenticated

will instruct the emoji manager to load an emoji

PATCH /emojis/{guild.id}/{emoji.id}/ - authenticated

will instruct the emoji manager to cache an emoji

  • user must be an admin

DELETE /emojis/{guild.id}/{emoji.id}/ - authenticated

instruct the emoji manager to delete an emoji from the guild and the cache

  • user must be the owner or an admin

Event polls broken

There are two causes of this bug:

  • Reaction listeners depend on the message queue
  • Event messages are stored in volatile memory

Solution to 1

Since we make a api call to fetch users that reacted already, we can use raw reaction event to get the event and then manually call get reactions (only have to do if we don't have the message object cached somewhere) to get the users.

This requires 3 calls for schedule and up to 10 for poll.

Solutions to 2

Option 1

Store the message id and the event data (i.e. title, poll options, etc) in the database. On initialization, fetch the messages by their id and store them in the cog. Whenever a reaction is fired, recalculate the message contents and make the edit.

  • Should only make a db query on initialization and on new event
  • Keeping a cache of message objects prevents us from having to make a custom api hook in Solution 1
  • On initialization - if the event message was sent more than 2 weeks ago, remove it from the db

Option 2

Parse every message to determine if it was an event and to extract the original title and options.

  • Does not require db at all
  • Requires relying on the global message cache
  • This is a bad option, don't pick it

Add stats endpoints for the frontend

/stats/<guild_id>/

{
    'members': {
        'count': 10,
    },
    'messages': {
        'count': 1090,
        'channels': {
            '1234567890': 1000,
            '0987654321': 90,
        },
        'members': {
            '2142315714': 501,
            '3456945684: 589,
        },
        'times': {
            '2019-12-27T23:05:0.000000': 974,
            '2019-12-28T12:35:0.000000': 16,
            '2019-12-28T12:40:0.000000': 27,
            '2019-12-28T12:55:0.000000': 100,
        },
    },
}

[RFC] Add method to report issues via bot

make it so users can create new issues through discord

have the bot open a dm with the user and then have them submit a captcha to submit the actual issue to prevent people from abusing the system

thank

Set reminders/alerts

Allow the bot to send reminders/alerts at the desired time(s) specified by the user.

Possible extension: allow spreadsheet integration / some file format to specify reminders.

Add LaTeX rendering options

Would it be possible to render latex with a white font color and a transparent background?

Potential options

  • Background color (including transparent)
  • Default foreground color
  • TEXLive package inclusion
  • Padding

Configuration methods

Preferably, these could be configured both on a per-guild and per-invocation level.

Twitch stream online notification

As an esteemed Architus user and developer, I would greatly appreciate a feature that will notice me when a designated streamer goes online.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.