diff --git a/README.md b/README.md index 0b7d872..953da45 100644 --- a/README.md +++ b/README.md @@ -100,3 +100,12 @@ anthonywritescodebot: cool_user has been following for 3 hours! some_user: !followage another_user anthonywritescodebot: another_user has been following for 5 years! ``` + +### `!joke` + +Get a joke + +``` +anthonywritescode: !joke +anthonywritescodebot: The best thing about a Boolean is even if you are wrong, you are only off by a bit. +``` diff --git a/bot.py b/bot.py index 951a707..c75147c 100644 --- a/bot.py +++ b/bot.py @@ -25,6 +25,7 @@ from typing import Tuple import aiohttp import aiosqlite import async_lru +import pyjokes from humanize import naturaldelta # TODO: allow host / port to be configurable @@ -507,6 +508,11 @@ def cmd_pep(match: Match[str]) -> Response: return MessageResponse(match, f'https://www.python.org/dev/peps/pep-{n}/') +@handle_message('!joke') +def cmd_joke(match: Match[str]) -> Response: + return MessageResponse(match, esc(pyjokes.get_joke())) + + COMMAND_RE = re.compile(r'!\w+') SECRET_CMDS = frozenset(('!settoday',)) diff --git a/requirements.txt b/requirements.txt index 8fa846b..433ed7a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ aiohttp aiosqlite async-lru humanize +pyjokes