Giter Site home page Giter Site logo

armandbriere / archy Goto Github PK

View Code? Open in Web Editor NEW
32.0 32.0 21.0 18.15 MB

Serverless discord Bot in Golang and Python with Google Cloud

Home Page: https://archybot.web.app/

License: GNU General Public License v3.0

Shell 0.08% Go 34.01% Python 31.22% JavaScript 2.05% HCL 9.27% TypeScript 13.52% HTML 5.36% SCSS 3.71% Makefile 0.27% Java 0.31% CSS 0.17% Dockerfile 0.04%
discord-bot firebase golang google-cloud python serverless

archy's People

Contributors

alexandrelachancegit avatar armandbriere avatar cmd0 avatar cor-lapidem avatar heliumapple avatar lancelotnd avatar mmasson-01 avatar pierreolivierbrillant avatar raoufbaz avatar wildman777 avatar zacharypeloquin 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  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

archy's Issues

Web all servers component

Is your feature request related to a problem? Please describe.
The bot is on multiple servers but there is no way to see that on the web page

Describe the solution you'd like

  • Create a new Angular component for a single server (Name, image and invite url)
  • Create a new Angular component for the server list
  • Display those component on the Home page for the beginning, this might move to its own page if the bot joins multiple servers

Refactor `help` cloud function to Golang

Is your feature request related to a problem? Please describe.

Python is slow, golang is better

Describe the solution you'd like

Refactor the python src/functions/help cloud function to Golang.

Modify main node to register `/` commands

Is your feature request related to a problem? Please describe.
The ! is nice but the future of discord bot is in the slash commands

Describe the solution you'd like
We need to modify the main node to use slash command:

  • Change discord.py to pycord https://github.com/Pycord-Development/pycord
  • All command should have their function
  • All command function must redirect treatment to cloud function
  • All command function will have description
  • If a command isn't active in Firestore, send back an ephemeral message back to user

Refactor `hello` cloud function to Golang

Is your feature request related to a problem? Please describe.

Python is slow, golang is better

Describe the solution you'd like

Refactor the python src/functions/hello cloud function to Golang.

VSCode extensions.json

A good .vscode/extensions.json would help new developers to work on the project
We need extensions for the following thing :

  • Python
  • Golang
  • Angular
  • newline at the end of json files
  • Terraform

Golang test mock

Is your feature request related to a problem? Please describe.
Python testing and mock is complete, we need the same for Golang

Describe the solution you'd like

  • The exp function has some tests, but we are not mocking Firestore calls
  • We need to find a robust structure to mock those calls
  • Write detailed documentation with code snippets about that

Refactor `describe` cloud function to Golang

Is your feature request related to a problem? Please describe.

Python is slow, golang is better

Describe the solution you'd like

Refactor the python src/functions/describe cloud function to Golang.

Role based on level

Is your feature request related to a problem? Please describe.
We have ranks and level, we want to associate special role to a level

Describe the solution you'd like

  • pubsub function in Go that read the Firestore DB to find which role a specific use should have
  • If some roles are missing -> add them
  • Find a way to execute this function for users that are already here

Golang unit test in CI

We have cloud functions that are written in Golang, we need to add unit test and run those test in the CI

Golang mock needs to be looked at

Right now, we only have a few integrations tests to run manually

Generate image to display rank

Is your feature request related to a problem? Please describe.
The rank is the core feature of the bot right now, having a nice image to display instead of the text from the level command would be nice

Describe the solution you'd like
Generate dynamic image from the firestore data, should be done in python with PIL or using image2PDF (or something like this, the project is no longer maintained I think)
https://github.com/vgalin/html2image

Some design template could be done before starting this feature, the work would be considered a POC if done before the design template

Use is_active function in the main node

Is your feature request related to a problem? Please describe.
We have a list of all functions in the firebase with a active boolean var, we want to use it in the main node to activate/deactivate command

Describe the solution you'd like

  • Read data from firestore
  • Execute command only if it's active in firestore

Refactor `answer` cloud function to Golang

Is your feature request related to a problem? Please describe.

Python is slow, golang is better

Describe the solution you'd like

Refactor the python src/functions/answer cloud function to Golang.

Exp function should track message count

Is your feature request related to a problem? Please describe.
The database that we used had message_count attribute before, the exp function should increment this variable only once every minute

Describe the solution you'd like
add this code to the exp function at the proper place
batch.update(doc_ref, ({"message_count": Increment(1)}))

Refactor `exam` cloud function to Golang

Is your feature request related to a problem? Please describe.

Python is slow, golang is better

Describe the solution you'd like

Refactor the python src/functions/exam cloud function to Golang.

Fix !gif command to take all params in consideration

Is your feature request related to a problem? Please describe.
Right now, when we use !gif cute cat it only uses cute as the search param and not cat

Describe the solution you'd like
Concat the params in the gif fonction code with space and url-encode it

