Skip to content

Commit

Permalink
fix #930 announcement link
Browse files Browse the repository at this point in the history
url type QtUrl was not converted to string for msg

+ game.state for announcing host was queried PLAYING instead of OPEN
+ some lower case and line break
  • Loading branch information
GrotheFAF committed Dec 28, 2017
1 parent 33b53d9 commit c280495
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Fix players in chat sometimes not displayed with their clan tags (#922, #923)
* Fix channel autojoin settings not loading properly
* Don't show checked user's name among other alias users
* Fix host and link in announcements in chat (#930, #934)

Contributors:
- Wesmania
Expand Down
15 changes: 7 additions & 8 deletions src/client/gameannouncer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ def __init__(self, gameset, me, colors, client):
self._colors = colors
self._client = client

self._gameset.newLobby.connect(self._announceHosting)
self._gameset.newLiveReplay.connect(self._announceReplay)
self._gameset.newLobby.connect(self._announce_hosting)
self._gameset.newLiveReplay.connect(self._announce_replay)

self.announce_games = True
self.announce_replays = True
Expand All @@ -24,7 +24,7 @@ def _is_friend_host(self, game):
return (game.host_player is not None
and self._me.isFriend(game.host_player.id))

def _announceHosting(self, game):
def _announce_hosting(self, game):
if not self._is_friend_host(game) or not self.announce_games:
return
announce_delay = QTimer()
Expand All @@ -39,24 +39,23 @@ def _delayed_announce_hosting(self):

if (not self._is_friend_host(game) or
not self.announce_games or
game.state != GameState.PLAYING):
game.state != GameState.OPEN):
return
self._announce(game, "hosting")

def _announceReplay(self, game):
def _announce_replay(self, game):
if not self._is_friend_host(game) or not self.announce_replays:
return
self._announce(game, "playing live")

def _announce(self, game, activity):
url = game.url(game.host_player.id)
url = game.url(game.host_player.id).toString()
url_color = self._colors.getColor("url")
mapname = maps.getDisplayName(game.mapname)
fmt = 'is {} {}<a style="color:{}" href="{}">{}</a> (on {})'
if game.featured_mod == "faf":
modname = ""
else:
modname = game.featured_mod + " "
msg = fmt.format(activity, modname, url_color, url,
game.title, mapname)
msg = fmt.format(activity, modname, url_color, url, game.title, mapname)
self._client.forwardLocalBroadcast(game.host, msg)

0 comments on commit c280495

Please sign in to comment.