Ejemplo n.º 1
0
        /// <summary>
        /// Attempts to add or remove an IP/Subnet from the banned list.
        /// </summary>
        /// <param name="subnet">The IP/Subnet (see getpeerinfo for nodes IP) with an optional netmask (default is /32 = single IP).</param>
        /// <param name="banCommand">'add' to add an IP/Subnet to the list, 'remove' to remove an IP/Subnet from the list.</param>
        /// <param name="bantime">time in seconds how long (or until when if [absolute] is set) the IP is banned (0 or empty means using the default time of 24h which can also be overwritten by the -bantime startup argument).</param>
        /// <param name="absolute">If set, the bantime must be an absolute timestamp expressed in UNIX epoch time.</param>
        /// <returns></returns>
        public async Task <string> SetBan(string subnet, BanCommand banCommand, int bantime = 0, bool absolute = false)
        {
            SetBan setBan = new SetBan {
                Subnet = subnet, BanCommand = banCommand, BanTime = bantime, Absolute = absolute
            };
            string response = await httpRequest.SendReq(MethodName.setban, setBan);

            return(response);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Attempts to add or remove an IP/Subnet from the banned list.
        /// </summary>
        /// <param name="setBan">See SetBan properties.</param>
        /// <returns></returns>
        public async Task <string> SetBan(SetBan setBan)
        {
            string response = await httpRequest.SendReq(MethodName.setban, setBan);

            return(response);
        }
Ejemplo n.º 3
0
        private void AsycnCallBack(System.Object sender, Telegram.Bot.Args.CallbackQueryEventArgs e)
        {
            DateTime d;
            DataBase db = Singleton.GetInstance().Context;

            if (e.CallbackQuery.From.Username != null)
            {
                SetUserName(e.CallbackQuery, db);
            }

            if (DateTime.TryParseExact(e.CallbackQuery.Data.Replace("+", "").Replace('.', '/'), "d/M/yyyy", new CultureInfo("en-US"), DateTimeStyles.None, out d))
            {
                try
                {
                    Advertising.Command.AbsCommand Command = AdvertisingCommands.FirstOrDefault(c => c.Equals(e.CallbackQuery.Data.Replace("+", "")));
                    if (Command == null && DateTime.ParseExact(e.CallbackQuery.Data.Replace("+", "").Replace('.', '/'), "d/M/yyyy", null) != null)
                    {
                        Command = AdvertisingCommands.FirstOrDefault(c => c.Equals(Advertising.CommandsText.ChoseDate));
                    }
                    Command.Execute(BotClient, e.CallbackQuery);
                }
                catch (Exception ex)
                {
                    Log.Logging(ex);
                }
            }
            else if (commands.Any(c => c.Equals(e.CallbackQuery.Data)))
            {
                try
                {
                    AbsCommand Command = commands.FirstOrDefault(c => c.Equals(e.CallbackQuery.Data));                     // вытягиваем класс
                    Command.Execute(BotClient, e.CallbackQuery);
                }
                catch (System.Exception ex)
                {
                    Log.Logging(ex);
                }
            }
            else if (commandSlashes.Any(c => c.Equals(e.CallbackQuery.Data)))
            {
                try
                {
                    ICommandSlash Command = commandSlashes.FirstOrDefault(c => c.Equals(e.CallbackQuery.Data));                     // вытягиваем класс
                    Command.Execute(BotClient, e.CallbackQuery);
                }
                catch (System.Exception ex)
                {
                    Log.Logging(ex);
                }
            }
            else if (AdvertisingCommands.Any(c => c.Equals(e.CallbackQuery.Data)))
            {
                try
                {
                    Advertising.Command.AbsCommand command = AdvertisingCommands.FirstOrDefault(c => c.Equals(e.CallbackQuery.Data));
                    command.Execute(BotClient, e.CallbackQuery);
                }
                catch (System.Exception ex)
                {
                    Log.Logging(ex);
                }
            }
            else if (db.GetChannels().Any(p => p.IDChannel == System.Convert.ToInt64(e.CallbackQuery.Data.Split(" ")[0])))
            {
                ThisChannel channel = new ThisChannel();
                channel.Execute(BotClient, e.CallbackQuery, System.Convert.ToInt64(e.CallbackQuery.Data.Split(" ")[0]));
            }
            else
            {
                User user = db.GetUser(e.CallbackQuery.From.Id);
                if (IsNullDataBase.IsNull(BotClient, e.CallbackQuery, user))
                {
                    return;
                }
                if (user.Chain == 53)
                {
                    SelectMyReviews selectReviews = new SelectMyReviews();
                    selectReviews.Execute(BotClient, e.CallbackQuery);
                }
                else if (user.Chain == 54)
                {
                    SelectOtherReviews selectReviews = new SelectOtherReviews();
                    selectReviews.Execute(BotClient, e.CallbackQuery);
                }
                else if (user.IsAdmin > 0)
                {
                    System.String[] words = e.CallbackQuery.Data.Split(new System.Char[] { ' ' }, System.StringSplitOptions.RemoveEmptyEntries);
                    if (words[1] == "1")
                    {
                        SetBan setBan = new SetBan();
                        setBan.Execute(BotClient, e.CallbackQuery);
                    }
                    else if (words[1] == "2")
                    {
                        SetCancel setCancel = new SetCancel();
                        setCancel.Execute(BotClient, e.CallbackQuery);
                    }
                    else if (words[1] == "3")
                    {
                        SetAppeal setAppeal = new SetAppeal();
                        setAppeal.Execute(BotClient, e.CallbackQuery);
                    }
                    else if (words[1] == "4")
                    {
                        SetCancelAppeal setAppeal = new SetCancelAppeal();
                        setAppeal.Execute(BotClient, e.CallbackQuery);
                    }
                }
            }
        }