Skip to content

Commit

Permalink
Use highest hoisted role as default tag, resolves #3014
Browse files Browse the repository at this point in the history
  • Loading branch information
fourjr committed Aug 7, 2021
1 parent fe11759 commit 1a885bc
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 8 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
This project mostly adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html);
however, insignificant breaking changes do not guarantee a major version bump, see the reasoning [here](https://github.com/kyb3r/modmail/issues/319). If you're a plugin developer, note the "BREAKING" section.

# v3.10.0-dev4
# v3.10.0-dev5

v3.10 adds group conversations while resolving othre bugs and QOL changes. It is potentially breaking to some plugins that adds functionality to threads.

Expand All @@ -18,6 +18,7 @@ v3.10 adds group conversations while resolving othre bugs and QOL changes. It is

- Ability to have group conversations. ([GH #143](https://github.com/kyb3r/modmail/issues/143))
- Snippets are invoked case insensitively. ([GH #3077](https://github.com/kyb3r/modmail/issues/3077), [PR #3080](https://github.com/kyb3r/modmail/pull/3080))
- Default tags now use top hoisted role. ([GH #3014](https://github.com/kyb3r/modmail/issues/3014))

## Fixed

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<br>

<a href="#">
<img src="https://img.shields.io/badge/Latest%20Version-v3.10.0-dev4-7289da?style=for-the-badge&logo=data:image/gif;base64,R0lGODlhGAAYAPcAAAAAADQ+Yj5MdThCaEFOekNQfWt5e1lqfEdVhVpriVx1iVtsnFZpll1xlF1znFx5mGNtjGR7hWNzjGd5iWJunGNslmN0lGl1lGN5lWt7lWR0nGp1nWR5nGt8nHJ9l3J9jFxto1xtqlZqqF5zpF15pV10rVx5q1Z2ql1us150s114sV50uVd1smJupGNurGN0pGp1pGR6o2t7o2F0rml0rGR5rGt8q3J9pGN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WiEqqq64ifvVe3at1nX2tTuWQ/QyIMfxHOGi+rkyeMklPMDuvWaBqlbj469IPUU2ykPCOw+53t4AAEBADs=">
<img src="https://img.shields.io/badge/Latest%20Version-v3.10.0-dev5-7289da?style=for-the-badge&logo=data:image/gif;base64,R0lGODlhGAAYAPcAAAAAADQ+Yj5MdThCaEFOekNQfWt5e1lqfEdVhVpriVx1iVtsnFZpll1xlF1znFx5mGNtjGR7hWNzjGd5iWJunGNslmN0lGl1lGN5lWt7lWR0nGp1nWR5nGt8nHJ9l3J9jFxto1xtqlZqqF5zpF15pV10rVx5q1Z2ql1us150s114sV50uVd1smJupGNurGN0pGp1pGR6o2t7o2F0rml0rGR5rGt8q3J9pGNus2Fvu2Bzs2p2smR5s2t7tGF0u2N6vGp7u2l1uXJ+uGJ1wWV7w2l+xWl+yl5zwHWDiWyCmHODnHiGmHSLkW2CpGuEqnSCpHqMo3ODrHWKrXyMq3iHp3yTqGyEtWqFunKDs3uLtHSGvXSMvHuMu3eItnyTs3yTu3iUuW+RsV+ApmuCxG2Dy22LxnSMxHuMxHGGzXSLzXqLzXWFxXyTw3uSy3WSx26E0W+N2m+L1XKG03SL1XmL1HOL2HmL23WF2XiS1m+QyHOK4XmL4XaH4nGM5ImXm4WOlJSjnoOOq4OOpYSUrImXqJOcqYONt4OUtIybtIOUu4ycvImYt5OcuIyiqZekqYyiupOjvJurvJimtp+yvqKruae2ua23trLCucPHvIOMxoOUxIuaw4eYyJKbyISW1YiW0o2kyJWlxJqpxZWkzJury5aoxp6xxZ2zyZio1Jyy2Yuk0aOsyKOyxKOzzKy8zKq2yLO7xqOr1KSz1Ku706W026y73Ki21bK716u75LS95KSu4Zyx6bPDzLjGx63B2LPD1LTE3LvL3brI17/S2bbKzrTE47rF47zM5L3M67bH577R5L7R67zK8rjM8MLM3MPK1sTT3crU3MjW2dLZ2srUy8PN5MTO68nP68jL48TS5MnT5cbR68jS7M3b7Mva5dTb6MTO8srO8szF8MXR8snS8c3a8cnY+NXb9tDL7dnm6dzk8tro99Pq9uTp6+r17fr77eTr/efr+Oz09OXz/Ov0/e37/uj39fX19fX89fz+9vP1/fX9/f7//vr2/ODl4sK75yH5BAEAAAAALAAAAAAYABgAAAj/AAEAmFOnoMGDCAvGmRNHYMKHEOdIhEgRIcGKGDMeTJVO00WNBj194/frFik5IOvgqdaP371N26xpefORYq57/HI+s7Vtmy0eKCmmapcz575FPXt+SfHmociiRae1SroNWIoVTQ2uxAk15yJg1awl7ZSCaUE82uRxhTpt1TNXq0Ip2pSobIqCc0iVoqsI0ipXr1bhywfVXxYdiA3Sourz2dqc8lbNQJz4bDWqix73E7ZjhgrKOjYmvfWLbZcZqCdTPjjHGLdtibi2U5Q6NWiEqqq64ifvVe3at1nX2tTuWQ/QyIMfxHOGi+rkyeMklPMDuvWaBqlbj469IPUU2ykPCOw+53t4AAEBADs=">
</a>

<br>
Expand Down
2 changes: 1 addition & 1 deletion bot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "v3.10.0-dev4"
__version__ = "v3.10.0-dev5"


import asyncio
Expand Down
4 changes: 2 additions & 2 deletions cogs/modmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ async def anonadduser(self, ctx, *users_arg: Union[discord.Member, discord.Role,

tag = self.bot.config["mod_tag"]
if tag is None:
tag = str(ctx.author.top_role)
tag = str(get_top_hoisted_role(ctx.author))
name = self.bot.config["anon_username"]
if name is None:
name = tag
Expand Down Expand Up @@ -976,7 +976,7 @@ async def anonremoveuser(self, ctx, *users_arg: Union[discord.Member, discord.Ro

tag = self.bot.config["mod_tag"]
if tag is None:
tag = str(ctx.author.top_role)
tag = str(get_top_hoisted_role(ctx.author))
name = self.bot.config["anon_username"]
if name is None:
name = tag
Expand Down
5 changes: 3 additions & 2 deletions core/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
match_other_recipients,
truncate,
format_channel_name,
get_top_hoisted_role,
)

logger = getLogger(__name__)
Expand Down Expand Up @@ -888,7 +889,7 @@ async def send(
# Anonymously sending to the user.
tag = self.bot.config["mod_tag"]
if tag is None:
tag = str(author.top_role)
tag = str(get_top_hoisted_role(author))
name = self.bot.config["anon_username"]
if name is None:
name = tag
Expand Down Expand Up @@ -1005,7 +1006,7 @@ async def send(
elif not anonymous:
mod_tag = self.bot.config["mod_tag"]
if mod_tag is None:
mod_tag = str(message.author.top_role)
mod_tag = str(get_top_hoisted_role(message.author))
embed.set_footer(text=mod_tag) # Normal messages
else:
embed.set_footer(text=self.bot.config["anon_tag"])
Expand Down
8 changes: 8 additions & 0 deletions core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"escape_code_block",
"format_channel_name",
"tryint",
"get_top_hoisted_role",
]


Expand Down Expand Up @@ -394,3 +395,10 @@ def tryint(x):
return int(x)
except (ValueError, TypeError):
return x


def get_top_hoisted_role(member: discord.Member):
roles = sorted(member.roles, key=lambda r: r.position, reverse=True)
for role in roles:
if role.hoist:
return role
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ extend-exclude = '''

[tool.poetry]
name = 'Modmail'
version = '3.10.0-dev4'
version = '3.10.0-dev5'
description = "Modmail is similar to Reddit's Modmail, both in functionality and purpose. It serves as a shared inbox for server staff to communicate with their users in a seamless way."
license = 'AGPL-3.0-only'
authors = [
Expand Down

0 comments on commit 1a885bc

Please sign in to comment.