Exemplo n.º 1
0
        public override void GiveBirth()
        {
            if (babies.NullOrEmpty())
            {
                ModLog.Warning(" no babies (debug?) " + this.GetType().Name);
                if (father == null)
                {
                    father = Trytogetfather(ref pawn);
                }
                Initialize(pawn, father);
            }

            List <Pawn> siblings = new List <Pawn>();

            foreach (Pawn baby in babies)
            {
                if (xxx.is_animal(baby))
                {
                    BestialBirth(baby, siblings);
                }
                else
                {
                    HumanlikeBirth(baby, siblings);
                }
            }

            pawn.health.RemoveHediff(this);
        }
Exemplo n.º 2
0
        private void SendMessageToAllClients(Message message)
        {
            var players = new List <IMyPlayer>();

            MyAPIGateway.Multiplayer.Players.GetPlayers(players);

            // V26.  Add checks for no local player
            ulong steamID = 0;
            long  me      = 0;

            if (MyAPIGateway.Session.Player != null)
            {
                steamID = MyAPIGateway.Session.Player.SteamUserId;
                me      = MyAPIGateway.Session.Player.IdentityId;
            }
            message.SenderSteamId = steamID;
            foreach (var player in players)
            {
                if (player.IdentityId == me)
                {
                    continue;
                }
                var steamId = MyAPIGateway.Multiplayer.Players.TryGetSteamId(player.IdentityId);
                if (steamId > 0)
                {
                    var msgBytes = Encoding.UTF8.GetBytes(MyAPIGateway.Utilities.SerializeToXML(message));
                    MyAPIGateway.Multiplayer.SendMessageTo(ModId, msgBytes, steamId);
                }
                else
                {
                    ModLog.Info("Found player with no steam ID:" + player.DisplayName);
                }
            }
        }
Exemplo n.º 3
0
        // after loading of saved data
        protected override void InitHostPostLoading(IModSystemRegistry modSystemRegistry)
        {
            ModLog.Info("Original world was loaded by Version:" + modBuildWhenGameStarted.ToString());
            ModLog.Info("Loaded world was saved by Version:" + modBuildWhenLastSaved.ToString());

            npcGroupManager.SetBuildWhenSaved(modBuildWhenLastSaved);

            researchHacking.InitHackingLocations(); // Uses research restrictions and save data
            DuckUtils.MakePeaceBetweenFactions("MIKI", "CRASH");
            DuckUtils.MakePeaceBetweenFactions("MIKI", "GCORP");

            //V27 for SE 1.192
            DuckUtils.RemoveFaction("SPRT");
            DuckUtils.SetAllPlayerReputation("MIKI", 0);

            audioSystem.AudioRelay = networkComms;
            networkComms.StartWipeHostToolbar();
            modSystemRegistry.AddRapidUpdatableModSystem(turretManager);
            modSystemRegistry.AddUpatableModSystem(researchHacking);
            modSystemRegistry.AddUpatableModSystem(missionSystem);
            modSystemRegistry.AddUpatableModSystem(mikiScrapManager);
            modSystemRegistry.AddUpatableModSystem(npcGroupManager);
            modSystemRegistry.AddUpatableModSystem(baseManager);
            modSystemRegistry.AddUpatableModSystem(convoySpawner);
        }
