- Added more things to the README
- Experimental change of logging
This commit is contained in:
parent
d33f8ebc1a
commit
4fc76b4dfd
2 changed files with 32 additions and 7 deletions
20
README.md
20
README.md
|
@ -12,13 +12,23 @@ Check by from time to time to see what has changed. :)
|
||||||
- python3 -m venv venv
|
- python3 -m venv venv
|
||||||
- Linux: source venv/bin/activate
|
- Linux: source venv/bin/activate
|
||||||
- pip install -r requirements.txt
|
- pip install -r requirements.txt
|
||||||
2. Then edit the bot.ini.example and move it to bot.ini .
|
2. Visit https://discordpy.readthedocs.io/en/latest/discord.html to read about how to create a bot on the Discord Website.
|
||||||
3. Run the bot by using your venv interpreter.
|
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
|
# Bugs
|
||||||
If you find a bug or have a feature request, visit https://code.nextgamers.eu/freaky/pybot-f/issues .
|
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
|
# Notes
|
||||||
A better description and HowTo will follow someday, maybe in the wiki. :)
|
- 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. :)
|
||||||
|
|
19
pybot-f.py
19
pybot-f.py
|
@ -7,11 +7,26 @@ import asyncio
|
||||||
import typing
|
import typing
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
import logging
|
import logging
|
||||||
|
from logging import handlers
|
||||||
|
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
loghandler = logging.FileHandler(filename='bot.log', encoding='utf-8', mode='w')
|
#loghandler = logging.FileHandler(filename='bot.log', encoding='utf-8', mode='w')
|
||||||
discord.utils.setup_logging(handler=loghandler)
|
#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 = logging.getLogger('discord')
|
||||||
# logger.setLevel(logging.INFO)
|
# logger.setLevel(logging.INFO)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue