add !joke command
This commit is contained in:
parent
c7e953743d
commit
27eb77022b
|
|
@ -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.
|
||||
```
|
||||
|
|
|
|||
6
bot.py
6
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',))
|
||||
|
||||
|
|
|
|||
|
|
@ -2,3 +2,4 @@ aiohttp
|
|||
aiosqlite
|
||||
async-lru
|
||||
humanize
|
||||
pyjokes
|
||||
|
|
|
|||
Loading…
Reference in New Issue