Exemplo n.º 4
0
        public async Task Take(IUser target = null, int Amount = 0, string reason = "No reason provided.")
        {
            //Make sure the command issuer is an administrator
            SocketGuildUser User1 = Context.User as SocketGuildUser;

            if (!User1.GuildPermissions.Administrator)
            {
                await Context.Channel.SendMessageAsync($"{Context.User.Mention}, you don't have administrator permissions in this discord server! Ask a moderator or the owner to execute this command!");

                return;
            }

            //Make sure a user was pinged
            if (target == null)
            {
                await Context.Channel.SendMessageAsync($"{Context.User.Mention}, you didn't mention a user to give the gold to! Please use this syntax: !gold give @user amount reason");

                return;
            }

            //Make sure the user pinged is not a bot
            if (target.IsBot)
            {
                await Context.Channel.SendMessageAsync($"{Context.User.Mention}, bots can't use gold, so you can't give gold to a bot!");

                return;
            }

            //Make sure an amount is specified
            if (Amount == 0)
            {
                await Context.Channel.SendMessageAsync($"{Context.User.Mention}, you need to specify a valid amount of gold that I need to give to {target.Mention}");

                return;
            }

            //Make sure the value is above 0
            if (Amount > 0)
            {
                await Context.Channel.SendMessageAsync($"{Context.User.Mention}, you can only take a positive value in gold.");

                return;
            }

            //Make sure the user has enough gold to take
            if (Amount > Data.Data.GetGold(target.Id, Context.Guild.Id))
            {
                await Context.Channel.SendMessageAsync($"{Context.User.Mention}, {target.Mention} does not have that much gold!" +
                                                       $" If you want to take all of their gold use the !reset command.");

                return;
            }

            await Context.Channel.SendMessageAsync($"tada: {Context.User.Mention} you have taken {Amount} gold from {target.Mention}!");

            //Take gold away and post admin action in mod log
            await Data.Data.SaveGoldMinus(target.Id, Amount, Context.Guild.Id, target.Username);

            await ModLog.PostInModLog(Context.Guild, "Took Gold", Context.User, target as IGuildUser, reason);
        }
Exemplo n.º 5
0
        public async Task Reset(IUser target = null, string reason = "No reason provided.")
        {
            SocketGuildUser User1 = Context.User as SocketGuildUser;

            if (!User1.GuildPermissions.Administrator) //Make sure user issuing command is admin
            {
                await Context.Channel.SendMessageAsync($"{Context.User.Mention}, you don't have administrator permissions in this discord server! Ask a administrator or the owner to execute this command!");

                return;
            }

            if (target == null) //Make sure a user was pinged
            {
                await Context.Channel.SendMessageAsync($"You need to tell me which user you want to reset the gold of! For example: !gold reset {Context.User.Mention}");

                return;
            }

            if (target.IsBot) //Make sure pinged user isn't a bot
            {
                await Context.Channel.SendMessageAsync($"{Context.User.Mention}, bots can't use gold, so you also can't reset the progress of bots! :robot:");

                return;
            }
            await Context.Channel.SendMessageAsync($"{target.Mention}, you have been reset by {Context.User.Mention}! This means you have lost all your gold!");

            await ModLog.PostInModLog(Context.Guild, "Reset Gold", Context.User, target as IGuildUser, reason);

            //Remove the gold
            using (SqliteDbContext DBContext = new SqliteDbContext())
            {
                DBContext.Gold.RemoveRange(DBContext.Gold.Where(x => x.UserId == target.Id && x.Serverid == Context.Guild.Id));
                await DBContext.SaveChangesAsync();
            }
        }
Exemplo n.º 6
0
        internal static Action AddGps(string name, string description, Vector3D coords)
        {
            MyStringId nameID;
            MyStringId descriptionID;

            string _name        = name;
            string _description = description;

            if (MyStringId.TryGet(name, out nameID))
            {
                _name = VRage.MyTexts.Get(nameID).ToString();
//                ModLog.Info("Found GPS localization for " + name+ " as:" + _name);
            }
            else
            {
                ModLog.Info("No name found for GPS:" + name);
            }
            if (MyStringId.TryGet(description, out descriptionID))
            {
                _description = VRage.MyTexts.Get(descriptionID).ToString();
//                ModLog.Info("Found GPS localization for " + description + " as:" + _description);
            }

            return(() => { DuckUtils.AddGpsToAllPlayers(_name, _description, coords); });
        }
Exemplo n.º 7
0
        public override void AllGridsInitialised()
        {
            // add unlock points
            ModLog.Info("Found " + unlockLocationList.Count().ToString() + " Unlock locations");
            foreach (var unlockLocation in unlockLocationList)
            {
                AddHackingLocation((TechGroup)unlockLocation.techGroup, unlockLocation.location, unlockLocation.unlockradius);

                if (researchControl.bDebugLocations)
                {
                    string name = "PBUnlock " + unlockLocation.techGroup.ToString();
                    DuckUtils.AddGpsToAllPlayers(name, "PB Unlock location", unlockLocation.location);
                }
            }
            // all grids have been loaded during game load.
            researchControl.AllowUnlockedTechs();


            //
            if (researchControl.bDebugLocations)
            {
                foreach (var unlockLocation in hackingLocations)
                {
                    string name = "Unlock " + unlockLocation.TechGroup.ToString();
                    DuckUtils.AddGpsToAllPlayers(name, "Unlock location", unlockLocation.Coords);
                }
            }
        }
