Coverage for cmds/echo.py: 53%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2echo.py
4contains echo() and echoa()
5"""
7import datetime
8import error
9import database
11async def echo(message, *args):
12 """
13 echo()
15 echos message
16 """
18 # check for arguments:
19 if args:
20 return f"`{message.author}:` {' '.join(args)}"
22 raise error.ArgumentRequiredError
24async def echoa(message, *args):
25 """
26 echoa()
28 echos message anonymously
29 """
31 # get admins from database
32 admins = database.get("admins")
34 # check for priviledges
35 if any([
36 str(message.author.id) in admins,
37 message.channel.permissions_for(message.author).administrator,
38 ]):
40 if args:
41 database.write("echoa", str(message.id), string='\n'.join([
42 f"{datetime.datetime.now()}",
43 f"{message.guild.id}: {message.guild.name}",
44 f"{message.channel.id}: {message.channel.name}",
45 f"{message.author.id}: {message.author}",
46 f"{' '.join(args)}",
47 ]))
48 return ' '.join(args)
50 raise error.ArgumentRequiredError
52 raise error.AuthorisationError