Пример #1
0
        public void Initialize()
        {
            LastPacketTime = Environment.TickCount;

            var geoData = GeoUtil.GetDataFromIPAddress(this.IPAddress);

            if (geoData != null)
            {
                this.CountryId = GeoUtil.GetCountryId(geoData["country"]["names"]["en"].ToString());
                this.Language  = CultureInfo
                                 .GetCultures(CultureTypes.AllCultures)
                                 .First(c => c.Name.EndsWith(geoData["country"]["iso_code"].ToString()))
                                 .Name;
                this.Latitude  = float.Parse(geoData["location"]["latitude"].ToString());
                this.Longitude = float.Parse(geoData["location"]["longitude"].ToString());
            }

            Status = new bUserStatus(bStatus.Idle, "", "", Mods.None, this.currentMode, 0);
            this.GetModesData();

            QueueCommand(
                new Command(Commands.OUT_ChoProtocol, Bancho.Protocol), //TODO: Is boxing good? idk..
                new Command(Commands.OUT_LoginResult, this.Id),
                new Command(Commands.OUT_UserTags, (int)this.Tags),
                new Command(Commands.OUT_FriendsList, new[] { 2, 3 }), //TODO: Friendslist
                new Command(Commands.OUT_Announcement,
                            "http://puu.sh/jh7t7/20c04029ad.png|https://osu.ppy.sh/news/123912240253"),
                new Command(Commands.OUT_UpdateUserInfo,
                            new bUserInfo(this.Id, this.Username, this.TimeZone, (byte)this.CountryId, UserTags.Player, PlayModes.Osu, this.Longitude, this.Latitude, 1)), //Yes, idk what is this "1"
                new Command(Commands.OUT_UpdateUserState, this.SerializableStats),
                new Command(Commands.OUT_UpdateUserInfo,
                            new bUserInfo(-3, "BanchoBot", 0, 0, UserTags.None, PlayModes.Osu, 0, 0, 0))
                );

            QueueCommand(Commands.OUT_ChannelJoinSuccess, "#osu");
            QueueCommand(Commands.OUT_ChannelJoinSuccess, "#broadcast");

            //FBUG: cant click in BanchoBot on his messages
            //FIXED? Probally negative id is only sent in UpdateUserInfo ..
            QueueCommand(Commands.OUT_IrcMessage,
                         new bIRCMessage("BanchoBot", "#osu", "Welcome to the Bancho!")
            {
                SenderId = 3
            });                                                                                 //NOTE: This is a test message
        }