Exemplo n.º 8
0
        public async Task BanAsync(SocketGuildUser targetUser, [Remainder] string reason = null)
        {
            // try banning our target
            try
            {
                await Context.Guild.AddBanAsync(targetUser);
            }
            catch
            {
                await ReplyAsync("Sorry, looks like I couldn't ban your target user. Perhaps their role is higher than mine?");

                return;
            }
            // build our database entry and add it to the database
            var modLog = new ModLog
            {
                Action    = $"{targetUser.Mention} was banned by {Context.User.Mention}.",
                Time      = DateTimeOffset.Now,
                Reason    = reason ?? "n/a",
                MessageId = null,
                Severity  = Severity.Severe,
                ActorId   = Context.User.Id
            };

            await MakeLogAsync(modLog, reason);
        }
Exemplo n.º 9
0
        public async Task SetInterest(double rate)
        {
            SocketGuildUser checkUser = Context.User as SocketGuildUser;

            if (!checkUser.GuildPermissions.Administrator)
            {
                await Context.Channel.SendMessageAsync($"Only an administrator can set the interest rate.");

                return;
            }

            try
            {
                await Data.Data.SetInterest(Context.Guild.Id, Context.Guild.Name, (int)rate);
            }
            catch (Exception)
            {
                await Context.Channel.SendMessageAsync("Please make sure the interest rate is in whole value format, 5% would be \"!setinterest 5\".");

                return;
            }
            await Context.Channel.SendMessageAsync($"Interest rate has been set to {rate}%.");

            //Channel to send the mod logs in
            await ModLog.PostInModLog(Context.Guild, $"Set interest rate to {rate}%", Context.User, null, "");
        }
Exemplo n.º 10
0
        public async Task SetModLogChannel(IGuildChannel channel)
        {
            SocketGuildUser checkUser = Context.User as SocketGuildUser;

            if (!checkUser.GuildPermissions.Administrator)
            {
                await Context.Channel.SendMessageAsync($"Only an administrator can set the mod log channel.");

                return;
            }

            //Set the channel
            await Data.Data.SetModLogChannel(Context.Guild.Id, channel.Id, Context.Guild.Name);

            //Send a test message
            SocketUser Nephry = Context.Guild.GetUser(322806920203337740);

            try
            {
                await ModLog.PostInModLog(Context.Guild, "Test", Nephry, null, "Testing");
            }
            catch (Exception)
            {
                await Data.Data.SetModLogChannel(Context.Guild.Id, 0, Context.Guild.Name);

                return;
            }
            await Context.Channel.SendMessageAsync($"Mod log channel successfully set to \"{channel.Name}\"");

            //Channel to send the mod logs in
            await ModLog.PostInModLog(Context.Guild, "Set the mod log channel to: " + channel.Name, Context.User, null, "");
        }
Exemplo n.º 11
0
 public override void Close()
 {
     ModLog.Info("Close Called");
     base.Close();
     MyAPIGateway.Utilities.MessageEntered -= MessageEntered;
     TextAPI.Close();
 }
Exemplo n.º 12
0
        public void UnlockTechsSilently(long playerId, HashSet <TechGroup> techGroups)
        {
            foreach (var techGroup in techGroups)
            {
                var technologies = techsForGroup[techGroup];
                if (technologies == null)
                {
                    ModLog.Error("No technologies for group: " + techGroup);
                    return;
                }

                foreach (var technology in technologies)
                {
                    if (bNewResearch)
                    {
                        // unknown: does this work for ALL players?
                        MyVisualScriptLogicProvider.ResearchListRemoveItem(technology); // SE 1.189
                    }
                    else
                    {
                        MyVisualScriptLogicProvider.PlayerResearchUnlock(playerId, technology);
                    }
                }
            }
        }
