Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix profile requests for invalid player names #39

Merged
merged 1 commit into from
May 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions xpartamupp/echelon.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from datetime import datetime, timedelta, timezone

from slixmpp import ClientXMPP
from slixmpp.jid import JID
from slixmpp.jid import JID, InvalidJID
from slixmpp.stanza import Iq
from slixmpp.xmlstream.handler import Callback
from slixmpp.xmlstream.matcher import StanzaPath
Expand Down Expand Up @@ -761,22 +761,23 @@ def _send_profile(self, iq, player_nick):
profile for

"""
player_jid = None

jid_str = self.plugin['xep_0045'].get_jid_property(self.room, player_nick, 'jid')
if jid_str:
player_jid = JID(jid_str)
player_jid.resource = "0ad"
else:
player_jid = None

# The player the profile got requested for is not online, so
# let's assume the JID contains the nick as local part.
if not player_jid:
player_jid = JID('%s@%s/%s' % (player_nick, self.sjid.domain, '0ad'))
# The player the profile got requested for is not online, so
# let's assume the JID contains the nick as local part.
try:
player_jid = JID('%s@%s/%s' % (player_nick, self.sjid.domain, '0ad'))
except InvalidJID:
pass

try:
if player_jid:
stats = self.leaderboard.get_profile(player_jid)
except Exception:
logger.exception("Failed to get leaderboard profile for player %s", player_jid)
else:
stats = {}

iq = iq.reply()
Expand Down
Loading