-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
25 lines (18 loc) · 762 Bytes
/
test.py
File metadata and controls
25 lines (18 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from hackchat.bot import BotChannel, Arg
from base64 import b64encode, b64decode
channel = BotChannel(prefix='!', name='testbot')
@channel.command(
name='encode',
description='encode a string in base64',
args=[Arg(name='string', description='the string to encode', required=True)]
)
async def base64encode(string: str):
await channel.send('Encoded: {}'.format(b64encode(string.encode()).decode()))
@channel.command(
name='decode',
description='decode a base64 encoded string',
args=[Arg(name='string', description='the string to decode', required=True)]
)
async def base64decode(string: str):
await channel.send('Decoded: {}'.format(b64decode(string.encode()).decode()))
channel.join(nick='BlueBot')