Exemplo n.º 13
0
        internal void UnlockTechGroupForAllPlayers(TechGroup techGroup)
        {
            if (UnlockedTechs.Contains(techGroup))
            {
                return; // Already unlocked
            }

            HashSet <MyDefinitionId> technologies;

            if (!techsForGroup.TryGetValue(techGroup, out technologies))
            {
                ModLog.Error("No technologies for group: " + techGroup);
                return;
            }

            var players = new List <IMyPlayer>();

            MyAPIGateway.Players.GetPlayers(players);
            foreach (var player in players)
            {
                foreach (var technology in technologies)
                {
                    MyVisualScriptLogicProvider.PlayerResearchUnlock(player.IdentityId, technology);
                }
            }
            UnlockedTechs.Add(techGroup);
            audioSystem.PlayAudio(GetAudioClipForTechGroup(techGroup));
        }
Exemplo n.º 14
0
        protected override void InitCommon(IModSystemRegistry modSystemRegistry)
        {
            string sInit = "Initialising Wico Research. Version: " + CurrentModVersion;

            MyAPIGateway.Utilities.ShowNotification(sInit, 5000, MyFontEnum.DarkBlue);
            ModLog.Info(sInit);

            if (MyAPIGateway.Session.IsServer)
            {
                MyVisualScriptLogicProvider.SendChatMessage(sInit, "Wicorel", 0, MyFontEnum.DarkBlue);
            }

            bool bResearch = Session.SessionSettings.EnableResearch;

            // This works to change the setting.
            Session.SessionSettings.EnableResearch = true;

            if (!bResearch)
            {
                ModLog.Info("Research was not turned on");
            }

            TextAPI         = new HudAPIv2();
            researchControl = new ResearchControl(audioSystem);
            researchControl.InitResearchRestrictions();
            researchHacking = new ResearchHacking(researchControl, TextAPI, networkComms);
            networkComms.Init(audioSystem, researchControl, researchHacking);
            modSystemRegistry.AddCloseableModSystem(networkComms);
            modSystemRegistry.AddUpatableModSystem(audioSystem);

            MyAPIGateway.Utilities.MessageEntered += MessageEntered;
        }
Exemplo n.º 15
0
        public override SaveData GetSaveData()
        {
            if (modBuildWhenGameStarted == 0)
            {
                modBuildWhenGameStarted = CurrentModVersion;
            }

            if (researchControl == null)
            {
                ModLog.Info("RC NULL!");
            }
            if (networkComms == null)
            {
                ModLog.Info("NC NULL!");
            }
            if (researchHacking == null)
            {
                ModLog.Info("RH NULL");
            }

            var saveData = new SaveData
            {
                UnlockedTechs          = researchControl.UnlockedTechs
                , RegisteredPlayers    = networkComms.RegisteredPlayers
                , HackingData          = researchHacking.GetSaveData()
                , BuildWhenGameStarted = modBuildWhenGameStarted
                , BuildWhenSaved       = CurrentModVersion
            };

            return(saveData);
        }
Exemplo n.º 16
0
            public async Task Ban(IGuildUser user, [Remainder] string msg = null)
            {
                var tm = DateTime.UtcNow;

                tm = TimeZoneInfo.ConvertTime(tm, _tz.GetTimeZoneOrUtc(user.Guild.Id));
                var mod         = _images.ImageUrls.Moderation;
                Uri imageToSend = mod.Ban[0];

                if (Context.User.Id != user.Guild.OwnerId && (user.GetRoles().Select(r => r.Position).Max() >= ((IGuildUser)Context.User).GetRoles().Select(r => r.Position).Max()))
                {
                    await ReplyErrorLocalized("hierarchy").ConfigureAwait(false);

                    return;
                }

                if (!string.IsNullOrWhiteSpace(msg))
                {
                    try
                    {
                        await(await user.GetOrCreateDMChannelAsync().ConfigureAwait(false)).EmbedAsync(new EmbedBuilder().WithErrorColor()
                                                                                                       .WithAuthor(GetText("baned_on", Context.Guild.ToString()))
                                                                                                       .WithThumbnailUrl(imageToSend.ToString())
                                                                                                       .WithFooter("ID: " + user.Id + " → " + $"[{tm:dd.MM.yyyy HH:mm:ss}]")
                                                                                                       .AddField(efb => efb.WithName(GetText("moderator")).WithValue(Context.User.ToString()))
                                                                                                       .AddField(efb => efb.WithName(GetText("reason")).WithValue(msg ?? "-")))
                        .ConfigureAwait(false);
                    }
                    catch
                    {
                        // ignored
                    }
                }

                var log = new ModLog()
                {
                    UserId    = user.Id,
                    GuildId   = Context.Guild.Id,
                    Type      = "Ban",
                    Reason    = msg,
                    Moderator = Context.User.Id,
                };

                await Context.Guild.AddBanAsync(user, 7, Context.User.ToString() + " | " + msg).ConfigureAwait(false);

                using (var uow = _db.UnitOfWork)
                {
                    uow.ModLog.Add(log);
                    uow.Complete();
                }

                var embed = new EmbedBuilder().WithErrorColor()
                            .WithFooter("ID: " + user.Id + " → " + $"[{tm:dd.MM.yyyy HH:mm:ss}]")
                            .WithThumbnailUrl(imageToSend.ToString())
                            .WithAuthor(name: user.ToString() + GetText("ban"), iconUrl: user.GetAvatarUrl())
                            .AddField(efb => efb.WithName(GetText("user")).WithValue(user.Mention).WithIsInline(true))
                            .AddField(efb => efb.WithName(GetText("moderator")).WithValue(Context.User.Mention).WithIsInline(true))
                            .AddField(efb => efb.WithName(GetText("reason")).WithValue(msg ?? "-").WithIsInline(true));

                await Context.Channel.EmbedAsync(embed).ConfigureAwait(false);
            }
