Пример #1
0
 public async Task AddToIgnoreForceReply(string chatId)
 {
     var reply   = new ForceReply();
     var message = $"<b>{ForceReplyCommand.ADD_TO_IGNORE_COMMAND}</b>" +
                   "Type email address here.";
     await _telegramMethods.SendMessage(chatId, message, ParseMode.Html, false, false, null, reply);
 }
Пример #2
0
 public async Task RemoveFromIgnoreForceReply(string chatId)
 {
     var reply   = new ForceReply();
     var message = $"<b>{ForceReplyCommand.REMOVE_FROM_IGNORE_COMMAND}</b>" +
                   $"\r\n{Emoji.INFO_SIGN}<i>You can enter here an email address or a sequence number in the ignore list." +
                   $"\r\nTo see all emails and their number - choose {IgnoreMenuButtonCaption.Show} option in the Ignore menu.</i>";
     await _telegramMethods.SendMessage(chatId, message, ParseMode.Html, false, false, null, reply);
 }
Пример #3
0
        public async Task ChangeTextMessageForceReply(string chatId)
        {
            var reply = new ForceReply
            {
                Selective = false
            };
            var message = $"<b>{ForceReplyCommand.MESSAGE_COMMAND} </b>\r\n{Emoji.INFO_SIGN}<i>To attach files drop them into the chat.</i>";

            await _telegramMethods.SendMessage(chatId, message, ParseMode.Html, false, false, null, reply);
        }
Пример #4
0
        public async Task ChangeSubjectForceReply(string chatId)
        {
            var reply = new ForceReply
            {
                Selective = false
            };
            var message = $"<b>{ForceReplyCommand.SUBJECT_COMMAND} </b>";

            await _telegramMethods.SendMessage(chatId, message, ParseMode.Html, false, false, null, reply);
        }
Пример #5
0
        /// <summary>
        /// Присылает сообщение с инструкцией как добавить новый товар в БД.
        /// </summary>
        /// <returns></returns>
        private async Task <IActionResult> SendInsertProductFAQ()
        {
            string Currencies = "";
            string Units      = "";

            using (MarketBotDbContext db = new MarketBotDbContext())
            {
                var CurrencyList = db.Currency.ToList();

                var UnitList = db.Units.ToList();

                foreach (Currency c in CurrencyList)
                {
                    Currencies += c.Name + " - " + c.ShortName;
                }

                foreach (Units u in UnitList)
                {
                    Units += u.Name + "-" + u.ShortName;
                }
            }

            const string quote   = "\"";
            string       Example = "Пришлите фотографию товара, а в поле под фотографией(можно без фотографии, просто ответьте на сообщение бота) добавьте комментарий следующего вида:" +
                                   " Название товара, Категория, Цена, Валюта, Еденица измерения, В наличии, " + quote + "Краткое описание [не обязательно]" + quote + BotMessage.NewLine()
                                   + BotMessage.Bold("Например: ") + "Хреновуха, Настойки,500, руб., шт., 5, " + quote + "40 градусов" + quote + BotMessage.NewLine()
                                   + BotMessage.Bold("Например: ") + "Рис, Крупы,100, руб., кг., 100" + BotMessage.NewLine()
                                   + BotMessage.Bold("Например: ") + "Сникерс, Конфеты, 50, руб., г., 1000" + quote + "Вкусные конфеты. Ага" + quote
                                   + BotMessage.NewLine() + BotMessage.NewLine() + BotMessage.Bold("Доступные валюты: ") + Currencies
                                   + BotMessage.NewLine() + BotMessage.Bold("Еденицы измерения: ") + Units;


            ForceReply forceReply = new ForceReply
            {
                Force = true,

                Selective = true
            };

            if (await SendMessage(new BotMessage {
                TextMessage = Example
            }) != null &&
                await SendMessage(new BotMessage {
                TextMessage = EnterNameNewProductCmd, MessageReplyMarkup = forceReply
            }) != null)
            {
                return(base.OkResult);
            }


            else
            {
                return(base.NotFoundResult);
            }
        }
Пример #6
0
        private async Task <Message> SendForceReply(string text)
        {
            try
            {
                ForceReply forceReply = new ForceReply
                {
                    Force     = true,
                    Selective = true
                };

                return(await TelegramClient.SendTextMessageAsync(ChatId, text, ParseMode.Html, false, false, 0, forceReply));
            }

            catch
            {
                return(null);
            }
        }
Пример #7
0
        /// <summary>
        /// Forcre Reply сообщение с просьбой отправить сообщение с комментарием для заказа
        /// </summary>
        /// <returns></returns>
        private async Task <IActionResult> SendForceReplyAddDesc()
        {
            ForceReply forceReply = new ForceReply
            {
                Force = true,

                Selective = true
            };

            if (await SendMessage(new BotMessage {
                TextMessage = CmdEnterDesc, MessageReplyMarkup = forceReply
            }) != null)
            {
                return(base.OkResult);
            }

            else
            {
                return(base.NotFoundResult);
            }
        }
Пример #8
0
        private async Task <Message> SendForceReply(string text)
        {
            try
            {
                if (BotInfo.Configuration.BotBlocked)
                {
                    return(await TelegramClient.SendTextMessageAsync(this.ChatId, BotBlockedMsg, ParseMode.Html));
                }

                ForceReply forceReply = new ForceReply
                {
                    Force     = true,
                    Selective = true
                };

                return(await TelegramClient.SendTextMessageAsync(ChatId, text, ParseMode.Html, false, false, 0, replyMarkup : forceReply));
            }

            catch
            {
                return(null);
            }
        }
