@@ -1,7 +1,7 @@
|
||||
TOKEN = YOUR_BOT_TOKEN
|
||||
CLIENT_ID = YOUR_BOT_CLIENT_ID
|
||||
CLIENT_SECRET_ID = YOUR_BOT_CLIENT_SECRET_ID
|
||||
SERCET_KEY = DASHBOARD_SERCET_KEY
|
||||
SECRET_KEY = DASHBOARD_SECRET_KEY
|
||||
|
||||
BUG_REPORT_CHANNEL_ID = YOUR_DISCORD_CHANNEL_ID
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ Start your bot with `python main.py`
|
||||
TOKEN = XXXXXXXXXXXXXXXXXXXXXXXX.XXXXXX.XXXXXXXXXXXXXXXXXXXXXXXXXXX
|
||||
CLIENT_ID = 123456789012345678
|
||||
CLIENT_SECRET_ID = XXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXX
|
||||
SERCET_KEY = DASHBOARD_SERCET_KEY
|
||||
SECRET_KEY = DASHBOARD_SECRET_KEY
|
||||
|
||||
BUG_REPORT_CHANNEL_ID = 123456789012345678
|
||||
|
||||
@@ -68,7 +68,7 @@ MONGODB_NAME = Vocard
|
||||
| TOKEN | Your Discord bot token [(Discord Portal)](https://discord.com/developers/applications) |
|
||||
| CLIENT_ID | Your Discord bot client id [(Discord Portal)](https://discord.com/developers/applications) |
|
||||
| CLIENT_SECRET_ID | Your Discord bot client secret id [(Discord Portal)](https://discord.com/developers/applications) ***(optional)*** |
|
||||
| SERCET_KEY | Secret key for dashboard ***(optional)*** |
|
||||
| SECRET_KEY | Secret key for dashboard ***(optional)*** |
|
||||
| BUG_REPORT_CHANNEL_ID | All the error messages will send to this text channel ***(optional)*** |
|
||||
| SPOTIFY_CLIENT_ID | Your Spoity client id [(Spotify Portal)](https://developer.spotify.com/dashboard/applications) ***(optional)*** |
|
||||
| SPOTIFY_CLIENT_SECRET | Your Spoity client sercret id [(Spotify Portal)](https://developer.spotify.com/dashboard/applications) ***(optional)*** |
|
||||
|
||||
@@ -25,7 +25,7 @@ class TOKENS:
|
||||
self.token = os.getenv("TOKEN")
|
||||
self.client_id = os.getenv("CLIENT_ID")
|
||||
self.client_secret_id = os.getenv("CLIENT_SECRET_ID")
|
||||
self.sercet_key = os.getenv("SERCET_KEY")
|
||||
self.secret_key = os.getenv("SECRET_KEY")
|
||||
self.bug_report_channel_id = int(os.getenv("BUG_REPORT_CHANNEL_ID"))
|
||||
self.spotify_client_id = os.getenv("SPOTIFY_CLIENT_ID")
|
||||
self.spotify_client_secret = os.getenv("SPOTIFY_CLIENT_SECRET")
|
||||
|
||||
2
main.py
2
main.py
@@ -33,7 +33,7 @@ class Vocard(commands.Bot):
|
||||
self,
|
||||
host=func.settings.ipc_server["host"],
|
||||
port=func.settings.ipc_server["port"],
|
||||
sercet_key=func.tokens.sercet_key
|
||||
secret_key=func.tokens.secret_key
|
||||
)
|
||||
|
||||
async def on_message(self, message: discord.Message, /) -> None:
|
||||
|
||||
@@ -4,12 +4,12 @@ Click on the image below to watch the tutorial on Youtube.
|
||||
[](https://youtu.be/5Y5GPO95uxE)
|
||||
|
||||
## Configuration
|
||||
1. **Fill in `CLIENT_SECRET_ID` and `SERCET_KEY` values in `.env`**
|
||||
1. **Fill in `CLIENT_SECRET_ID` and `SECRET_KEY` values in `.env`**
|
||||
|
||||
| Values | Description |
|
||||
| --- | --- |
|
||||
| CLIENT_SECRET_ID | Your Discord bot client secret id [(Discord Portal)](https://discord.com/developers/applications) ***(optional)*** |
|
||||
| SERCET_KEY | Secret key for dashboard ***(optional)*** |
|
||||
| SECRET_KEY | Secret key for dashboard ***(optional)*** |
|
||||
|
||||
2. **Add `ipc_server` configuration in `settings.json`**
|
||||
```json
|
||||
|
||||
@@ -40,7 +40,7 @@ class IPCClient:
|
||||
data = json.loads(message)
|
||||
|
||||
payload = {
|
||||
"sercet": self.secret_key,
|
||||
"secret": self.secret_key,
|
||||
"data": data | {"user_id": user.id, "guild_id": user.guild_id}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,20 +16,20 @@ class IPCServer:
|
||||
bot: commands.Bot,
|
||||
host: str = "127.0.0.1",
|
||||
port: int = 8000,
|
||||
sercet_key: Optional[str] = None
|
||||
secret_key: Optional[str] = None
|
||||
):
|
||||
self.bot = bot
|
||||
self.host = host
|
||||
self.port = port
|
||||
self.sercet_key = sercet_key
|
||||
self.secret_key = secret_key
|
||||
|
||||
self.user = {}
|
||||
self.connections = set()
|
||||
|
||||
def is_secure(self, data: dict) -> bool:
|
||||
if (key := data.get("sercet")):
|
||||
return str(key) == str(self.sercet_key)
|
||||
return bool(self.sercet_key is None)
|
||||
if (key := data.get("secret")):
|
||||
return str(key) == str(self.secret_key)
|
||||
return bool(self.secret_key is None)
|
||||
|
||||
async def start(self):
|
||||
try:
|
||||
|
||||
@@ -14,7 +14,7 @@ import functools
|
||||
load_dotenv()
|
||||
|
||||
app = Flask(__name__)
|
||||
app.secret_key = os.getenv("SERCET_KEY")
|
||||
app.secret_key = os.getenv("SECRET_KEY")
|
||||
socketio = SocketIO(app)
|
||||
|
||||
# Discord OAuth2 credentials
|
||||
|
||||
Reference in New Issue
Block a user