Exemplo n.º 17
0
 // UNTESTED:
 void FunctionalityChanged(long entityId, long gridid, string entityName, string gridName, string typeid, string subtypeid, bool becameFunctional)
 {
     if (subtypeid.Contains("Hydrogen"))
     { // it's likely a hydrogen tank
         ModLog.Info(" It looks like a hydrogen tank just got built.");
         KeepTechsLocked();
     }
 }
Exemplo n.º 18
0
        public async Task <ModLog> LogModAction(User user, string reason, string rule, Instant timestamp)
        {
            var modLog = new ModLog(string.Empty, user.Id, reason, rule, timestamp);
            await Collection.InsertOneAsync(modLog);

            Debug.Assert(modLog.Id.Length > 0, "The MongoDB driver injected a generated ID");
            return(modLog);
        }
Exemplo n.º 19
0
        internal void InitHudMesages(bool bForce = false)
        {
            if (TextAPI == null)
            {
                ModLog.Error("Text HUD API not loaded");
                return;
            }
            if (TextAPI.Heartbeat)
            {
//                ModLog.Info("Have Heartbeat");

                if (hackInterruptedV2 == null || bForce)
                {
//                    ModLog.Info("Creating Interrupted HUD");
                    sbInterruptedMessage = new StringBuilder(SeTextColor + "CONNECTION LOST");
                    hackInterruptedV2    = new HudAPIv2.HUDMessage(sbInterruptedMessage, new Vector2D(-0.5, 0.5));
                    if (hackInterruptedV2 != null)
                    {
                        hackInterruptedV2.Message  = sbInterruptedMessage;
                        hackInterruptedV2.Scale    = 2;
                        hackInterruptedV2.Options  = HudAPIv2.Options.Shadowing;
                        hackInterruptedV2.Options |= HudAPIv2.Options.HideHud;
                        //                        hackInterruptedV2.TimeToLive = 45;
                        hackInterruptedV2.Visible = false;
                    }
                    else
                    {
                        ModLog.Info("Could not create Interrupted HUD");
                    }
                }
                if (hackBarV2 == null || bForce)
                {
//                    ModLog.Info("Creating Hacking HUD");
                    if (sbHackBarMessage == null)
                    {
                        sbHackBarMessage = new StringBuilder("Initial Research Bar");
                    }
                    hackBarV2 = new HudAPIv2.HUDMessage(sbHackBarMessage, new Vector2D(-0.5, 0.5));
                    if (hackBarV2 != null)
                    {
                        hackBarV2.Message  = sbHackBarMessage;
                        hackBarV2.Scale    = 2;
                        hackBarV2.Options  = HudAPIv2.Options.Shadowing;
                        hackBarV2.Options |= HudAPIv2.Options.HideHud;
                        hackBarV2.Visible  = false;
//                        hackBarV2.TimeToLive = 45;
                    }
                    else
                    {
                        ModLog.Info("Could not create Research HUD");
                    }
                }
            }
            else
            {
                ModLog.Info("NO TextHud HEARTBEAT");
            }
        }
