aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Marko Kovačević <[email protected]>2018-10-02 20:41:07 +0200
committerGravatar Marko Kovačević <[email protected]>2018-10-02 20:41:07 +0200
commita30b4a5412a0e88ac37ae5f524b03886a997dd7c (patch)
treefa022a1ded17150139d1eedaa82f269bd1df7f37
parentCreate CONTRIBUTING.md (diff)
Implemented flake8 and a Discord Bot base.
-rw-r--r--bot/bot.py21
-rw-r--r--bot/constants.py1
-rw-r--r--requirements-dev.txt5
-rw-r--r--requirements.txt10
-rw-r--r--tox.ini6
5 files changed, 43 insertions, 0 deletions
diff --git a/bot/bot.py b/bot/bot.py
new file mode 100644
index 00000000..0813eb54
--- /dev/null
+++ b/bot/bot.py
@@ -0,0 +1,21 @@
+from pathlib import Path
+from sys import stderr
+from traceback import print_exc
+
+
+from bot import constants
+from discord.ext import commands
+
+
+bot = commands.Bot(command_prefix=commands.when_mentioned_or('!'))
+
+if __name__ == '__main__':
+ cogs = [x.stem for x in Path('cogs').glob('*.py')]
+ for extension in cogs:
+ try:
+ bot.load_extension(f'cogs.{extension}')
+ except Exception as e:
+ print(f'Failed to load extension {extension}.', file=stderr)
+ print_exc()
+
+bot.run(constants.token)
diff --git a/bot/constants.py b/bot/constants.py
new file mode 100644
index 00000000..f2376c4d
--- /dev/null
+++ b/bot/constants.py
@@ -0,0 +1 @@
+token = ''
diff --git a/requirements-dev.txt b/requirements-dev.txt
new file mode 100644
index 00000000..bdc6b391
--- /dev/null
+++ b/requirements-dev.txt
@@ -0,0 +1,5 @@
+flake8
+flake8-bugbear
+flake8-bandit
+flake8-import-order
+flake8-tidy-imports
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 00000000..850f73bb
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1,10 @@
+aiohttp==3.4.4
+async-timeout==3.0.0
+attrs==18.2.0
+chardet==3.0.4
+discord.py==1.0.0a0
+idna==2.7
+idna-ssl==1.1.0
+multidict==4.4.2
+websockets==6.0
+yarl==1.2.6 \ No newline at end of file
diff --git a/tox.ini b/tox.ini
new file mode 100644
index 00000000..780c31d7
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,6 @@
+[flake8]
+max-line-length=120
+application_import_names=proj
+ignore=P102,B311,W503,E226,S311
+exclude=__pycache__, venv, .venv, tests
+import-order-style=pycharm