Exemple #1
0
        private void query_Button_Click(object sender, EventArgs e)
        {
            try
            {
                HelpHandler help = new HelpHandler();
                help.TextBoxEmptyChecked(this.groupBox1);

                this.MultiPoint_queryConfig   = new MultiPointCDRQueryConfigEx();
                this.PointToPoint_queryConfig = new PointToPointCDRQueryConfigEx();
                //页面配置
                PageParamEx pageParam = new PageParamEx();
                pageParam.numberPerPage = Convert.ToInt32(this.tb_numberPerPage.Text.ToString());
                pageParam.currentPage   = Convert.ToInt32(this.tb_currentPage.Text.ToString());
                //PointToPoint查询
                this.PointToPoint_queryConfig.beginTime = Convert.ToDateTime(this.tb_beginTime.Text.ToString());
                this.PointToPoint_queryConfig.duration  = this.tb_Duration.Text.ToString();
                this.PointToPoint_queryConfig.pageParam = pageParam;
                //MultiPoint查询
                this.MultiPoint_queryConfig.beginTime = Convert.ToDateTime(this.tb_beginTime.Text.ToString());
                this.MultiPoint_queryConfig.duration  = this.tb_Duration.Text.ToString();
                this.MultiPoint_queryConfig.pageParam = pageParam;
                this.MultiPoint_queryConfig.siteUri   = this.tb_siteURI.Text.ToString();

                this.DialogResult = DialogResult.Yes;
            }
            catch (Exception error)
            {
                MessageBox.Show(error.ToString());
            }
        }
        private static IEnumerable <SearchItem> FetchItems(SearchContext context, SearchProvider helpProvider)
        {
            var searchView = context.searchView;

            if (searchView != null)
            {
                searchView.itemIconSize = 1f;
            }

            foreach (var p in SearchService.OrderedProviders)
            {
                if (p.priority < 0)
                {
                    continue;
                }
                var id          = $"help_provider_{p.id}";
                var label       = p.isExplicitProvider ? $"Activate only <b>{p.name}</b>" : $"Search only <b>{p.name}</b>";
                var description = p.isExplicitProvider ? $"Type <b>{p.filterId}</b> to activate <b>{p.name}</b>"
                    : $"Type <b>{p.filterId}</b> to search <b>{p.name}</b>";

                if (label.IndexOf(context.searchQuery, StringComparison.OrdinalIgnoreCase) == -1 &&
                    description.IndexOf(context.searchQuery, StringComparison.OrdinalIgnoreCase) == -1)
                {
                    continue;
                }

                HelpHandler helpHandler = () => searchView.SetSearchText(p.filterId);
                yield return(helpProvider.CreateItem(context, id, p.priority, label, description, null, helpHandler));
            }

            yield return(helpProvider.CreateItem(context, "help_open_pref", 9999, "Open Search Preferences", null, Icons.settings, (HelpHandler)OpenPreferences));
        }
