示例#1
0
        internal static async Task NotifyOwnersAsync(Tuple <List <ExceptionNumbered>, int> exceptions,
                                                     TelegramBotAbstract sender, string v, string langCode, long?replyToMessageId = null)
        {
            MessageSentResult m = null;

            try
            {
                var text = new Language(new Dictionary <string, string>
                {
                    { "en", v }
                });
                m = await NotifyOwners2Async(text, sender, 0, langCode, replyToMessageId);
            }
            catch
            {
                ;
            }

            try
            {
                var text = new Language(new Dictionary <string, string>
                {
                    { "en", "Number of exceptions: " + exceptions.Item2 + " - " + exceptions.Item1.Count }
                });
                _ = await NotifyOwners2Async(text, sender, 0, langCode, replyToMessageId);
            }
            catch
            {
                ;
            }

            try
            {
                foreach (var e1 in exceptions.Item1)
                {
                    try
                    {
                        await NotifyOwners(e1, sender);
                    }
                    catch
                    {
                        ;
                    }
                }
            }
            catch
            {
                ;
            }

            try
            {
                var text2 = new Language(new Dictionary <string, string>
                {
                    { "en", "---End---" }
                });

                long?replyto = null;
                ;

                if (m != null)
                {
                    replyto = m.GetMessageID();
                }
                await NotifyOwners2Async(text2, sender, 0, langCode, replyto);
            }
            catch
            {
                ;
            }
        }
        private static async Task <MessageSentResult> SendExtraInfoDbForThisMessage(MessageSentResult r1, DataRow dr,
                                                                                    int?chatIdToSendTo, ChatType?chatTypeToSendTo, TelegramBotAbstract telegramBotAbstract, int count)
        {
            if (r1 == null || r1.IsSuccess() == false)
            {
                return(r1);
            }

            if (chatIdToSendTo == null)
            {
                return(new MessageSentResult(false, null, chatTypeToSendTo));
            }

            var dto  = dr["sent_date"];
            var fieo = dr["from_id_entity"];
            var fipo = dr["from_id_person"];

            DateTime?dt             = null;
            int?     from_id_entity = null;
            int?     from_id_person = null;

            try
            {
                dt = (DateTime?)dto;
            }
            catch
            {
                ;
            }

            try
            {
                from_id_entity = (int?)fieo;
            }
            catch
            {
                ;
            }

            try
            {
                from_id_person = (int?)fipo;
            }
            catch
            {
                ;
            }

            var text1 = "📌 ID: " + count + "\n";

            if (dt != null)
            {
                text1 += "📅 " + DateTimeClass.DateTimeToItalianFormat(dt) + "\n";
            }
            if (from_id_entity != null)
            {
                var entity_name = Assoc.GetNameOfEntityFromItsID(from_id_entity.Value);
                text1 += "👥 " + entity_name + "\n";
            }

            if (from_id_person != null)
            {
                text1 += "✍ " + from_id_person + "\n";
            }

            var dict = new Dictionary <string, string>
            {
                { "en", text1 }
            };
            var text2 = new Language(dict);

            return(await telegramBotAbstract.SendTextMessageAsync(chatIdToSendTo.Value, text2, chatTypeToSendTo, "",
                                                                  ParseMode.Html,
                                                                  null, null, r1.GetMessageID(), true));
        }