ertondev / add-web Goto Github PK
View Code? Open in Web Editor NEWDiscord server related website and other important scripts related to the project.
Discord server related website and other important scripts related to the project.
I'm currently programming the Control Unit Monitor, or Control Center, to display important values that my bot works with. My idea is to make a selector to move across data in our database, and the way to do that was by using keys. Sadly, I don't know how to do that.
I've been reading the pynput
module docs to find some information about this and I've tried lots of different things, but none worked as I expected.
The program should be able to call one function when w
is pressed and a different one when s
is pressed.
We should change the name of the HOST env variable to DBHOST to avoid problems with windows.
Heroku did maintenance on all their databases which changed our credentials.
The bot needs to start using information online so we must setup the postgreSQL db. I've deployed the db in a Heroku server and the API is working. We should "rewrite" the bot1.py files to work with the db.
Because post
, get
and put
no longer exist in psqlapi.py
we must change this import code to import each function with its respective new name.
I think we should change the name of the server in the website code to ADD instead of "A" del Discord. The original name isn't serious and now that the project is public we should keep this in mind. I will be doing this as soon as possible, but anyone can do it.
When we did the update to support the database we forgot that we were no longer working with lists, but with individual values. I'm going to upload a version of the bot files where we haven't tried anything to fix the issue yet, this way we can easily fix the lists problem.
For some reason autodatabase.py
is raising errors when trying to upload data from our .txt
files to DB. We have updated the users
table from our DB and we need to use this file to reupload all the information.
Line 1120 of bot1.py:
allowed = lvl.check_license(ctx, 1)
I think that lvl_num (1) should be 4 because of how licences are supposed to work in the game.
Because we are hosting our database in Heroku, I think that hosting the bot there would be a good idea too.
I'm leaving here a link for a site that may be useful for this issue: https://medium.com/@linda0511ny/create-host-a-discord-bot-with-heroku-in-5-min-5cb0830d0ff2
At the moment we are still tweaking some of the new features as well as fixing some bugs.
You can see more in:
#8 - BOT connection to the PostgreSQL database.
When I programmed the bot I thought of using .txt
files as a database. This has worked fine but now we need to have this information online. This is why we must change all the code related to the .txt
files and implement the API where it is needed.
We have already programmed different scripts to make this easier, this is a closed issue that may be useful:
#5 - Automatize database update process
There is some data that I would like to keep as .txt
files (multas.txt, and other files related to the casino/ games)
, if you would like a more detailed description leave a comment.
The code that we should change is the one related to bolsa/
and profile/
:
file = io.open("path/file.txt", "r") # r to read, w to write, a to append
file_content = file.readlines()
file.close()
This code got the lines of file.txt
:
print(file_content[0])
>>> line_1
print(file_content[1])
>>> line_2
...
print(file_content[i])
>>> line_i+1
Basically the bot wrote or updated data in files to then read that same information.
You will also have to change the code where the bot creates new profiles:
create_profile = os.makedirs(f"profile/{ctx.author.id}_profile", exists_ok = True)
You can look at this in line 899 (29/11/2021 9:50, 11/29/2021 9:50)
The new code should use our API located inside the web/
folder. This was programmed by @MarcBen05
Import it as a module:
from web.psqlapi import *
Then you can start rewriting the code! :)
LEAVE A COMMENT IF YOU HAVE ANY QUESTION
There has been an update to the API but we haven't tried it yet.
To do this we should create a script with python that does this automatically.
All the information that must be updated to the database is on the add-web/profile/
and add-web/bolsa/
.
Some of the information in these files are outdated but should help to start coding the script.
The script should be able to be executable at any time and it would update all the values of accounts and in-game values.
You can use the psqlapi.py
file to import useful functions from there. These functions will allow you to connect with the database. Take into account that you will also need the environment variables for this so send me a msg as soon as you want to test the code.
The script should be properly written to make it easily updatable in the future. To make the psqlapi.py
script run properly you will need to create a .env
file in the same folder as the script (add-web/web/
) and write on it the environmental variables used for:
HOST = ...
DBUSER = ...
PASS = ...
DBNAME = ...
import psqlapi.py
or
from psqlapi.py import ...
In case you don't create the automation file inside of the add-web/web/
folder and do it in add-web/
instead:
import web.psqlapi.py
or
from web.psqlapi.py import ...
I would recommend reading psqlapi.py
before starting to write the automation script.
You will also need to use the io
module to read .txt
files using the open()
function.
import io
Here is an example for reading files:
file = io.open("path/to/file/file.txt", 'r')
file_lines = file.readlines()
file.close()
Remember to always close the file, then you can print each line of the file, here is an example:
file.txt
ABC
CBA
123
Your script
for i in range(3):
print(i + 1, file_lines[i])
# 0, 1, 2
The output should look like this:
1 ABC
2 CBA
3 123
If you have any issue with the explanation leave a comment :)
Passwords aren't something crucial for the project, but if we add functions to delete accounts, then that should be protected.
First our database and API must be adapted and then .registro
in bot.py
has to be updated to support the input of the password but in a private way. (Probably through MD)
Error message:
Error: While importing 'app', an ImportError was raised
I think this has something to do with flask being unable to import the libraries from venv. If anyone knows how to fix this issue, please send a Pull request. It works if you download all the libraries in your computer but doesn't if you don't. The idea is that flask gets the libraries from the venv.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.