Skip to content

Commit 6531a0d

Browse files
authored
Merge branch 'master' into master
2 parents 7f216d7 + 4a3b6b7 commit 6531a0d

25 files changed

+1013
-249
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ jobs:
1111

1212
steps:
1313
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
14-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v3
1515

16-
- uses: actions/setup-python@v2
16+
- uses: actions/setup-python@v3
1717
with:
1818
python-version: '3.10.6'
1919

docker-compose.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,9 @@ services:
99
- "5432:5432"
1010
volumes:
1111
- database:/var/lib/postgresql/data
12-
lavalink:
13-
image: fredboat/lavalink:latest
14-
environment:
15-
LAVALINK_SERVER_PASSWORD: youshallnotpass
16-
SERVER_PORT: 2333
17-
SERVER_HOST: 0.0.0.0
1812
dozer:
1913
depends_on:
2014
- postgres
21-
- lavalink
2215
build: .
2316
volumes:
2417
- ".:/app"

docs/FTC.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
===============
2+
FTC Information
3+
===============
4+
ftc
5+
+++
6+
Get information on an FTC team from FTC-Events.
7+
If no subcommand is specified, the `team` subcommand is inferred, and the argument is taken as a team number.
8+
::
9+
`{prefix}ftc 5667` - show information on team 5667, Robominers
10+
team
11+
++++
12+
Get information on an FTC team by number.
13+
::
14+
`{prefix}ftc team 7244` - show information on team 7244, OUT of the BOX Robotics

docs/Shortcuts.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
=========
2+
Shortcuts
3+
=========
4+
settings
5+
++++++++
6+
Display the shortcut settings for the current server.
7+
::
8+
`{prefix}shortcuts settings` - display the shortcut settings for the current server
9+
setprefix
10+
+++++++++
11+
Set the prefix to be used to respond to shortcuts for the server.
12+
::
13+
`{prefix}shortcuts setprefix ^` - sets the server's shortcut prefix to "^"
14+
set
15+
+++
16+
Sets the reply for a given shortcut name, creating one if doesn't exist.
17+
::
18+
`{prefix}shortcuts set foo bar` - sets the shortcut named "foo" to send "bar"
19+
remove
20+
++++++
21+
Removes a shortcut from the server.
22+
::
23+
`{prefix}shortcuts remove foo` - removes the shortcut "foo" for the server
24+
list
25+
++++
26+
Lists the shortcuts for the server.
27+
::
28+
`{prefix}shortcuts list` - lists the shortcuts that exist for the server

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Welcome to Dozer's documentation!
1515
NameGame <NameGame.rst>
1616
News <News.rst>
1717
Roles <Roles.rst>
18+
Shortcuts <Shortcuts.rst>
1819
Starboard <Starboard.rst>
1920
TBA <TBA.rst>
2021
Teams <Teams.rst>

dozer/Components/CustomJoinLeaveMessages.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,31 @@ async def send_log(member):
2525
def format_join_leave(template: str, member: discord.Member):
2626
"""Formats join leave message templates
2727
{guild} = guild name
28-
{user} = user's name plus discriminator ex. SnowPlow#5196
29-
{user_name} = user's name without discriminator
28+
{user} = user's name
3029
{user_mention} = user's mention
3130
{user_id} = user's ID
3231
"""
3332
template = template or "{user_mention}\n{user} ({user_id})"
34-
return template.format(guild=member.guild, user=str(member), user_name=member.name,
35-
user_mention=member.mention, user_id=member.id)
3633

34+
subst = [("{guild}", member.guild.name),
35+
("{user}", member),
36+
("{user_mention}", member.mention),
37+
("{user_id}", member.id)]
38+
39+
def helper(s: str, subst: list):
40+
if not subst:
41+
# base case: return self
42+
return s
43+
cur = subst[0]
44+
# split the current string on cur[0].
45+
# for each split segment call the helper on the rest of the substitutions.
46+
# then rejoin on the substitutions (this avoids the substituted values from matching substitution keywords)
47+
48+
# we could make this not recursive but there's an O(1) number of possible recursions anyway
49+
# recursion depth is limited to 5 since the subst list is limited
50+
# breadth is limited by template size (indirectly limited by discord message size)
51+
return str(cur[1]).join([helper(bit, subst[1:]) for bit in s.split(cur[0])])
52+
return helper(template, subst)
3753

3854
class CustomJoinLeaveMessages(db.DatabaseTable):
3955
"""Holds custom join leave messages"""

dozer/__main__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
'key': 'Put TOA API key here',
2222
'app_name': 'Dozer',
2323
},
24+
'ftc-events': {
25+
'username': 'Put FTC-Events username here',
26+
'token': 'Put FTC-Events token here'
27+
},
2428
'db_url': 'postgres://dozer_user:simplepass@postgres',
2529
'gmaps_key': "PUT GOOGLE MAPS API KEY HERE",
2630
'discord_token': "Put Discord API Token here.",

dozer/cogs/actionlogs.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ async def on_raw_message_edit(self, payload: discord.RawMessageUpdateEvent):
300300
embed = discord.Embed(title="Message Edited",
301301
description=f"[MESSAGE]({link}) From {mention}\nEdited In: {mchannel.mention}",
302302
color=0xFFC400)
303-
embed.set_author(name=f"{author['username']}#{author['discriminator']}", icon_url=avatar_link)
303+
embed.set_author(name=f"{author['username']}{'#' + author['discriminator'] if author['discriminator'] != '0' else ''}", icon_url=avatar_link)
304304
embed.add_field(name="Original", value="N/A", inline=False)
305305
if content:
306306
embed.add_field(name="Edited", value=content[0:1023], inline=False)
@@ -547,8 +547,7 @@ async def help(self,
547547
e.set_footer(text='Triggered by ' + escape_markdown(ctx.author.display_name))
548548
e.description = """
549549
`{guild}` = guild name
550-
`{user}` = user's name plus discriminator ex. SnowPlow#5196
551-
`{user_name}` = user's name without discriminator
550+
`{user}` = user's name
552551
`{user_mention}` = user's mention
553552
`{user_id}` = user's ID
554553
"""

dozer/cogs/development.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ def load_function(code: str, globals_, locals_):
144144
try:
145145
exec(function_header + '\n\treturn ' + lines[0], globals_, locals_)
146146
except SyntaxError as err: # Either adding the 'return' caused an error, or it's user error
147+
err.offset = int(err.offset)
147148
if err.text[err.offset - 1] == '=' or err.text[err.offset - 3:err.offset] == 'del' \
148149
or err.text[err.offset - 6:err.offset] == 'return': # return-caused error
149150
exec(function_header + '\n\t' + lines[0], globals_, locals_)

0 commit comments

Comments
 (0)