11 Commits

Author SHA1 Message Date
Klemek d81b143a3f update requirements.txt 2022-09-02 09:53:09 +02:00
Klemek ef23f07479 Merge remote-tracking branch 'origin/dev' 2022-09-02 09:45:30 +02:00
Klemek 30fb36d61a 2.0 miniscord with message content intent 2022-09-02 09:38:53 +02:00
Klemek fffbc08a82 Merge branch 'dev' of github.com:klemek/miniscord into dev 2022-08-23 09:27:54 +02:00
Klemek b13e574427 Merge branch 'master' of github.com:klemek/miniscord 2022-08-23 09:27:32 +02:00
Klemek 0ed3072b44 fix guild size 2022-08-23 09:27:06 +02:00
Klemek f335f193b8 Merge pull request #7 from Klemek/dev
Dev
2021-04-09 00:47:31 +02:00
Klemek aba1b10ef1 Update python.yml 2021-04-09 00:46:19 +02:00
Klemek daaededd19 Update python.yml 2021-04-09 00:42:34 +02:00
Klemek ac7d4a1191 Merge pull request #6 from Klemek/dev
Update README.md
2021-04-09 00:25:44 +02:00
Klemek 16e1cade57 Update README.md 2021-04-09 00:25:24 +02:00
5 changed files with 17 additions and 16 deletions
+4 -7
View File
@@ -1,4 +1,4 @@
name: Test name: Python
on: ["push", "pull_request"] on: ["push", "pull_request"]
@@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
python-version: [3.8, 3.9] python-version: [3.7, 3.8, 3.9]
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }} - name: Set up Python ${{ matrix.python-version }}
@@ -17,16 +17,13 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: | run: |
python -m pip install --upgrade pip python -m pip install --upgrade pip
python -m pip install flake8 black python -m pip install flake8
- name: Lint with flake8 - name: Lint with flake8
run: | run: |
# stop the build if there are Python syntax errors or undefined names # stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Code style with black
run: |
black --check
test: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
@@ -49,4 +46,4 @@ jobs:
run: coveralls run: coveralls
env: env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+2 -1
View File
@@ -192,7 +192,7 @@ The function must be exactly named after the event
```python ```python
async def on_ready() -> bool: async def on_ready() -> bool:
print("on_ready") print("on_ready")
return False # if True is returned, prevent miniscord handling of the event return True # if False is returned, prevent miniscord's handling of the event
bot.register_event(on_ready) bot.register_event(on_ready)
``` ```
@@ -344,6 +344,7 @@ bot.start() # this bot respond to "|help", "|info" and "|hello"
## Versions ## Versions
* v0.1.0 : Discord v2 API with intents
* v0.0.3 : custom events handling * v0.0.3 : custom events handling
* v0.0.2 : new answer capability * v0.0.2 : new answer capability
* v0.0.1 : initial version * v0.0.1 : initial version
+9 -6
View File
@@ -59,11 +59,14 @@ class Bot(object):
self.__commands = [] self.__commands = []
self.__fallback = None self.__fallback = None
self.__events = {} self.__events = {}
self.games = [f"v{version}", lambda: f"{len(self.client.guilds)} guilds"] self.games = [f"v{version}", lambda: f"{len(self.guilds)} guilds"]
if self.alias is not None: if self.alias is not None:
self.games += [f"{self.alias}help"] self.games += [f"{self.alias}help"]
self.client = discord.Client() intents = discord.Intents.default()
intents.message_content = True
self.client = discord.Client(intents=intents)
self.client.bot = self self.client.bot = self
self.guilds = []
self.__register_events() self.__register_events()
self.__register_commands() self.__register_commands()
@@ -106,7 +109,7 @@ class Bot(object):
f"```\n" f"```\n"
f"{self.app_name} v{self.version}\n" f"{self.app_name} v{self.version}\n"
f"* Started at {self.__t0:%Y-%m-%d %H:%M}\n" f"* Started at {self.__t0:%Y-%m-%d %H:%M}\n"
f"* Connected to {len(self.client.guilds)} guilds\n" f"* Connected to {len(self.guilds)} guilds\n"
f"```", f"```",
reference=message if self.answer else None, reference=message if self.answer else None,
mention_author=self.answer_mention, mention_author=self.answer_mention,
@@ -154,15 +157,15 @@ class Bot(object):
async def on_ready(self, *args): async def on_ready(self, *args):
if await self.__handle_event("on_ready", args): if await self.__handle_event("on_ready", args):
return return
self.guilds = [guild async for guild in self.client.fetch_guilds(limit=1000)]
# Change status # Change status
logging.info( logging.info(
f"{self.client.user} (v{self.version}) has connected to {len(self.client.guilds)} Discord guilds" f"{self.client.user} (v{self.version}) has connected to {len(self.guilds)} Discord guilds"
) )
if self.guild_logs_file is not None and not os.path.exists( if self.guild_logs_file is not None and not os.path.exists(
self.guild_logs_file self.guild_logs_file
): ):
for guild in self.client.guilds: for guild in self.guilds:
await self.on_guild_join(guild) await self.on_guild_join(guild)
while True: while True:
await self.client.change_presence( await self.client.change_presence(
+1 -1
View File
@@ -1,2 +1,2 @@
discord.py discord.py>=2.0.0
python-dotenv python-dotenv
+1 -1
View File
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
setuptools.setup( setuptools.setup(
name="miniscord-Klemek", name="miniscord-Klemek",
version="0.0.3", version="0.1.0",
author="Klemek", author="Klemek",
description="A minimalist discord bot API", description="A minimalist discord bot API",
long_description=long_description, long_description=long_description,