Exemplo n.º 20
0
        // after loading of saved data
        protected override void InitHostPostLoading(IModSystemRegistry modSystemRegistry)
        {
            ModLog.Info("Original world was loaded by Version:" + modBuildWhenGameStarted.ToString());
            ModLog.Info("Loaded world was saved by Version:" + modBuildWhenLastSaved.ToString());
            researchHacking.InitHackingLocations(); // Uses research restrictions and save data
            audioSystem.AudioRelay = networkComms;
//			networkComms.StartWipeHostToolbar();
            modSystemRegistry.AddUpatableModSystem(researchHacking);
        }
Exemplo n.º 21
0
        private static ModLog GetModLog(Assembly assembly)
        {
            ModLog result;

            if (!ModLogs.TryGetValue(assembly, out result))
            {
                ModLogs[assembly] = result = new ModLog(assembly);
            }
            return(result);
        }
Exemplo n.º 22
0
        public Task AuthBotAsync(SocketGuildUser target, SocketGuildUser bot, [Remainder] string reason = null)
        {
            var modLog = new ModLog
            {
                Action    = $"{target.Mention}'s bot {bot.Mention} was authed by {Context.User.Mention}.",
                Time      = DateTimeOffset.Now,
                Reason    = reason ?? "n/a",
                MessageId = null,
                Severity  = Severity.Low,
                ActorId   = Context.User.Id
            };

            return(MakeLogAsync(modLog, reason));
        }
Exemplo n.º 23
0
        public async Task AdminGive(IUser target = null, int Amount = 0, string reason = "No reason provided.")
        {
            //Make sure someone was targeted
            if (target == null)
            {
                await Context.Channel.SendMessageAsync($"{Context.User.Mention}, you didn't mention a user to give the gold to! Please use this syntax: !gold give @user amount reason");

                return;
            }

            //At this point, we made sure that a user has been pinged
            if (target.IsBot)
            {
                await Context.Channel.SendMessageAsync($"{Context.User.Mention}, bots can't use gold, so you can't give gold to a bot!");

                return;
            }

            //At this point we made sure a user has been pinged AND that the user is not a bot
            if (Amount == 0)
            {
                await Context.Channel.SendMessageAsync($"{Context.User.Mention}, you need to specify a valid amount of gold that I need to give to {target.Mention}");

                return;
            }

            //Make sure the value is above 0
            if (Amount < 1)
            {
                await Context.Channel.SendMessageAsync($"{Context.User.Mention}, you can only give a positive value in gold.");

                return;
            }

            //At this point, we made sure a user has been pinged, that the user is not a bot AND that there is a valid amount of coins
            SocketGuildUser User1 = Context.User as SocketGuildUser;

            if (!User1.GuildPermissions.Administrator)
            {
                await Context.Channel.SendMessageAsync($"{Context.User.Mention}, you don't have administrator permissions in this discord server!");

                return;
            }

            await Data.Data.SaveGold(target.Id, Amount, Context.Guild.Id, target.Username);

            await ModLog.PostInModLog(Context.Guild, "Gave Gold", Context.User, target as IGuildUser, reason);

            await Context.Channel.SendMessageAsync($"tada: {target.Mention} you have received {Amount} gold from {Context.User.Mention}!");
        }
Exemplo n.º 24
0
        public override void Update1200()
        {
            var currentTime = MyAPIGateway.Session.GameDateTime;

            foreach (var npcGroup in npcGroups)
            {
                if (npcGroup.GroupSpawnTime + convoyExpiryTime < currentTime)
                {
                    ModLog.DebugError("NPC group expired! Ordering to disband for passing time limit of "
                                      + convoyExpiryTime, npcGroup.GetPosition());
                    npcGroup.Expire();
                }
            }
        }
