Schneider
7 years ago
commit
bcd30226b7
2 changed files with 155 additions and 0 deletions
-
104.gitignore
-
51bot.py
@ -0,0 +1,104 @@ |
|||
# Byte-compiled / optimized / DLL files |
|||
__pycache__/ |
|||
*.py[cod] |
|||
*$py.class |
|||
|
|||
# C extensions |
|||
*.so |
|||
|
|||
# Distribution / packaging |
|||
.Python |
|||
build/ |
|||
develop-eggs/ |
|||
dist/ |
|||
downloads/ |
|||
eggs/ |
|||
.eggs/ |
|||
lib/ |
|||
lib64/ |
|||
parts/ |
|||
sdist/ |
|||
var/ |
|||
wheels/ |
|||
*.egg-info/ |
|||
.installed.cfg |
|||
*.egg |
|||
MANIFEST |
|||
|
|||
# PyInstaller |
|||
# Usually these files are written by a python script from a template |
|||
# before PyInstaller builds the exe, so as to inject date/other infos into it. |
|||
*.manifest |
|||
*.spec |
|||
|
|||
# Installer logs |
|||
pip-log.txt |
|||
pip-delete-this-directory.txt |
|||
|
|||
# Unit test / coverage reports |
|||
htmlcov/ |
|||
.tox/ |
|||
.coverage |
|||
.coverage.* |
|||
.cache |
|||
nosetests.xml |
|||
coverage.xml |
|||
*.cover |
|||
.hypothesis/ |
|||
|
|||
# Translations |
|||
*.mo |
|||
*.pot |
|||
|
|||
# Django stuff: |
|||
*.log |
|||
.static_storage/ |
|||
.media/ |
|||
local_settings.py |
|||
|
|||
# Flask stuff: |
|||
instance/ |
|||
.webassets-cache |
|||
|
|||
# Scrapy stuff: |
|||
.scrapy |
|||
|
|||
# Sphinx documentation |
|||
docs/_build/ |
|||
|
|||
# PyBuilder |
|||
target/ |
|||
|
|||
# Jupyter Notebook |
|||
.ipynb_checkpoints |
|||
|
|||
# pyenv |
|||
.python-version |
|||
|
|||
# celery beat schedule file |
|||
celerybeat-schedule |
|||
|
|||
# SageMath parsed files |
|||
*.sage.py |
|||
|
|||
# Environments |
|||
.env |
|||
.venv |
|||
env/ |
|||
venv/ |
|||
ENV/ |
|||
env.bak/ |
|||
venv.bak/ |
|||
|
|||
# Spyder project settings |
|||
.spyderproject |
|||
.spyproject |
|||
|
|||
# Rope project settings |
|||
.ropeproject |
|||
|
|||
# mkdocs documentation |
|||
/site |
|||
|
|||
# mypy |
|||
.mypy_cache/ |
@ -0,0 +1,51 @@ |
|||
#! /usr/bin/env python3 |
|||
""" |
|||
Code for schneiderbot |
|||
""" |
|||
import os |
|||
import datetime |
|||
|
|||
import discord |
|||
from discord.ext import commands |
|||
|
|||
DESCRIPTION = '''Schneiderbot, bald mit tollen Funktionen''' |
|||
BOT = commands.Bot(command_prefix='!', description=DESCRIPTION) |
|||
MENSA_URL = { |
|||
"zentral": "zentralmensa", |
|||
"nord": "nordmensa" |
|||
} |
|||
|
|||
@BOT.event |
|||
async def on_ready(): |
|||
""" On ready """ |
|||
print('Logged in as') |
|||
print(BOT.user.name) |
|||
print(BOT.user.id) |
|||
print('------') |
|||
|
|||
@BOT.command() |
|||
async def hello(): |
|||
"""Says world""" |
|||
await BOT.say("world") |
|||
|
|||
@BOT.command() |
|||
async def mensa(which="zentral"): |
|||
"""Gibt leckere, äh, nützliche Infos über die Mensa aus. |
|||
Standardmäßig für die Zentralmensa, aber probier auch mal nord aus.""" |
|||
|
|||
today = datetime.datetime.now().date().weekday() + 1 |
|||
if datetime.datetime.now().time() > datetime.time(hour=16): |
|||
# Es ist zu spät am Tag, zeig das essen für morgen an |
|||
today += 1 |
|||
|
|||
await BOT.say("""Hallo, ich bin ein Bot. |
|||
Hier gibt es tolle Infos über das Essen in der Mensa: |
|||
https://mensa.schneider-hosting.de/%s/%d |
|||
Mhmm, lecker. Guten Appetit!""" % (MENSA_URL[which], today)) |
|||
|
|||
def main(): |
|||
""" entry point """ |
|||
BOT.run(os.environ['SCHNEIDERBOT_TOKEN']) |
|||
|
|||
if __name__ == '__main__': |
|||
main() |
Write
Preview
Loading…
Cancel
Save
Reference in new issue