From 1397d84545563d7f8b7b76784bcc6d485832f4b6 Mon Sep 17 00:00:00 2001 From: Uwe Pfeifer Date: Wed, 7 May 2025 08:00:40 +0200 Subject: [PATCH 1/4] - Added initial instructions to README - Changed few other things. --- README.md | 5 ++++- pybot-f.py | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e5fb195..b9ea465 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,9 @@ Check by from time to time to see what has changed. :) # Installation 1. Check that you create a venv and then install requirements.txt in there. + - python3 -m venv venv + - Linux: source venv/bin/activate + - pip install -r requirements.txt 2. Then edit the bot.ini.example and move it to bot.ini . 3. Run the bot by using your venv interpreter. @@ -18,4 +21,4 @@ If you find a bug or have a feature request, visit https://code.nextgamers.eu/fr If you don't want to load the example extensions, just move them to some other ending (not .py). # Note -A better description and HowTo will follow someday, maybe in the wiki. :) \ No newline at end of file +A better description and HowTo will follow someday, maybe in the wiki. :) diff --git a/pybot-f.py b/pybot-f.py index 91c20e2..107ffd2 100644 --- a/pybot-f.py +++ b/pybot-f.py @@ -8,6 +8,7 @@ import typing from discord.ext import commands import logging + # Logging loghandler = logging.FileHandler(filename='bot.log', encoding='utf-8', mode='w') discord.utils.setup_logging(handler=loghandler) @@ -33,6 +34,7 @@ config.read('bot.ini') bottoken = config['General']['bottoken'] + # Setting up commands.Bot bot = commands.Bot(command_prefix='.', description=description, intents=intents) From d33f8ebc1a393f1a5a14c8f52d79b7f6a5bce3e0 Mon Sep 17 00:00:00 2001 From: Uwe Pfeifer Date: Wed, 7 May 2025 08:13:46 +0200 Subject: [PATCH 2/4] - Moved all extension files to .example to not load them by default. - Added and changed stuff in README --- ext/{administration.py => administration.py.example} | 0 ext/{test.py => test.py.example} | 0 ext/test2.py => test2.py.example | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename ext/{administration.py => administration.py.example} (100%) rename ext/{test.py => test.py.example} (100%) rename ext/test2.py => test2.py.example (100%) diff --git a/ext/administration.py b/ext/administration.py.example similarity index 100% rename from ext/administration.py rename to ext/administration.py.example diff --git a/ext/test.py b/ext/test.py.example similarity index 100% rename from ext/test.py rename to ext/test.py.example diff --git a/ext/test2.py b/test2.py.example similarity index 100% rename from ext/test2.py rename to test2.py.example From 4fc76b4dfd3aca1199baa5ae92ca1412b80ac43a Mon Sep 17 00:00:00 2001 From: Uwe Pfeifer Date: Wed, 7 May 2025 08:35:57 +0200 Subject: [PATCH 3/4] - Added more things to the README - Experimental change of logging --- README.md | 20 +++++++++++++++----- pybot-f.py | 19 +++++++++++++++++-- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b9ea465..bbf4232 100644 --- a/README.md +++ b/README.md @@ -12,13 +12,23 @@ Check by from time to time to see what has changed. :) - python3 -m venv venv - Linux: source venv/bin/activate - pip install -r requirements.txt -2. Then edit the bot.ini.example and move it to bot.ini . -3. Run the bot by using your venv interpreter. +2. Visit https://discordpy.readthedocs.io/en/latest/discord.html to read about how to create a bot on the Discord Website. +3. Then make a copy of bot.ini.example and name it "bot.ini". Edit the file. +4. Run the bot inside the venv. + - Make sure u're inside the venv. + - Now: python3 pybot-f.py +5. Invite the bot to your server using the provided link after successfully starting the bot. # Bugs If you find a bug or have a feature request, visit https://code.nextgamers.eu/freaky/pybot-f/issues . -If you don't want to load the example extensions, just move them to some other ending (not .py). +# Extensions +- Extensions are how you create "plugins/modules" for the bot to provide additional features. There are some .example extension files in + the ext/ folder. +- If you need more information visit https://discordpy.readthedocs.io/en/latest/index.html#extensions and read about extensions there. +- The jishaku extension is always loaded and downloaded from the network on requirement.txt updates. The module provides administration commands. + it is not written by me. -# Note -A better description and HowTo will follow someday, maybe in the wiki. :) +# Notes +- There is a .gitignore which ignores things like bot.ini and bot.log with git so passwords and logs are not getting commited to git. +- A better description and HowTo will follow someday, maybe in the wiki. :) diff --git a/pybot-f.py b/pybot-f.py index 107ffd2..bee0bf2 100644 --- a/pybot-f.py +++ b/pybot-f.py @@ -7,11 +7,26 @@ import asyncio import typing from discord.ext import commands import logging +from logging import handlers # Logging -loghandler = logging.FileHandler(filename='bot.log', encoding='utf-8', mode='w') -discord.utils.setup_logging(handler=loghandler) +#loghandler = logging.FileHandler(filename='bot.log', encoding='utf-8', mode='w') +#discord.utils.setup_logging(handler=loghandler) + +logger = logging.getLogger('discord') +logger.setLevel(logging.INFO) + +loghandler = logging.handlers.RotatingFileHandler( + filename='bot.log', + encoding='utf-8', + maxBytes=32 * 1024 * 1024, # 32 MiB + backupCount=5, # Rotate through 5 files +) +dt_fmt = '%Y-%m-%d %H:%M:%S' +formatter = logging.Formatter('[{asctime}] [{levelname:<8}] {name}: {message}', dt_fmt, style='{') +loghandler.setFormatter(formatter) +logger.addHandler(loghandler) # logger = logging.getLogger('discord') # logger.setLevel(logging.INFO) From 2013b29c8bbcfe021fdd2e9bc3d62713398d3120 Mon Sep 17 00:00:00 2001 From: Uwe Pfeifer Date: Wed, 7 May 2025 08:57:30 +0200 Subject: [PATCH 4/4] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bbf4232..dd6cbae 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,9 @@ If you find a bug or have a feature request, visit https://code.nextgamers.eu/fr - Extensions are how you create "plugins/modules" for the bot to provide additional features. There are some .example extension files in the ext/ folder. - If you need more information visit https://discordpy.readthedocs.io/en/latest/index.html#extensions and read about extensions there. -- The jishaku extension is always loaded and downloaded from the network on requirement.txt updates. The module provides administration commands. +- The Jishaku extension is always loaded and downloaded from the network on requirement.txt updates. The module provides administration commands. it is not written by me. +- Jishaku Documentation: https://jishaku.readthedocs.io/en/latest/index.html # Notes - There is a .gitignore which ignores things like bot.ini and bot.log with git so passwords and logs are not getting commited to git.