Пример #9
0
 public async Task EditLabelNameForceReply(string chatId)
 {
     var reply   = new ForceReply();
     var message = $"<b>{ForceReplyCommand.EDIT_LABEL_NAME_COMMAND}</b>";
     await _telegramMethods.SendMessage(chatId, message, ParseMode.Html, false, false, null, reply);
 }
Пример #10
0
 public async Task CreateNewLabelForceReply(string chatId)
 {
     var reply   = new ForceReply();
     var message = $"<b>{ForceReplyCommand.NEW_LABEL_COMMAND}</b>";
     await _telegramMethods.SendMessage(chatId, message, ParseMode.Html, false, false, null, reply);
 }
Пример #11
0
        public static void ClassInitialize(TestContext context)
        {
            _telegramMessagesCount = 0;
            _config = new ComparisonConfig
            {
                CompareChildren = true,
                CompareFields = false,
                CompareReadOnly = true,
                ComparePrivateFields = false,
                ComparePrivateProperties = false,
                CompareProperties = true,
                MaxDifferences = 50,
                MembersToIgnore = new List<string> { "MessageId", "Date", "ForwardDate", "UpdateId" }
            };

            var rm = new ResourceManager("CoffeeJelly.TelegramBotApiWrapperTests.Token", Assembly.GetExecutingAssembly());
            var token = rm.GetString("testToken");
            _telegramMethods = new TelegramMethods(token, true);
            var t = _telegramMethods.DeleteWebhook().Result;

            _privateChat = new Chat
            {
                Id = 170181775,
                FirstName = "Coffee",
                LastName = "Jelly",
                Username = "******",
                Type = ChatType.Private
            };
            _botUser = new User
            {
                Id = 252886092,
                FirstName = "Gmail control bot",
                Username = "******"
            };
            _italicTextEntity = new MessageEntity
            {
                Type = MessageEntityType.Italic,
                Offset = 0,
                Length = 23
            };
            _urlEntity = new MessageEntity
            {
                Type = MessageEntityType.Url,
                Offset = 0,
                Length = 21
            };
            _testUrlButton = new InlineKeyboardButton
            {
                Text = "URL Button",
                Url = "https://www.twitch.tv"
            };
            _testCallbackDataButton = new InlineKeyboardButton
            {
                Text = "Callback Button",
                CallbackData = "Test callback data"
            };
            _testInlineKeyboardMarkup = new InlineKeyboardMarkup
            {
                InlineKeyboard = new List<List<InlineKeyboardButton>>
                {
                    new List<InlineKeyboardButton>
                    {
                    _testUrlButton,
                    _testCallbackDataButton
                    }
                }
            };
            _testTextKeyboardButton = new KeyboardButton
            {
                Text = "Test keyboard button"
            };
            _testContactKeyboardButton = new KeyboardButton
            {
                Text = "Test contact keyboard button",
                RequestContact = true

            };
            _testReplyKeyboardMarkup = new ReplyKeyboardMarkup
            {
                Keyboard = new List<List<KeyboardButton>>
                {
                    new List<KeyboardButton>
                    {
                        _testTextKeyboardButton,
                        _testContactKeyboardButton,
                    },
                    new List<KeyboardButton>
                    {
                        _testContactKeyboardButton
                    }
                }
            };
            _testReplyKeyboardRemove = new ReplyKeyboardRemove();
            _testForceReply = new ForceReply();
            _botStartCommandEntity = new MessageEntity
            {
                Type = MessageEntityType.BotCommand,
                Offset = 0,
                Length = 6
            };
            _user = new User
            {
                Id = 170181775,
                FirstName = "Coffee",
                LastName = "Jelly",
                Username = "******",
                LanguageCode = "en"
            };
            _location = new Location
            {
                Latitude = 53.901112F,
                Longitude = 27.562325F
            };
            _photoSize1 = new PhotoSize
            {
                FileId = "AgADAgADqqcxG4_EJAo-Knthid_Ygy4XSA0ABHFCoFI0_mWuqGEBAAEC",
                FileSize = 10311,
                Width = 160,
                Height = 160
            };
            _photoSize2 = new PhotoSize
            {
                FileId = "AgADAgADqqcxG4_EJAo-Knthid_Ygy4XSA0ABII7yIDVjT7yqWEBAAEC",
                FileSize = 22094,
                Width = 320,
                Height = 320
            };
            _photoSize3 = new PhotoSize
            {
                FileId = "AgADAgADqqcxG4_EJAo-Knthid_Ygy4XSA0ABEN3DhgGCbBFqmEBAAEC",
                FileSize = 57644,
                Width = 640,
                Height = 640
            };
            _userProfilePhotos = new UserProfilePhotos
            {
                TotalCount = 1,
                Photos = new List<List<PhotoSize>>
                {
                    new List<PhotoSize>
                    {
                        _photoSize1,
                        _photoSize2,
                        _photoSize3
                    }
                }
            };
            _file = new File
            {
                FileId = "CAADAgADLgADk35wS_5j0ImZMegiAg",
            };

            _supergroupChat = new Chat
            {
                Id = -1001076966401,
                Title = "testgrp_new_title",
                Type = ChatType.Supergroup
            };
            _testChannel = new Chat
            {
                Id = -1001114442404,
                Title = "TestChannel",
                Type = ChatType.Channel
            };
            _userChatMember = new ChatMember
            {
                Status = ChatMemberStatus.Creator,
                User = _user
            };
            _botChatMember = new ChatMember
            {
                Status = ChatMemberStatus.Administrator,
                User = _botUser
            };
            _githubBot = new User
            {
                Id = 107550100,
                FirstName = "GitHub",
                Username = "******"
            };
            _githubBotChatMember = new ChatMember
            {
                Status = ChatMemberStatus.Administrator,
                User = _githubBot
            };
        }