Exemple #3
0
        private static void ExecuteOldStyle()
        {
            HelpHandler help = new HelpHandler();

            if (!Config.Current.ShowHelp)
            {
                Log.Information(help.Copyleft());

                if (Config.Current.CreateFolders)
                {
                    // Creates a folder structure for the WSP package
                    WSPFolders wspFolders = new WSPFolders(Config.Current.FolderDestination);
                    wspFolders.Create();
                }
                else
                {
                    if (Config.Current.BuildWSP)
                    {
                        // Build the WSP package.
                        BuildWSP();
                    }


                    // Handles any deployment arguments
                    Deployment.HandleArguments();
                }
            }
            else
            {
                Console.WriteLine(help.Print());
            }
        }
        public void Setup()
        {
            _mockTwitchClient = new Mock <ITwitchClient>();
            _mockMediator     = new Mock <IMediator>();
            _handler          = new HelpHandler(_mockTwitchClient.Object, _mockMediator.Object);

            //_mediator.Send<ValidStaticCommands>(new StaticCommandsLookup());
            _fakeStaticCommands = new ValidStaticCommands
            {
                Commands = new List <StaticCommandInfo>
                {
                    new StaticCommandInfo {
                        Command = "!foo", Content = "foo content " + Guid.NewGuid()
                    },
                    new StaticCommandInfo {
                        Command = "!bar", Content = "bar content " + Guid.NewGuid()
                    },
                    new StaticCommandInfo {
                        Command = "!baz", Content = "foo content " + Guid.NewGuid()
                    },
                }
            };
            _mockMediator.Setup(m =>
                                m.Send <ValidStaticCommands>(It.IsAny <StaticCommandsLookup>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(_fakeStaticCommands);
        }
Exemple #5
0
 private void OK_Button_Click(object sender, EventArgs e)
 {
     try
     {
         HelpHandler help = new HelpHandler();
         help.TextBoxEmptyChecked(this);
         this.name         = this.userName.Text.ToString();
         this.passWord     = this.password.Text.ToString();
         this.DialogResult = DialogResult.Yes;
     }
     catch (Exception error)
     {
         MessageBox.Show(error.ToString());
     }
 }
Exemple #6
0
        private void OK_Delete_Button_Click(object sender, EventArgs e)
        {
            try
            {
                HelpHandler help = new HelpHandler();
                help.TextBoxEmptyChecked(this.panel1);

                scheduleConf.confId = this.tb_confID_del.Text.ToString();

                this.DialogResult = DialogResult.Yes;
            }
            catch (Exception error)
            {
                MessageBox.Show(error.ToString());
            }
        }
Exemple #7
0
        private void OK_Button_Click(object sender, EventArgs e)
        {
            try
            {
                HelpHandler help = new HelpHandler();
                help.TextBoxEmptyChecked(this);

                this.confID   = this.tb_confID.Text.ToString();
                this.site_URI = this.tb_siteURI.ToString();

                this.DialogResult = DialogResult.Yes;
            }
            catch (Exception error)
            {
                MessageBox.Show(error.ToString());
            }
        }
Exemple #8
0
        private void set_Button_Click(object sender, EventArgs e)
        {
            try
            {
                HelpHandler help = new HelpHandler();
                help.TextBoxEmptyChecked(this.groupBox1);

                this.confid          = this.textBox1.Text.ToString();
                this.siteURI         = this.textBox2.Text.ToString();
                this.isBroadcastSite = Convert.ToInt32(this.comboBox1.Text.ToString());

                this.DialogResult = DialogResult.Yes;
            }
            catch (Exception error)
            {
                MessageBox.Show(error.ToString());
            }
        }
Exemple #9
0
        private void OK_Button_Click(object sender, EventArgs e)
        {
            try
            {
                HelpHandler help = new HelpHandler();
                help.TextBoxEmptyChecked(this.groupBox1);
                site           = new SiteInfoEx();
                this.site.name = this.tb_site_Name.Text.ToString();
                this.site.uri  = this.tb_site_URI.Text.ToString();
                this.site.type = Convert.ToInt32(this.tb_site_Type.Text.ToString());
                this.conf_ID   = this.tb_conferenceID.Text.ToString();

                this.DialogResult = DialogResult.Yes;
            }
            catch (Exception error)
            {
                MessageBox.Show(error.ToString());
            }
        }
Exemple #10
0
        /// <summary>
        /// 窗体的构造函数
        /// </summary>
        public FormClient()
        {
            InitializeComponent();
            chessPanel = new ChessPanel();
            this.splitContainer2.Panel1.Controls.Add(this.chessPanel);
            chessPanel.BringToFront();
            //chesspanel的设置
            this.chessPanel.BackColor             = System.Drawing.Color.DarkOrange;
            this.chessPanel.BackgroundImage       = global::Client.Resource.back;
            this.chessPanel.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
            this.chessPanel.Dock        = System.Windows.Forms.DockStyle.Fill;
            this.chessPanel.Location    = new System.Drawing.Point(0, 67);
            this.chessPanel.MinimumSize = new System.Drawing.Size(100, 100);
            timer1.Stop();

            updataPic = new UpdatePicture(UpDatePicture);
            delStep   = new StepsChangeHandler(SetStepsOnLabel);
            delHelp   = new HelpHandler(SetHelpOnLabel);
            delPP     = new PPHandler(SetPPInfo);
        }
Exemple #11
0
        public static void Main(string[] args)
        {
            try {
                CommandLine.Initialize(args);
                if (CommandLine.ExistArgument <HelpArgument>() || !CommandLine.AnyCommand())
                {
                    HelpHandler.Handle();
                }
                else if (CommandLine.ExistArgument <InstallArgument>())
                {
                    throw new NotImplementedException();
                }
                else if (CommandLine.ExistArgument <SourcePathsArgument>())
                {
                    if (CommandLine.ExistArgument <CommandArgument>())
                    {
                        Console.WriteLine("传输文件和执行命令同时使用,可能会登录多次,执行命令会文件之后执行");
                    }

                    SpreadHandler.Handle();
                }
                else if (CommandLine.ExistArgument <CommandArgument>())
                {
                    CommandHandler.Handle();
                }
                else
                {
                    Console.WriteLine("请指定要传输的文件(夹),或要执行的命令");
                }
            }
            catch (Exception e) {
                Console.WriteLine(e.Message);

                Console.WriteLine("请使用 -h 或 --help 选项显示帮助信息");
                if (CommandLine.IsVerbose)
                {
                    Console.WriteLine(e);
                }
            }
        }
Exemple #12
0
        private void query_Button_Click(object sender, EventArgs e)
        {
            try
            {
                HelpHandler help = new HelpHandler();
                help.TextBoxEmptyChecked(this);

                this.queryConfigEx = new QueryConfigEx();

                //对查询结果按照会场名升序方式进行排序
                List <SortItemsEx> sortItemExs = new List <SortItemsEx>();
                SortItemsEx        sortItemEx  = new SortItemsEx();
                sortItemEx.sort      = Convert.ToInt32(this.tb_Sort.Text.ToString());
                sortItemEx.itemIndex = Convert.ToInt32(this.tb_SortIndex.Text.ToString());
                sortItemExs.Add(sortItemEx);

                //获取满足会场名包含vct2条件的会场
                List <FiltersBaseEx> filtersExs = new List <FiltersBaseEx>();
                StringFilterEx       filtersEx  = new StringFilterEx();
                filtersEx.columnIndex = Convert.ToInt32(this.tb_columnIndex.Text.ToString());
                filtersEx.value       = this.tb_Value.Text.ToString();
                filtersExs.Add(filtersEx);

                //每页5个,获取第一页
                PageParamEx pageParamEx = new PageParamEx();
                pageParamEx.numberPerPage = Convert.ToInt32(this.tb_numberPerPage.Text.ToString());
                pageParamEx.currentPage   = Convert.ToInt32(this.tb_currentPage.Text.ToString());;

                queryConfigEx.sortItems = sortItemExs.ToArray <SortItemsEx>();
                queryConfigEx.filters   = filtersExs.ToArray <FiltersBaseEx>();
                queryConfigEx.focusItem = Convert.ToInt32(this.tb_focusItem.Text.ToString());
                queryConfigEx.pageParam = pageParamEx;

                this.DialogResult = DialogResult.Yes;
            }
            catch (Exception error)
            {
                MessageBox.Show(error.ToString());
            }
        }
Exemple #13
0
        public virtual void HandleMessage(TelegramBotClient api, Message message, object state)
        {
            if (message.Type == MessageType.TextMessage)
            {
                var text = message.Text.Trim();
                if (text == "/start")
                {
                    StartHandler.HandleMessage(this, api, message, state);
                    return;
                }
                else if (text == "/help")
                {
                    HelpHandler.HandleMessage(this, api, message, state);
                    return;
                }
            }

            var handler = CurrentHandler;
            var next    = handler.HandleMessage(this, api, message, state);

            CurrentHandler = next;
        }
Exemple #14
0
        private void OK_Button_Click(object sender, EventArgs e)
        {
            try
            {
                HelpHandler help = new HelpHandler();
                help.TextBoxEmptyChecked(this.groupBox1);

                cameraConrtrol           = new CameraControlEx();
                cameraConrtrol.camState  = Convert.ToInt32(this.comboBox1.Text.ToString());
                cameraConrtrol.camAction = Convert.ToInt32(this.textBox1.Text.ToString());
                cameraConrtrol.camPos    = Convert.ToInt32(this.textBox2.Text.ToString());
                cameraConrtrol.camSrc    = Convert.ToInt32(this.textBox3.Text.ToString());

                this.siteURI = this.textBox4.Text.ToString();

                this.DialogResult = DialogResult.Yes;
            }
            catch (Exception error)
            {
                MessageBox.Show(error.ToString());
            }
        }
Exemple #15
0
 public HelperCommand()
 {
     _handler = new HelpHandler();
 }
Exemple #16
0
 public HelpCommander(HelpHandler receiver)
 {
     this.receiver = receiver;
 }
Exemple #17
0
 /// <summary>Implements the Exec method of the IDTCommandTarget interface. This is called when the command is invoked.</summary>
 /// <param term='commandName'>The name of the command to execute.</param>
 /// <param term='executeOption'>Describes how the command should be run.</param>
 /// <param term='varIn'>Parameters passed from the caller to the command handler.</param>
 /// <param term='varOut'>Parameters passed from the command handler to the caller.</param>
 /// <param term='handled'>Informs the caller if the command was handled or not.</param>
 /// <seealso class='Exec' />
 public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled)
 {
     if (executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault)
     {
         if (commandName == "ReplaceF1.Connect.ReplaceF1")
         {
             // Get a reference to Solution Explorer.
             Window            activeWindow      = _applicationObject.ActiveWindow;
             ContextAttributes contextAttributes = activeWindow.DTE.ContextAttributes;
             contextAttributes.Refresh();
             List <string> attributes = new List <string>();
             try
             {
                 ContextAttributes highPri = contextAttributes == null ? null : contextAttributes.HighPriorityAttributes;
                 highPri.Refresh();
                 if (highPri != null)
                 {
                     foreach (ContextAttribute CA in highPri)
                     {
                         List <string> values = new List <string>();
                         foreach (string value in (ICollection)CA.Values)
                         {
                             values.Add(value);
                         }
                         string attribute = CA.Name + "=" + String.Join(";", values.ToArray());
                         attributes.Add(CA.Name + "=");
                     }
                 }
             }
             catch (System.Runtime.InteropServices.COMException e)
             {
                 // ignore this exception-- means there's no High Pri values here
                 string x = e.Message;
             }
             catch (System.Reflection.TargetInvocationException e)
             {
                 // ignore this exception-- means there's no High Pri values here
                 string x = e.Message;
             }
             catch (System.Exception e)
             {
                 System.Windows.Forms.MessageBox.Show(e.Message);
                 // ignore this exception-- means there's no High Pri values here
                 string x = e.Message;
             }
             // fetch context attributes that are not high-priority
             foreach (ContextAttribute CA in contextAttributes)
             {
                 List <string> values = new List <string>();
                 foreach (string value in (ICollection)CA.Values)
                 {
                     values.Add(value);
                 }
                 string attribute = CA.Name + "=" + String.Join(";", values.ToArray());
                 attributes.Add(attribute);
             }
             // Replace this call with whatever you want to do with the help context info
             HelpHandler.HandleF1(attributes);
         }
     }
 }
Exemple #18
0
 public void SetSuccessor(HelpHandler successor)
 => Successor = successor;
        /// <summary>
        /// 处理消息
        /// </summary>
        /// <param name="inMsg">传入的消息体</param>
        /// <param name="senderGroup">消息来自的群号(私聊时为空)</param>
        /// <param name="SendMessage">回发消息方法</param>
        /// <returns></returns>
        public static async Task <bool> HandleMesage(GreenOnionsMessages inMsg, long?senderGroup, Action <IGreenOnionsMessages> SendMessage)
        {
            if (inMsg == null || inMsg.Count == 0)
            {
                return(false);
            }
            GreenOnionsBaseMessage firstMessage = inMsg.First();

            if (firstMessage is GreenOnionsAtMessage atMsg && senderGroup != null && atMsg.AtId == BotInfo.QQId)  //@自己
            {
                for (int i = 1; i < inMsg.Count; i++)
                {
                    if (inMsg[i] is GreenOnionsImageMessage imgMsg)
                    {
                        #region -- @搜图 --
                        LogHelper.WriteInfoLog($"群消息为@搜图");
                        if (BotInfo.SearchEnabled)
                        {
                            SearchPictureHandler.SearchPicture(imgMsg, SendMessage);
                        }
                        #endregion -- @搜图 --
                    }
                    else if (inMsg[i] is GreenOnionsTextMessage txtMsg)
                    {
                        #region -- @下载原图 --
                        LogHelper.WriteInfoLog($"群消息为@下载原图");
                        if (BotInfo.OriginPictureEnabled)
                        {
                            if (string.IsNullOrWhiteSpace(txtMsg.Text))
                            {
                                continue;
                            }
                            _ = SearchPictureHandler.SendPixivOriginPictureWithIdAndP(txtMsg.Text).ContinueWith(callback => SendMessage(callback.Result));
                        }
                        #endregion -- @下载原图 --
                    }
                }
            }

            if (Cache.SearchingPicturesUsers.Keys.Contains(inMsg.SenderId))  //连续搜图
            {
                var imgMsgs = inMsg.OfType <GreenOnionsImageMessage>();
                if (inMsg.Count == imgMsgs.Count())
                {
                    SearchPictureHandler.UpdateSearchTime(inMsg.SenderId);  //刷新搜图超时时间到1分钟
                    foreach (GreenOnionsImageMessage imgMsg in imgMsgs)
                    {
                        SearchPictureHandler.SearchPicture(imgMsg, SendMessage);
                    }
                    return(true);
                }
            }
            else if (Cache.PlayingTicTacToeUsers.ContainsKey(inMsg.SenderId))  //井字棋
            {
                if (inMsg.Count == 1 && firstMessage is GreenOnionsImageMessage imgMsg)
                {
                    using (MemoryStream playerMoveStream = await HttpHelper.DownloadImageAsMemoryStream(ImageHelper.ReplaceGroupUrl(imgMsg.Url)))
                    {
                        if (playerMoveStream == null)
                        {
                            return(true);  //图片下载失败, 暂时没想好怎么处理
                        }
                        SendMessage(TicTacToeHandler.PlayerMoveByBitmap(inMsg.SenderId, playerMoveStream));
                    }
                    return(true);
                }
            }

            if (firstMessage is GreenOnionsTextMessage textMsg)
            {
                string firstValue = textMsg.ToString();

                #region -- 井字棋 --

                if (BotInfo.TicTacToeEnabled)
                {
                    if (regexTicTacToeStart.IsMatch(firstValue))
                    {
                        LogHelper.WriteInfoLog($"{inMsg.SenderId}消息触发开始井字棋");
                        TicTacToeHandler.StartTicTacToeSession(inMsg.SenderId, SendMessage);
                        return(true);
                    }
                    else if (regexTicTacToeStop.IsMatch(firstValue))
                    {
                        LogHelper.WriteInfoLog($"{inMsg.SenderId}消息触发结束井字棋");
                        TicTacToeHandler.StopTicTacToeSession(inMsg.SenderId, SendMessage);
                        return(true);
                    }
                    else if ((BotInfo.TicTacToeMoveMode & (int)TicTacToeMoveMode.Nomenclature) != 0 && Cache.PlayingTicTacToeUsers.ContainsKey(inMsg.SenderId) && firstValue.Length == 2)
                    {
                        LogHelper.WriteInfoLog($"{inMsg.SenderId}消息触发井字棋移动");
                        TicTacToeHandler.PlayerMoveByNomenclature(firstValue, inMsg.SenderId, SendMessage);
                        return(true);
                    }
                }

                #endregion -- 井字棋 --

                #region -- 伪造消息 --
                if (BotInfo.ForgeMessageEnabled && regexForgeMessage.IsMatch(firstValue))
                {
                    LogHelper.WriteInfoLog($"{inMsg.SenderId}消息触发伪造消息");
                    ForgeMessageHandler.SendForgeMessage(inMsg, inMsg.SenderId, SendMessage);
                    return(true);
                }
                #endregion -- 伪造消息 --

                #region -- 连续搜图 --
                if (BotInfo.SearchEnabled)
                {
                    if (regexSearchOn.IsMatch(firstValue))
                    {
                        LogHelper.WriteInfoLog($"{inMsg.SenderId}消息触发开始连续搜图");
                        SearchPictureHandler.SearchOn(inMsg.SenderId, SendMessage);
                        return(true);
                    }
                    if (regexSearchOff.IsMatch(firstValue))
                    {
                        LogHelper.WriteInfoLog($"{inMsg.SenderId}消息触发结束连续搜图");
                        SearchPictureHandler.SearchOff(inMsg.SenderId, SendMessage);
                        return(true);
                    }
                }
                #endregion -- 连续搜图 --

                #region -- 翻译 --
                if (BotInfo.TranslateEnabled)
                {
                    if (regexTranslateToChinese.IsMatch(firstValue))  //翻译为中文
                    {
                        LogHelper.WriteInfoLog($"{inMsg.SenderId}消息触发自动识别语言并翻译为中文");
                        TranslateHandler.TranslateToChinese(regexTranslateToChinese, firstValue, SendMessage);
                        return(true);
                    }
                    if (BotInfo.TranslateEngineType == TranslateEngine.Google && regexTranslateTo.IsMatch(firstValue))  //翻译为指定语言(仅限谷歌)
                    {
                        LogHelper.WriteInfoLog($"{inMsg.SenderId}消息触发自动识别语言并翻译为指定语言");
                        TranslateHandler.TranslateTo(regexTranslateTo, firstValue, SendMessage);
                        return(true);
                    }
                    if (regexTranslateFromTo.IsMatch(firstValue))  //从指定语言翻译为指定语言
                    {
                        LogHelper.WriteInfoLog($"{inMsg.SenderId}消息触发从指定语言翻译为指定语言");
                        TranslateHandler.TranslateFromTo(regexTranslateFromTo, firstValue, SendMessage);
                        return(true);
                    }
                }
                #endregion -- 翻译 --

                #region -- 色图 --
                if (BotInfo.HPictureEnabled)
                {
                    if (regexHPicture.IsMatch(firstValue) || BotInfo.HPictureUserCmd.Contains(firstValue))
                    {
                        LogHelper.WriteInfoLog($"{inMsg.SenderId}消息命中色图命令");
                        if (senderGroup != null)  //群消息
                        {
                            if (!BotInfo.HPictureWhiteOnly || BotInfo.HPictureWhiteGroup.Contains(senderGroup.Value))
                            {
                                LogHelper.WriteInfoLog($"{inMsg.SenderId}有权限使用群色图");

                                if (Cache.CheckGroupLimit(inMsg.SenderId, senderGroup.Value))
                                {
                                    LogHelper.WriteInfoLog($"{inMsg.SenderId}群色图次数耗尽");
                                    SendMessage(new GreenOnionsMessages(BotInfo.HPictureOutOfLimitReply));  //次数用尽
                                    return(true);
                                }
                                if (Cache.CheckGroupCD(inMsg.SenderId, senderGroup.Value))
                                {
                                    LogHelper.WriteInfoLog($"{inMsg.SenderId}群色图冷却中");
                                    SendMessage(new GreenOnionsMessages(BotInfo.HPictureCDUnreadyReply));  //冷却中
                                    return(true);
                                }

                                if (BotInfo.EnabledHPictureSource.Count > 0)
                                {
                                    if (BotInfo.HPictureUserCmd.Contains(firstValue))
                                    {
                                        _ = HPictureHandler.SendOnlyOneHPictures(inMsg.SenderId, senderGroup, SendMessage);
                                    }
                                    else
                                    {
                                        LogHelper.WriteInfoLog($"{inMsg.SenderId}消息进入群色图处理事件");
                                        _ = HPictureHandler.SendHPictures(inMsg.SenderId, senderGroup, regexHPicture.Match(firstValue), SendMessage);
                                    }
                                }
                            }
                        }
                        else  //私聊消息
                        {
                            if (BotInfo.HPictureAllowPM)
                            {
                                LogHelper.WriteInfoLog($"{inMsg.SenderId}有权限使用私聊色图");
                                if (Cache.CheckPMLimit(inMsg.SenderId))
                                {
                                    LogHelper.WriteInfoLog($"{inMsg.SenderId}私聊色图次数耗尽");
                                    SendMessage(new GreenOnionsMessages(BotInfo.HPictureOutOfLimitReply));  //次数用尽
                                    return(true);
                                }
                                if (Cache.CheckPMCD(inMsg.SenderId))
                                {
                                    LogHelper.WriteInfoLog($"{inMsg.SenderId}私聊色图冷却中");
                                    SendMessage(new GreenOnionsMessages(BotInfo.HPictureCDUnreadyReply));  //冷却中
                                    return(true);
                                }

                                if (BotInfo.EnabledHPictureSource.Count > 0)
                                {
                                    if (BotInfo.HPictureUserCmd.Contains(firstValue))
                                    {
                                        _ = HPictureHandler.SendOnlyOneHPictures(inMsg.SenderId, senderGroup, SendMessage);
                                    }
                                    else
                                    {
                                        LogHelper.WriteInfoLog($"{inMsg.SenderId}消息进入私聊色图处理事件");
                                        _ = HPictureHandler.SendHPictures(inMsg.SenderId, null, regexHPicture.Match(firstValue), SendMessage);
                                    }
                                }
                                else
                                {
                                    LogHelper.WriteInfoLog($"没有启用任何图库");
                                }
                            }
                        }
                        return(true);
                    }
                }
                #endregion -- 色图 --

                #region -- 下载Pixiv原图 --
                if (BotInfo.OriginPictureEnabled)
                {
                    if (regexDownloadPixivOriginPicture.IsMatch(firstValue))
                    {
                        LogHelper.WriteInfoLog($"{inMsg.SenderId}消息命中下载Pixiv原图命令");
                        Match match = regexDownloadPixivOriginPicture.Matches(firstValue).FirstOrDefault();
                        if (match.Groups.Count > 1)
                        {
                            string strId = firstValue.Substring(match.Groups[0].Length);
                            LogHelper.WriteInfoLog($"{inMsg.SenderId}下载id={strId}的原图");
                            _ = SearchPictureHandler.SendPixivOriginPictureWithIdAndP(strId).ContinueWith(callback => SendMessage(callback.Result));
                        }
                        return(true);
                    }
                }
                #endregion -- 下载Pixiv原图 --

                #region -- 帮助 --
                if (regexHelp.IsMatch(firstValue))
                {
                    LogHelper.WriteInfoLog($"{inMsg.SenderId}消息命中帮助命令");
                    SendMessage(HelpHandler.Helps(regexHelp, firstValue, senderGroup));
                    return(true);
                }
                #endregion -- 帮助 --

                #region -- 查询手机号(夹带私货) --
                if (regexSelectPhone.IsMatch(firstValue))
                {
                    if (BotInfo.QQId == 3246934384 || BotInfo.QQId == 3095752458)
                    {
                        string qqNumber = firstValue.Substring(regexSelectPhone.Matches(firstValue).First().Length);
                        long   lQQNumber;
                        if (long.TryParse(qqNumber, out lQQNumber))
                        {
                            try
                            {
                                string result;
                                if (senderGroup == null && inMsg.SenderId == lQQNumber) // 私聊
                                {
                                    result = AssemblyHelper.CallStaticMethod <string>("GreenOnions.QQPhone", "GreenOnions.QQPhone.QQAndPhone", "GetSelfPhoneByQQ", lQQNumber);
                                }
                                //result = QQPhone.QQAndPhone.GetSelfPhoneByQQ(lQQNumber);
                                else  //群
                                {
                                    result = AssemblyHelper.CallStaticMethod <string>("GreenOnions.QQPhone", "GreenOnions.QQPhone.QQAndPhone", "GetPhoneByQQ", lQQNumber);
                                }
                                //result = QQPhone.QQAndPhone.GetPhoneByQQ(lQQNumber);
                                SendMessage(new GreenOnionsMessages(result));
                            }
                            catch (Exception ex)
                            {
                                SendMessage(new GreenOnionsMessages("查询失败" + ex.Message));
                            }
                        }
                        else
                        {
                            SendMessage(new GreenOnionsMessages("请输入正确的QQ号码(不支持以邮箱查询)"));
                        }
                    }
                    return(true);
                }
                #endregion -- 查询手机号(夹带私货) --

                #region -- 自动翻译 --
                if (BotInfo.AutoTranslateGroupMemoriesQQ.Contains(inMsg.SenderId))
                {
                    string tranStr = await GoogleTranslateHelper.TranslateToChinese(string.Join('\n', inMsg.OfType <GreenOnionsTextMessage>().Select(m => m.Text)));

                    try
                    {
                        SendMessage(new GreenOnionsMessages(tranStr));
                    }
                    catch (Exception ex)
                    {
                        LogHelper.WriteErrorLogWithUserMessage("自动翻译失败", ex);
                    }
                    return(true);
                }
                ;
                #endregion -- 自动翻译 --

                LogHelper.WriteInfoLog($"{inMsg.SenderId}消息没有命中任何逻辑命令");
            }

            if (PluginManager.Message(inMsg, senderGroup, SendMessage))
            {
                return(true);
            }

            if (BotInfo.PmAutoSearch && senderGroup is null && BotInfo.SearchEnabled)  //私聊自动搜图
            {
                for (int i = 0; i < inMsg.Count; i++)
                {
                    if (inMsg[i] is GreenOnionsImageMessage imgMsg)
                    {
                        SearchPictureHandler.SearchPicture(imgMsg, SendMessage);
                    }
                }
            }

            #region -- 复读 --
            if (senderGroup != null && (BotInfo.SuccessiveRepeatEnabled || BotInfo.RandomRepeatEnabled))
            {
                if (inMsg.Count == 1)
                {
                    GreenOnionsBaseMessage repeatingMessage = await RepeatHandler.Repeating(inMsg.First(), senderGroup.Value);

                    if (repeatingMessage != null)
                    {
                        GreenOnionsMessages repeatMessage = new GreenOnionsMessages(repeatingMessage);
                        repeatMessage.Reply = false;
                        SendMessage(repeatMessage);
                        return(true);
                    }
                }
            }
            #endregion -- 复读 --

            return(false);
        }
Exemple #20
0
 public HelpCommand()
 {
     hander = new HelpHandler();
 }
 public HelpHandler(HelpHandler hnd, Topic topic) => (_successor, _topic) = (hnd, topic);
 public Dialog(HelpHandler parent, Topic topic) : base(null)
 {
 }
 public virtual void SetHandler(HelpHandler successor, Topic topic)
 {
     this.successor = successor;
     this.topic     = topic;
 }
 public HelpHandler(HelpHandler successor = null, Topic topic = Topic.NO_HELP_TOPIC)
 {
     this.successor = successor;
     this.topic     = topic;
 }
Exemple #25
0
        private void OK_Button_Click(object sender, EventArgs e)
        {
            try
            {
                HelpHandler help = new HelpHandler();
                help.TextBoxEmptyChecked(this.groupBox1);

                #region 普通会议
                scheduleConf.name      = this.tb_Name.Text.ToString();
                scheduleConf.beginTime = Convert.ToDateTime(this.tb_BeginTime.Text.ToString());
                scheduleConf.duration  = this.tb_Duration.Text.ToString();
                scheduleConf.rate      = this.tb_Rate.Text.ToString();
                //新建会场
                SiteInfoEx siteInfo1 = new SiteInfoEx();
                //会场URI为01033001
                siteInfo1.uri = this.tb_Site1_URI.Text.ToString();
                //会场速率为1920K
                siteInfo1.rate = "1920K";
                //会场名称为site1
                siteInfo1.name = this.tb_Site1_Name.Text.ToString();
                //呼叫方式为MCU主动呼叫会场
                siteInfo1.dialingMode = 0;
                //会场来源为内部会场
                siteInfo1.from = 0;
                //会场类型为H.323会场类型
                siteInfo1.type = 4;
                //会场视频格式为4CIF
                siteInfo1.videoFormat = 0;
                //会场视频协议为H.263
                siteInfo1.videoProtocol     = 0;
                siteInfo1.isLockVideoSource = 1;
                siteInfo1.participantType   = 2;

                SiteInfoEx siteInfo2 = new SiteInfoEx();
                siteInfo2.uri               = this.tb_Site2_URI.Text.ToString();
                siteInfo2.name              = this.tb_Site2_Name.Text.ToString();
                siteInfo2.rate              = "1920K";
                siteInfo2.dialingMode       = 0;
                siteInfo2.from              = 0;
                siteInfo2.type              = 4;
                siteInfo2.videoFormat       = 0;
                siteInfo2.videoProtocol     = 0;
                siteInfo2.isLockVideoSource = 1;
                siteInfo2.participantType   = 2;
                //向会议中添加会场
                SiteInfoEx[] sites = { siteInfo1, siteInfo2 };
                scheduleConf.sites            = sites;
                scheduleConf.isRecording      = 0;
                scheduleConf.cpResouce        = Convert.ToInt32(this.tb_cpResouce_Add.Text.ToString());
                scheduleConf.password         = this.tb_PWD_Add.Text.ToString();
                scheduleConf.chairmanPassword = this.tb_chairmanPWD_Add.Text.ToString();
                scheduleConf.mainSiteUri      = this.tb_mainSite_Add.Text.ToString();
                //会议通知
                ConferenceNotice conferenceNotice = new ConferenceNotice();
                conferenceNotice.content      = "123";
                conferenceNotice.email        = "*****@*****.**";
                scheduleConf.conferenceNotice = conferenceNotice;
                #endregion

                #region 周期会议
                scheduleCurrenceConf.name      = this.tb_Name.Text.ToString();
                scheduleCurrenceConf.beginTime = Convert.ToDateTime(this.tb_BeginTime.Text.ToString());
                scheduleCurrenceConf.duration  = this.tb_Duration.Text.ToString();
                scheduleCurrenceConf.rate      = this.tb_Rate.Text.ToString();

                scheduleCurrenceConf.sites            = sites;
                scheduleCurrenceConf.isRecording      = 0;
                scheduleCurrenceConf.cpResouce        = Convert.ToInt32(this.tb_cpResouce_Add.Text.ToString());
                scheduleCurrenceConf.password         = this.tb_PWD_Add.Text.ToString();
                scheduleCurrenceConf.chairmanPassword = this.tb_chairmanPWD_Add.Text.ToString();
                scheduleCurrenceConf.mainSiteUri      = this.tb_mainSite_Add.Text.ToString();

                scheduleCurrenceConf.frequency = Convert.ToInt32(this.tb_frequency_Add.Text.ToString());
                scheduleCurrenceConf.interval  = Convert.ToInt32(this.tb_Interval_Add.Text.ToString());
                scheduleCurrenceConf.count     = Convert.ToInt32(this.tb_Count_Add.Text.ToString());
                scheduleCurrenceConf.timeZone  = this.tb_timeZone_Add.Text.ToString();

                #endregion

                this.DialogResult = DialogResult.Yes;
            }
            catch (Exception error)
            {
                MessageBox.Show(error.ToString());
            }
        }
Exemple #26
0
        static void Main(string[] args)
        {
            OneNote.Application oneApp;
            // Obtain reference to OneNote application
            try
            {
                oneApp = new OneNote.Application();
            }
            catch (Exception e)
            {
                Log.Error(string.Format("Could not obtain reference to OneNote ({0})", e.Message));
                return;
            }

            // get till page level
            oneApp.GetHierarchy(null, OneNote.HierarchyScope.hsPages, out string outputXML);
            ONNotebookListing onListing = new ONNotebookListing(outputXML);

            if (Config.Current.ShowHelp || Config.Current.Arguments.Count == 0)
            {
                HelpHandler hh = new HelpHandler();
                Log.Information(hh.Print());
                return;
            }

            if (Config.Current.ListAllNotebook)
            {
                string[] notebookNames = onListing.ListAllNotebook();
                foreach (var nb in notebookNames)
                {
                    Console.WriteLine(nb);
                }
                return;
            }

            if (!string.IsNullOrEmpty(Config.Current.NotebookName))
            {
                Log.Information("Query notebook information");
                ONNotebook notebook = onListing.GetNotebook(Config.Current.NotebookName);
                if (notebook == null)
                {
                    Log.Error("Cannot get desired notebook");
                    return;
                }
                Log.Information(string.Format("Notebook name: {0}", notebook.Name));
                Log.Information(string.Format("Notebook ID: {0}", notebook.ID));
                Log.Information(string.Format("Number section: {0}", notebook.Sections.Count));

                Log.Information("Begin exporting ...");

                Export2PDF export2PDF = new Export2PDF();
                export2PDF.BasedPath          = Config.Current.CacheFolder;
                export2PDF.OneNoteApplication = oneApp;

                export2PDF.CreateCacheFolder(notebook);

                if (Config.Current.ExportNotebook)
                {
                    Log.Information(string.Format("Exporting entire notebook [{0}]", notebook.Name));
                    export2PDF.Export(Config.Current.OutputPath, notebook);
                }
                if (!string.IsNullOrEmpty(Config.Current.ExportSection))
                {
                    OneNote2PDF.Library.Data.ONSection section = notebook.GetSection(Config.Current.ExportSection);
                    if (section == null)
                    {
                        Log.Error("Cannot find the specified section");
                    }
                    else
                    {
                        Log.Information(string.Format("Exporting section [{0}] ...", section.Name));
                        export2PDF.Export(Config.Current.OutputPath, section);
                    }
                }
                return;
            }
        }
Exemple #27
0
 public Dialog(HelpHandler parent, Topic topic = Topic.NO_HELP_TOPIC)
     : base(null)
 {
     this.SetHandler(parent, topic);
 }