Пример #1
0
        private static void InitChattable(IChattable source)
        {
            if (!InitdChattables.Contains(source))
            {
                string sourceStr = source.ToString(true);

                var config = (JObject)AppStatusConfig.Config;
                config.Add(new JProperty(sourceStr, new JObject()), false);

                var sourceConfig = (JObject)config[sourceStr];
                var newConfig    = new JObject();
                var apps         = AppUtilities.GetApps(source);

                foreach (AppBase app in apps)
                {
                    if (app.CanDisable)
                    {
                        newConfig.Add(sourceConfig.ContainsKey(app.Name) ? new JProperty(app.Name, sourceConfig[app.Name]) : new JProperty(app.Name, app.IsEnabledByDefault));
                    }
                }

                sourceConfig.Replace(newConfig);

                AppStatusConfig.Save();
                InitdChattables.Add(source);
            }
        }
Пример #2
0
        public void AssignNewDialogue(DialogueInfo info)
        {
            DialogueOption dialogue = DialogueService.GetInstance().GetDialogue(info);
            IChattable     npc      = EntityService.GetInstance().GetNpcById(info.NpcId);

            npc.AddDialogue(dialogue);
            hasChanged = true;
        }
Пример #3
0
        public DialogueComponent(SpriteFont font, ContentManager content, IChattable chatSupplier)
            : base(font, content)
        {
            dialogueOptions = new ItemList(font);

            this.chatSupplier = chatSupplier;
            dialogueOptions.SelectionChange += OnListSelectionChange;
            PopulateOptions();

            responseArea = new TextArea(font, content);
        }
Пример #4
0
        internal static IEnumerable <AppBase> GetApps(IChattable source)
        {
            var apps = Commons.Apps.Where(x => x is App);

            if (source is IGroup)
            {
                return(apps.Concat(Commons.Apps.Where(x => x is GroupApp)));
            }
            else if (source is IUser)
            {
                return(apps.Concat(Commons.Apps.Where(x => x is UserApp)));
            }
            else
            {
                return(apps);
            }
        }
        internal static IEnumerable <AppBase> GetApps(IChattable source, IUser user)
        {
            var apps = AppBase.Apps.Where(x => x is App && x.IsAllowed(user));

            if (source is IGroup)
            {
                return(apps.Concat(AppBase.Apps.Where(x => x is GroupApp && x.IsAllowed(user))));
            }
            else if (source is IUser)
            {
                return(apps.Concat(AppBase.Apps.Where(x => x is UserApp && x.IsAllowed(user))));
            }
            else
            {
                return(apps);
            }
        }
Пример #6
0
        public void OnMissionChange(object sender, EventArgs args)
        {
            if (!(sender is MissionInstance))
            {
                return;
            }

            MissionInstance mission      = (MissionInstance)sender;
            DialogueInfo    dialogueInfo = mission.CurrentMission.NewDialogueOption;

            if (dialogueInfo != null)
            {
                IChattable npc = EntityService.GetInstance().GetNpcById(dialogueInfo.NpcId);
                DialogueManager.GetInstance().AssignNewDialogue(dialogueInfo);
            }

            NotificationPopup.GetInstance().AddNotification(string.Format("Mission log updated"));
            hasChanged = true;
        }
Пример #7
0
        public void Update(GameTime gameTime)
        {
            if (chattable != null)
            {
                chattable.RemoveDialogue(this);

                foreach (DialogueInfo info in successorInfo)
                {
                    DialogueOption option = DialogueService.GetInstance().GetDialogue(info);
                    IChattable     npc    = EntityService.GetInstance().GetNpcById(info.NpcId);
                    npc.AddDialogue(option);
                }
            }

            if (Selected != null)
            {
                Selected(dialogueInfo, null);
            }

            if (ProccessAdditionalData != null && additionalData != null)
            {
                ProccessAdditionalData(additionalData, null);
            }
        }
Пример #8
0
 internal static string ToString(this IChattable chattable, bool useExtension)
 {
     if (chattable is IUser user && useExtension)
     {
         return(user.AsUser().ToString());
     }
Пример #9
0
 public void AttachChattable(IChattable chattable)
 {
     this.chattable = chattable;
 }
Пример #10
0
 internal bool IsEnabled(IChattable source) => !CanDisable || AppStatusConfig.Config[source.ToString(true)][Name].ToObject <bool>();
Пример #11
0
        internal override void Invoke(MessageReceivedEventArgs e)
        {
            if (Owner == -1)
            {
                Handled = true;
            }

            if (IsRunning)
            {
                if (CurrentUser == null && (Owner == -1 || e.Subject.Number == Owner))
                {
                    CurrentUser = e.Subject;
                }

                if (CurrentUser != null && CurrentUser.Equals(e.Subject))
                {
                    switch (CurrentStepId)
                    {
                    case 0:
                        if (Owner == -1)
                        {
                            e.Reply("Hey! 别来无恙啊,欢迎使用 Minop Bot!");
                        }
                        e.Reply("请输入管理员账号:(输入 -1 则设置为当前账号)");
                        break;

                    case 1:
                        if (long.TryParse(e.Message, out OwnerSet))
                        {
                            if (OwnerSet < -1)
                            {
                                e.Reply("QQ 号不正确,请重新输入管理员账号:");
                                CurrentStepId--;
                                break;
                            }

                            e.Reply("管理员设置完毕!");
                            e.Reply("请输入命令响应前缀:");
                        }
                        else
                        {
                            e.Reply("获取 QQ 号失败,请重新输入管理员账号:");
                            CurrentStepId--;
                        }

                        break;

                    case 2:
                        Prefix = e.Message;
                        e.Reply("命令响应前缀设置完毕!");
                        break;
                    }

                    if (CurrentStepId == LastStepId)
                    {
                        e.Reply("配置准备就绪,敬请使用吧!\n" +
                                $"如果需要使用帮助菜单,请输入 {Prefix}help\n" +
                                $"如果设置管理员账号有误,请删除 data\\app\\{AppId}\\PluginConfig.json,并重载应用,发送 minop config\n" +
                                $"如果仅需修改其他内容,发送 {Prefix}config 重新配置即可");

                        if (OwnerSet == -1)
                        {
                            Owner = CurrentUser.Number;
                        }
                        else
                        {
                            Owner = OwnerSet;
                        }

                        PluginConfig.Save();
                        CurrentStepId = 0;
                        CurrentUser   = null;
                        OwnerSet      = -1;
                        IsRunning     = false;
                    }
                    else
                    {
                        CurrentStepId++;
                    }
                }

                Handled = true;
            }
        }
 public MessageReceivedEventArgs(Message message, IChattable source, IUser sender)
 {
     Message = message;
     Source  = source;
     Sender  = sender;
 }