Exemplo n.º 25
0
        private async Task MakeLogAsync(ModLog modLog, string reason = null)
        {
            // Get our logging channel.
            var logChannel = Context.Guild.TextChannels.FirstOrDefault(channel => channel.Name.ToLower() == _config["moderation_log_channel"].ToLower());

            // Define our embed color based on log severity.
            Color embedColour;

            switch (modLog.Severity)
            {
            case (Severity.Severe):
                embedColour = Color.Red;
                break;

            case (Severity.Medium):
                embedColour = Color.DarkOrange;
                break;

            default:
                embedColour = Color.Orange;
                break;
            }

            // add our log and save changes
            _dctx.Add(modLog);
            await _dctx.SaveChangesAsync();

            // grab the entry so we can get the id
            var dbLog = _dctx.Modlogs.LastOrDefault();
            // build our embed
            var logEmbed = new EmbedBuilder
            {
                Title       = $"Log Message",
                Description = dbLog.Action + "\n\n" +
                              $"Time: {dbLog.Time.ToString("HH:mm:ss dd/MM/yyy")} GMT+0\n\n" +
                              $"Reason: {reason ?? _config["prefix"] + $"reason {dbLog.Id} to set a reason."}",
                Color  = embedColour,
                Footer = (new EmbedFooterBuilder {
                    Text = $"Case {dbLog.Id}"
                })
            };
            // send it off.
            var message = await logChannel.SendMessageAsync("", false, logEmbed.Build());

            // update the modlog with the id of the message that it refers to, so we can use the reason command later on.
            dbLog.MessageId = message.Id;
            await _dctx.SaveChangesAsync();
        }
Exemplo n.º 26
0
        private void IncomingMessage(byte[] bytes)
        {
            try
            {
                var message = MyAPIGateway.Utilities.SerializeFromXML <Message>(Encoding.UTF8.GetString(bytes));
                switch (message.MessageType)
                {
                case MessageType.ClientJoined:                         // Server only
                    HandleClientJoinedMessage(message);
                    break;

                case MessageType.ClearToolbar:
                    StartWipeClientToolbar();
                    break;

                case MessageType.ToolbarClearedSuccessfully:
                    RegisteredPlayers.Add(message.PlayerId);
                    break;

                case MessageType.PlaySound:
                    audio.PlayAudio(AudioClip.GetClipFromId(message.AudioClipId));
                    break;

                case MessageType.HackingProgress:
                    hacking.ShowLocalHackingProgress(message.HackingProgressTicks);
                    break;

                case MessageType.HackingSuccess:
                    hacking.ShowLocalHackingSuccess();
                    break;

                case MessageType.HackingInterrupted:
                    hacking.ShowLocalHackingInterrupted();
                    break;

                case MessageType.HackingInterruptStopped:
                    hacking.ShowLocalHackingInterruptStopped();
                    break;

                default:
                    throw new Exception("Unrecognised message type: " + message.MessageType);
                }
            }
            catch (Exception e)
            {
                ModLog.Error(e);
            }
        }
Exemplo n.º 27
0
 public override void AllGridsInitialised()
 {
     // log to remind that they are on..
     if (DebugConvoys)
     {
         ModLog.Info("Convoy Debug is ON");
     }
     if (ForceAirOnly)
     {
         ModLog.Info(" Force Air only is ON");
     }
     if (ForceGroundOnly)
     {
         ModLog.Info(" Force Ground only is ON");
     }
 }
Exemplo n.º 28
0
        public async Task UnmuteAsync(SocketGuildUser targetUser, [Remainder] string reason = null)
        {
            await _mutes.ForceUnmute(targetUser);

            var log = new ModLog
            {
                Action    = $"{targetUser.Mention} was unmuted by {Context.User.Mention}",
                Time      = DateTimeOffset.Now,
                Reason    = reason ?? "n/a",
                MessageId = null,
                Severity  = Severity.Low,
                ActorId   = Context.User.Id
            };

            await MakeLogAsync(log, reason);
        }
Exemplo n.º 29
0
        public async Task <IActionResult> Edit(WorkItem workItem)
        {
            Console.WriteLine(workItem.CreatedAt);
            if (ModelState.IsValid)
            {
                _context.Update(workItem);
                var modLog = new ModLog {
                    ItemId = workItem.Id
                };
                _context.Add(modLog);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(workItem));
        }
Exemplo n.º 30
0
        public void UnlockTechForJoiningPlayer(long playerId)
        {
            foreach (var techGroup in UnlockedTechs)
            {
                var technologies = techsForGroup[techGroup];
                if (technologies == null)
                {
                    ModLog.Error("No technologies for group: " + techGroup);
                    return;
                }

                foreach (var technology in technologies)
                {
                    MyVisualScriptLogicProvider.PlayerResearchUnlock(playerId, technology);
                }
            }
        }