Binato/server/packets/UserPresence.ts

34 lines
782 B
TypeScript
Raw Normal View History

2023-09-10 12:59:22 +01:00
import osu from "../../osuTyping";
import Shared from "../objects/Shared";
import User from "../objects/User";
2022-11-19 01:06:03 +00:00
2023-09-10 12:59:22 +01:00
export default function UserPresence(arg0:User | Shared, id:number) {
2023-08-20 13:03:01 +01:00
const osuPacketWriter = osu.Bancho.Writer();
let shared:Shared;
2022-11-21 23:26:20 +00:00
if (arg0 instanceof User) {
2023-08-20 13:03:01 +01:00
shared = arg0.shared;
2022-11-21 23:26:20 +00:00
} else {
2023-08-20 13:03:01 +01:00
shared = arg0;
2022-11-21 23:26:20 +00:00
}
2022-11-19 01:06:03 +00:00
2023-08-20 13:03:01 +01:00
const userData = shared.users.getById(id);
2022-11-19 01:06:03 +00:00
if (userData == null) return;
osuPacketWriter.UserPresence({
userId: id,
username: userData.username,
timezone: 0,
countryId: userData.countryID,
permissions: 4,
longitude: userData.location.longitude,
latitude: userData.location.latitude,
rank: userData.rank
});
2022-11-21 23:26:20 +00:00
if (arg0 instanceof User) {
arg0.addActionToQueue(osuPacketWriter.toBuffer);
}
return osuPacketWriter.toBuffer;
2022-11-19 01:06:03 +00:00
}