Exemplo n.º 1
0
        private void ChangeNotificationButton()
        {
            button.Text = _message.Text;

            ButtonNotification ButtonTemp = db.GetButtonNotification(button);

            if (ButtonTemp == null)
            {
                db.SetValue(button);
            }

            ButtonAndTextNotication temp = db.GetButtonAndTextNotication(user);

            if (temp.Text != null)
            {
                Text += temp.Text.Text + "\n";
            }

            Text += button.Text;

            db.SetValue(new CollectionButtonNotification()
            {
                buttonAndTextNotification = temp, buttonNotification = button
            });
            db.Save();
        }
Exemplo n.º 2
0
        private void ChangeNotificztionText()
        {
            _Text = new TextNotification {
                Text = _message.Text
            };

            TextNotification TextTemp = db.GetTextNotification(_Text);

            if (TextTemp == null)
            {
                db.SetValue(_Text);
            }

            ButtonAndTextNotication temp = db.GetButtonAndTextNotication(user);

            ButtonAndTextNotication tempText = db.GetButtonAndTextNotication(_Text.Text);

            if (tempText == null)
            {
                temp.Text = _Text;
            }
            else
            {
                temp.isWork     = false;
                tempText.isWork = true;
                tempText.User   = user;
            }

            db.Save();
        }
Exemplo n.º 3
0
 private void SetNotification()
 {
     db.SetValue <ButtonAndTextNotication>(new ButtonAndTextNotication()
     {
         User = user, isWork = true
     });
 }
Exemplo n.º 4
0
        private void SetIncomeChannelAdmin(List <ChannelInfo> channel, Single total)
        {
            if (channel == null)
            {
                throw new ArgumentNullException(nameof(channel));
            }

            DataBase db = Singleton.GetInstance().Context;

            total = (total * 20) / 100;
            foreach (var item in channel)
            {
                Int32 temp = item.Admins.Count;
                foreach (var admin in item.Admins)
                {
                    IncomeChannelAdmin income = db.GetIncomeChannelsAdmin(admin.Id, ((item.Channel.Id + 1000000000000) * -1));
                    if (admin.Id != BotClient.BotId)
                    {
                        if (income == null)
                        {
                            db.SetValue <IncomeChannelAdmin>(new IncomeChannelAdmin()
                            {
                                ChannelId = (item.Channel.Id + 1000000000000) * -1, UserId = admin.Id, DateTime = System.DateTime.Today, SumIncome = total / temp
                            });
                        }
                        else
                        {
                            income.SumIncome = (total / temp) + income.SumIncome;
                        }
                    }
                }
            }
            db.Save();
        }
Exemplo n.º 5
0
 private void Add()
 {
     db.SetValue <FeaturedUserNew>(new FeaturedUserNew()
     {
         UserId = userTwo.ID, UserWhoAddedId = user.ID
     });
     db.Save();
 }
        public void SetNewCategoty(Message _message)
        {
            DataBase db = Singleton.GetInstance().Context;

            db.SetValue <Category>(new Category()
            {
                Name = _message.Text
            });
            user.Chain = (Int32)SetChain.MessageUserInBot;
            db.Save();
        }
Exemplo n.º 7
0
        private void ChangeNotificationPicture()
        {
            ButtonAndTextNotication temp = db.GetButtonAndTextNotication(user);

            CollectionPictureNotification picture = new CollectionPictureNotification();

            picture.buttonAndTextNotification = temp;
            picture.Picture = _message.Photo[2].FileId;

            db.SetValue(picture);
            db.Save();
        }