New discord command: "!help"

A new command that returns all currently enabled commands would help user interaction

We need to find a way to check what functions are deployed and which one are not, this can be done via Firebase or just in code

In the long term it would be good to enable and disable commands using an admin panel in the web page. You can keep that in mind while thinking of a solution

Fix /level with user that are not in the DB

Is your feature request related to a problem? Please describe.
!level @archy works
/level @archy doesn't

Describe the solution you'd like
Modify /level in main node to handle image and text response
Add a try except to display the message if it's provided

Add a new "On user join" event

We want Archy to greets new users

  • Add a listener to the main node
  • Throw a pub/sub event when a new user arrive
  • Write a cloud function that listen to this event and greets the user

Create dev & prod env

Is your feature request related to a problem? Please describe.
We need a dev env to test code before merging it to prod

Describe the solution you'd like

  • dev env is the development server

  • prod is the other servers

  • We need a new git flow to code, merge and contribute to the project

  • Update terraform to create dev functions and prod functions by using prefix name

  • Auto deploy to dev on merge to that branch (same for prod and the main branch)

  • Concerning the main node, we might need a new Discord token to create Archy-dev or we can just rely on the server ID before calling cloud functions

Add i18n to Angular

Add translations in french and english to accomodate our target audience.

Documentation available here.

Change exp from http to pubsub

Is your feature request related to a problem? Please describe.
Exp function is a http one, we need it to be a pubsub

Describe the solution you'd like
Change exp/main.py, unit tests, terraform and main node code

!froge command, gif support

Is your feature request related to a problem? Please describe.
The !froge command return a random froge, a gif can be selected and the current .png extension breaks it

Describe the solution you'd like
Change the code to identify if the selected froge emoji is a gif or a png and change the image extension
A default integration test could be added with a small gif in base64, like the image

Describe alternatives you've considered
Maybe the extension isn't required, maybe check that first

Automate action when Archy is added to a new server

Is your feature request related to a problem? Please describe.
Those are the action needed when Archy is added to a new server:

  • Create a new document on firebase inside the /serverList collection
    • document id is the server id
    • document fields are:
      • member_count
      • server_icon
      • server_id
      • server_name
  • Register all the commands with the "register_commands" script
  • Activate commands on the server
  • Create level to role map

Describe the solution you'd like
Find a way to automate all those steps

Python Typing enforcement

Since we are using python typing to improve code quality, it would be good to have tox notifying developers when typing is missing

Pylint or maybe some other python module could provide that

Example:

def hello(name):
    return f"Hello {name}"

This code should look like this:

def hello(name: str) -> str:
    return f"Hello {name}"

Level command on user without avatarUrl result in index out of bound in go

Is your feature request related to a problem? Please describe.
!level @userwithoutavatar -> This is broken

Describe the solution you'd like
The level.go file is the problem on the regex

re := regexp.MustCompile("avatars/(.*).png")
var subMatch = re.FindStringSubmatch(user.AvatarUrl)
if len(subMatch) < 2 {
re := regexp.MustCompile("avatars/(.*).gif")
subMatch = re.FindStringSubmatch(user.AvatarUrl)
}

user.AvatarId = subMatch[1]

The subMatch[1] result in an index out of bound, this need to be fix

Write unit tests for function "describe"

The "describe" function is a small python code that needs testing

Read the testing documentation in src/README.md, these tests would be similar to test_hello.py

Add Go lint Ci to project

Is your feature request related to a problem? Please describe.
We write more and more Golang but we are not that good. A linter in ci will make the code better

Describe the solution you'd like
Add this to the project https://github.com/marketplace/actions/run-golangci-lint
We want to use their runner directly
We also want to have a link in our readme on how to run the linter locally

Make Froge of the Day identical for all servers

Is your feature request related to a problem? Please describe.
Right now we have one scheduler per server on Google cloud, we want the same scheduler for the whole bot with only one Froge of the Day

Describe the solution you'd like

  • Add the scheduler to terraform
  • Modify frogeOfTheDay to read the server id from terraform
  • Add a checker to see if the server wants the froge
  • Add a field for the channel id in firestore
  • Generate a single froge and publish it to pubsub
  • Add unit tests and clean the python code of Froge of the Day

Add nextJS function to terraform

Is your feature request related to a problem? Please describe.
The nextJS handling dynamic image generation isn't linked to terraform

Describe the solution you'd like

  • Add this function to the terraform file
  • Add a step to build this function before the terraform plan
  • Fix the code and function name to handle more image and routes

Refactor `frogeOfTheDay` cloud function to Golang

Is your feature request related to a problem? Please describe.

Python is slow, golang is better

Describe the solution you'd like

Refactor the python src/functions/frogeOfTheDay cloud function to Golang.

Translation Command

This command will translate the desired sentence in the language indicated.
Ex.: !translate French Hello, How are you?
-> Bonjour, Comment vas-tu?

