mirror of
https://github.com/solero/houdini.git
synced 2024-11-25 15:07:24 +00:00
Use safe penguin name everywhere appropriate
This commit is contained in:
parent
2fd0a68aef
commit
c9907ba178
@ -1,9 +1,10 @@
|
||||
from houdini import handlers
|
||||
from houdini.handlers import XTPacket
|
||||
from houdini.handlers.play.navigation import handle_join_room
|
||||
from houdini.handlers.play.navigation import handle_join_room, handle_join_server
|
||||
|
||||
from houdini.data.penguin import Penguin
|
||||
from houdini.data.buddy import BuddyList, BuddyRequest
|
||||
from houdini.data.buddy import BuddyList, BuddyRequest, BuddyListCollection, \
|
||||
BuddyRequestCollection, CharacterBuddyCollection
|
||||
from houdini.constants import ClientType
|
||||
|
||||
|
||||
@ -58,7 +59,7 @@ async def handle_get_buddies(p):
|
||||
|
||||
async for buddy in buddy_list:
|
||||
buddy_presence = int(buddy.buddy_id in p.server.penguins_by_id)
|
||||
buddies.append(f'{buddy.buddy_id}|{buddy.parent.nickname}|{buddy_presence}')
|
||||
buddies.append(f'{buddy.buddy_id}|{buddy.parent.safe_nickname(p.server.config.lang)}|{buddy_presence}')
|
||||
|
||||
if buddy.best_buddy:
|
||||
best_buddies.append(str(buddy.buddy_id))
|
||||
@ -70,7 +71,8 @@ async def handle_get_buddies(p):
|
||||
if character.best_buddy:
|
||||
best_characters.append(str(character.character_id))
|
||||
|
||||
requests = [f'{request.requester_id}|{request.parent.nickname}' async for request in buddy_requests]
|
||||
requests = [f'{request.requester_id}|{request.parent.safe_nickname(p.server.config.lang)}'
|
||||
async for request in buddy_requests]
|
||||
|
||||
best_friend_count = len(best_buddies) + len(best_characters)
|
||||
notification_aware = int(best_friend_count >= 1)
|
||||
@ -101,7 +103,7 @@ async def handle_get_buddies_legacy(p):
|
||||
|
||||
async for buddy in buddy_list:
|
||||
buddy_presence = int(buddy.buddy_id in p.server.penguins_by_id)
|
||||
buddies.append(f'{buddy.buddy_id}|{buddy.parent.nickname}|{buddy_presence}')
|
||||
buddies.append(f'{buddy.buddy_id}|{buddy.parent.safe_nickname(p.server.config.lang)}|{buddy_presence}')
|
||||
|
||||
await p.send_xt('gb', *buddies)
|
||||
await update_player_presence(p)
|
||||
|
@ -392,7 +392,7 @@ async def handle_can_like_igloo(p):
|
||||
@handlers.handler(XTPacket('g', 'gr'), client=ClientType.Vanilla)
|
||||
async def handle_get_open_igloo_list(p):
|
||||
async def get_igloo_string(igloo):
|
||||
owner_name = p.server.penguins_by_id[igloo.penguin_id].data.nickname
|
||||
owner_name = p.server.penguins_by_id[igloo.penguin_id].safe_name
|
||||
like_count = await get_layout_like_count(igloo.id)
|
||||
igloo_population = len(igloo.penguins_by_id)
|
||||
return f'{igloo.penguin_id}|{owner_name}|{like_count}|{igloo_population}|{int(igloo.locked)}'
|
||||
@ -409,7 +409,7 @@ async def handle_get_open_igloo_list_legacy(p):
|
||||
return await p.send_line('%xt%gr%-1%')
|
||||
|
||||
async def get_igloo_string(igloo):
|
||||
owner_name = p.server.penguins_by_id[igloo.penguin_id].data.nickname
|
||||
owner_name = p.server.penguins_by_id[igloo.penguin_id].safe_name
|
||||
return f'{igloo.penguin_id}|{owner_name}'
|
||||
|
||||
open_igloos = [await get_igloo_string(igloo) for igloo in p.server.open_igloos_by_penguin_id.values()]
|
||||
|
@ -21,7 +21,8 @@ async def handle_get_ignore_list(p):
|
||||
|
||||
async with p.server.db.transaction():
|
||||
ignore_list = ignore_query.gino.iterate()
|
||||
ignores = [f'{ignore.ignore_id}|{ignore.parent.nickname}' async for ignore in ignore_list]
|
||||
ignores = [f'{ignore.ignore_id}|{ignore.parent.safe_nickname(p.server.config.lang)}'
|
||||
async for ignore in ignore_list]
|
||||
|
||||
await p.send_xt('gn', *ignores)
|
||||
|
||||
|
@ -31,7 +31,7 @@ async def handle_get_mail(p):
|
||||
async with p.server.db.transaction():
|
||||
async for postcard in mail_query.gino.iterate():
|
||||
sender_name, sender_id = ('sys', 0) if postcard.sender_id is None else (
|
||||
postcard.parent.nickname, postcard.sender_id)
|
||||
postcard.parent.safe_nickname(p.server.config.lang), postcard.sender_id)
|
||||
sent_timestamp = int(time.mktime(postcard.send_date.timetuple()))
|
||||
postcards.append(f'{sender_name}|{sender_id}|{postcard.postcard_id}|'
|
||||
f'{postcard.details}|{sent_timestamp}|{postcard.id}|{int(postcard.has_read)}')
|
||||
@ -54,7 +54,7 @@ async def handle_send_mail(p, recipient_id: int, postcard_id: int):
|
||||
postcard = await PenguinPostcard.create(penguin_id=recipient_id, sender_id=p.id,
|
||||
postcard_id=postcard_id)
|
||||
sent_timestamp = int(time.mktime(postcard.send_date.timetuple()))
|
||||
await recipient.send_xt('mr', p.data.nickname, p.data.id, postcard_id, '', sent_timestamp, postcard.id)
|
||||
await recipient.send_xt('mr', p.safe_name, p.id, postcard_id, '', sent_timestamp, postcard.id)
|
||||
else:
|
||||
ignored = await IgnoreList.query.where((IgnoreList.penguin_id == recipient_id)
|
||||
& (IgnoreList.ignore_id == p.id)).gino.scalar()
|
||||
|
@ -84,7 +84,7 @@ class SoundStudio:
|
||||
|
||||
async def get_broadcasted_tracks(self):
|
||||
penguins = self.server.penguins_by_id
|
||||
broadcasted_tracks = ','.join(f'{track.owner_id}|{penguins[track.owner_id].data.nickname}|'
|
||||
broadcasted_tracks = ','.join(f'{track.owner_id}|{penguins[track.owner_id].safe_name}|'
|
||||
f'{track.owner_id}|{track.id}|{track.likes}'
|
||||
for track in self.playlist)
|
||||
return broadcasted_tracks
|
||||
@ -113,7 +113,7 @@ async def get_shared_tracks(p):
|
||||
async with db.transaction():
|
||||
async for track in tracks_query.iterate():
|
||||
penguin = p.server.penguins_by_id[track.owner_id]
|
||||
shared_tracks.append(f'{penguin.data.id}|{penguin.data.nickname}|{track.id}|{track.likes}')
|
||||
shared_tracks.append(f'{penguin.id}|{penguin.safe_name}|{track.id}|{track.likes}')
|
||||
return shared_tracks
|
||||
|
||||
|
||||
|
@ -106,7 +106,7 @@ async def handle_get_player_by_id(p, penguin_id: int):
|
||||
@handlers.cooldown(1)
|
||||
async def handle_get_player_by_swid(p, penguin_id: int):
|
||||
if penguin_id in p.server.penguins_by_id:
|
||||
nickname = p.server.penguins_by_id[penguin_id].data.nickname
|
||||
nickname = p.server.penguins_by_id[penguin_id].safe_nick
|
||||
else:
|
||||
nickname = await Penguin.select('nickname').where(Penguin.id == penguin_id).gino.scalar()
|
||||
await p.send_xt('pbs', penguin_id, penguin_id, nickname)
|
||||
|
Loading…
Reference in New Issue
Block a user