Exemplo n.º 8
0
        private void SetIncomeChannel(Int32 id, Single total, PostTemplate postTemplate = null)
        {
            DataBase           db      = Singleton.GetInstance().Context;
            List <ChannelInfo> channel = null;

            if (postTemplate == null)
            {
                channel = StartSession.Test(db.GetChannelsList(), id);
            }
            else
            {
                List <Channel> channels = new List <Channel>();
                foreach (var item in postTemplate.PostChannel)
                {
                    Channel Thischannel = db.GetChannel(item.ChannelId);
                    channels.Add(Thischannel);
                }
                channel = StartSession.Test(channels, id);
            }

            Int32 temp = channel.Count;

            foreach (var item in channel)
            {
                IncomeChannel incomeChannel = db.GetIncomeChannels((item.Channel.Id + 1000000000000) * -1);
                if (incomeChannel == null)
                {
                    db.SetValue <IncomeChannel>(new IncomeChannel()
                    {
                        ChannelId = (item.Channel.Id + 1000000000000) * -1, DateTime = System.DateTime.Today, SumIncome = total / temp
                    });
                }
                else
                {
                    incomeChannel.SumIncome = (total / temp) + incomeChannel.SumIncome;
                }
            }
            db.Save();
            SetIncome(channel, id, total);
            SetIncomeChannelAdmin(channel, total);
        }
Exemplo n.º 9
0
        private void SetIncome(List <ChannelInfo> channel, Int32 id, Single total)
        {
            DataBase db   = Singleton.GetInstance().Context;
            Int32    temp = channel.Count;

            foreach (var item in channel)
            {
                Income income = db.GetIncome(id, ((item.Channel.Id + 1000000000000) * -1));
                if (income == null)
                {
                    db.SetValue <Income>(new Income()
                    {
                        ChannelId = (item.Channel.Id + 1000000000000) * -1, UserId = id, dateTime = System.DateTime.Today, SumIncome = total / temp
                    });
                }
                else
                {
                    income.SumIncome = (total / temp) + income.SumIncome;
                }
            }
            db.Save();
        }
Exemplo n.º 10
0
        private void ChangeNotificationChat()
        {
            Channel channel = db.GetChannel(KeyChannel);
            ButtonAndTextNotication buttonAndTextNotication = db.GetButtonAndTextNotication(user);

            NotificationChat[] notificationChats = db.GetNotificationChats();
            NotificationChat   notificationChat  =
                notificationChats.FirstOrDefault(p => p.IdChannel == channel && p.IdNotification == buttonAndTextNotication.Id);

            if (notificationChat == null)
            {
                db.SetValue(new NotificationChat()
                {
                    IdChannel = channel, IdNotification = buttonAndTextNotication.Id
                });
            }
            else
            {
                db.Remove(notificationChat);
            }
            db.Save();
        }