Should use the google translate api or the DeepL Api.

Web Admin panel

Is your feature request related to a problem? Please describe.
We need an admin panel to interact with Firestore database

Describe the solution you'd like

  • This feature is accessible for the server Admins only
  • Some design template would be nice (still looking for someone to do them)
  • Table with all the functions of this server
  • Only the active field can be modified by an admin
  • Create a form with a submit button that register changes
  • This should be an Angular component

CDN for Froge emojis

Is your feature request related to a problem? Please describe.
Right now we are using discord CDN of their emoji, if the emoji is modified on the discord server it belongs to, we lose it

Describe the solution you'd like
We need a solution to store image in the cloud that can be pull easily without a download process like what's available on Firebase Storage

Meme command

Command that returns a custom generated meme from user selected parameters.
This command will use the IMGFLIP API.

Show course channels based on reaction emoji

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Most students are only interested in the course channels related to the course they are taking. Showing up in a server with tons of channels and having to mute all of unwanted channels might discourage newcomers to engage in the server.

Describe the solution you'd like

  • In a Readonly channel.
  • Each post represents a school session (based on the proposed cursed given by the university), listing every suggested courses in the session.
  • Each course is associated with an emoji.
  • Students can react to a post with an emoji associated with the course.
  • Reacting to a post with an emoji gives them a role which gives them access to the channel they are interested in.
  • An administrator should be able to define the relation Emoji - Course channel in an admin panel.

Describe alternatives you've considered
None

Additional context

  • Users should still be able to see all channels without having to react with every single emojis.
  • If a user reacts with an emoji other than the one related to the course, it should be removed.

Example

image

Deploy listener cloud function

Is your feature request related to a problem? Please describe.
We need a way to know when a cloud function or any ressource is being deployed

Describe the solution you'd like
Let's create a cloud function like cloudErrorLog that will track deployments log on the cloud and send us a discord message on the dev server

  • The function should be in Go
  • It should be clear what env is being deploy, maybe with multiple channels or different color
  • We want a clear and rapid view

Commands to display level to roles

Is your feature request related to a problem? Please describe.
We have no way to know what are the role to level value on a given server

Describe the solution you'd like
A go function that returns the list in a formatted way, something like the !help command

New bot command: Get the url of the leaderboard

Is your feature request related to a problem? Please describe.
There is no current way to get the leaderboard URL

Describe the solution you'd like
New cloud function written in Python with unit test that returns the current server leaderboard url
Command could be !leaderboard

Describe alternatives you've considered
The URL could also be added to the !level command but it wouldn't be nice

Refactor `gif` cloud function to Golang

Is your feature request related to a problem? Please describe.

Python is slow, golang is better

Describe the solution you'd like

Refactor the python src/functions/gif cloud function to Golang.

Web: Login with Discord

Is your feature request related to a problem? Please describe.
We want user to login with Discord on the web page
If they are admin of the server, they can modify some of the bot behavior

Describe the solution you'd like
Implement Oauth2 of discord and store user info in the cookies/session storage

Insult command

Command that returns an insult to the user tagged or the author using this Insult API.

This command will ultimately be able to insult multiple people at a time and will support custom insults.

⚠️ This command should only be used as a joke, and we do not support any form of online bullying or harrassment. ⚠️

Refactor `flag` cloud function to Golang

Is your feature request related to a problem? Please describe.

Python is slow, golang is better

Describe the solution you'd like

Refactor the python src/functions/flag cloud function to Golang.

Improve level function

Is your feature request related to a problem? Please describe.
Level returns an URL to og-vercel cloud function.
Download the image inside the cloud function and returns the base64 image to the main node
This will decrease the number of call to the og-vercel function

Describe the solution you'd like

  • http get request og-vercel function from level function
  • encode result in bas64
  • Returns it to the main node
  • Main node:
    • slash command -> decode and return image
    • normal command -> detect that it is an image -> decode and return it

Allow multiword parameters for commands

Is your feature request related to a problem? Please describe.
The current implementation doesn't allow for multiword parameters. This is blocking progress for #64.

Describe the solution you'd like

  • Use shlex.split() instead of str.split() to separate parameters.

Cloud function pub/sub in Go

Is your feature request related to a problem? Please describe.
We need a pub/sub cloud function that add a Discord role to a user
We need a pub/sub cloud function that remove a Discord role to a user

Describe the solution you'd like
Golang cloud function with cmd/main.go for manual integration test

Command to activate and deactivate command

Is your feature request related to a problem? Please describe.
We need a way to activate or deactivate a command by switching the boolean value in firebase

Describe the solution you'd like
A new command that would take a command name and a boolean (admin only)
We will also need an other command to disable all specified commands. In case a new deployment breaks a specific command, we need a fast way to disable that specific command on all the server
This command should only be working on the development server and only by contributors

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.