Exemplo n.º 11
0
        public async void ChekRegister(TelegramBotClient bot, System.Object message)
        {
            _message  = message as Message;
            db        = Singleton.GetInstance().Context;
            botClient = bot;

            try
            {
                Channel channel = db.GetChannel(_message);
                if (channel == null && _message.Chat.Type == Telegram.Bot.Types.Enums.ChatType.Supergroup)
                {
                    Channel[] channels = db.GetChannels();

                    Chat chat = await botClient.GetChatAsync(_message.Chat.Id);

                    System.String NewChannel = $"Здравствуйте у нас появился новая группа @{_message.Chat.Username}!\n{chat.Description}";

                    foreach (Channel ch in channels)
                    {
                        botClient.SendText(ch.IDChannel, NewChannel);
                    }

                    db.SetChannel(chat);
                    db.Save();

                    channel = db.GetChannel(_message);

                    await Task.Run(() => AddNewChannel.SetTmessage());
                }

                User user = db.GetUser(_message.From.Id);

                TMessage tmessage = db.GetMessage(_message);
                Settings settings = db.GetSettings();

                if ((user == null || user.FIO == null || user.Number == "0") && _message.Chat.Type != ChatType.Private)
                {
                    botClient.DeleteMessage(_message.Chat.Id, _message.MessageId, "Невозможно удалить сообщение так как оно не было отправленное!");

                    System.String textChannel = $"❗Здравствуйте, что бы писать в чатах UBC - пройдите регистрацию в боте, это занимает меньше 1 минуты.\nСсылка на бота/регистрацию: @{botClient.GetMeAsync().Result.Username}\n\n📜Полный список чатов UBC @allUBC";


                    try
                    {
                        if ((_message.Type != MessageType.Photo) || (_message.Caption != null))
                        {
                            await botClient.SendTextMessageAsync(_message.From.Id, textChannel,
                                                                 replyMarkup : _inlineButton.Register);
                        }
                    }
                    catch
                    {
                        Message mes = null;

                        if ((channel.IDMessage == 0 && _message.Type != MessageType.Photo) ||
                            (_message.Caption != null && channel.IDMessage == 0))
                        {
                            mes = await botClient.SendTextMessageAsync(_message.Chat.Id, textChannel);

                            channel.IDMessage = mes.MessageId;
                            db.SetValue(new ChannelMessage()
                            {
                                ChannelID         = channel.IDChannel,
                                MessageId         = mes.MessageId,
                                DateMessageDelete = DateTime.Now.AddSeconds(20)
                            });

                            db.Save();
                        }
                    }
                }
                else if (user.Chain > 0 && user.Chain < (System.Int32)Advertising.SetChain.GetPayments && _message.Chat.Type == Telegram.Bot.Types.Enums.ChatType.Private)
                {
                    FIO fIO = new FIO();
                    fIO.SetNext(
                        new Number()).SetNext(
                        new ChaingeFIO()).SetNext(
                        new ChaingeNumber()).SetNext(
                        new SetReviewsName()).SetNext(
                        new SearchIDUser()).SetNext(
                        new SearchNumberUser()).SetNext(
                        new ChangeReviewsName()).SetNext(
                        new SetSendComplaint()).SetNext(
                        new SetSendAppeal()).SetNext(
                        new Admin()).SetNext(
                        new SetAdminPassword()).SetNext(
                        new Ban()).SetNext(
                        new KickUser()).SetNext(
                        new AdminAdd()).SetNext(
                        new AdminDelete()).SetNext(
                        new PostCount()).SetNext(
                        new WordAdd()).SetNext(
                        new AddUsers()).SetNext(
                        new FludUser()).SetNext(
                        new ChannelAdd()).SetNext(
                        new NewAdmin2Lvl()).SetNext(
                        new WordDelete());

                    ChainOfResposnsibility(botClient, fIO, message, user);
                }
                else if (user.Chain >= (System.Int32)Advertising.SetChain.GetPayments && _message.Chat.Type == Telegram.Bot.Types.Enums.ChatType.Private)
                {
                    Advertising.Payments payments = new Advertising.Payments();
                    payments.SetNext(
                        new AddPhotoAdvertising()).SetNext(
                        new ContentEditorText()).SetNext(
                        new SetUserInTransaction()).SetNext(
                        new SetBlockChain()).SetNext(
                        new SetDiscriptionInTransaction()).SetNext(
                        new SetIdTransaction()).SetNext(
                        new SetPublicKeyUserTwo()).SetNext(
                        new AddPhotoChannel()).SetNext(
                        new AddCategotyInDataBase()).SetNext(
                        new AddChannelInCategoryInDataBase()).SetNext(
                        new LinkChat()).SetNext(
                        new LinkChatPharase()).SetNext(
                        new AnaliticsPhraseUser()).SetNext(
                        new AdminCallBlockchainUser()).SetNext(
                        new MessageUserBot()).SetNext(
                        new AddAccauntBotUser()).SetNext(
                        new AddAccauntCode()).SetNext(
                        new PostCountChannel()).SetNext(
                        new ThisRegulationsUBC()).SetNext(
                        new ThisDeleteChat()).SetNext(
                        new ThisDeleteCategory()).SetNext(
                        new SetPriceTime()).SetNext(
                        new SetPriceStandartMessage()).SetNext(
                        new SetStaticTimePinnedPrice()).SetNext(
                        new SetPriceStatic()).SetNext(
                        new SetStaticTimePinnedNotificationPrice()).SetNext(
                        new NotificationTextChain()).SetNext(
                        new NotificationButtonChain()).SetNext(
                        new PictureNotificationChain());

                    payments.Handle(user.Chain, botClient, message);
                }
                else
                {
                    FludChain fludChain = new FludChain();
                    fludChain.SetNext(
                        new AddPeopleChain()).SetNext(
                        new PostNullChain()).SetNext(
                        new CheckChannelChain()).SetNext(
                        new CheckWordAdnLinkChain()).SetNext(
                        new CheckInviteChain()).SetNext(
                        new CheckPhotoChain());

                    fludChain.Handle(botClient, message, user, settings, tmessage, channel);
                }
            }
            catch (System.Exception ex)
            {
                Log.Logging("Класс Analize - " + ex);
            }
        }