コード例 #1
0
        public static async Task <TLAbsUpdates> SendMessageUserBot(TelegramClient userbotClient,
                                                                   TLAbsInputPeer peer, Language text, string username, TLAbsReplyMarkup tlAbsReplyMarkup, string lang,
                                                                   long?replyToMessageId, bool disablePreviewLink)
        {
            TLAbsUpdates r2;

            try
            {
                r2 = await userbotClient.SendMessageAsync(peer, text.Select(lang), replyMarkup : tlAbsReplyMarkup);
            }
            catch
            {
                if (string.IsNullOrEmpty(username))
                {
                    return(null);
                }

                var peerBetter = await UserbotPeer.GetPeerUserWithAccessHash(username, userbotClient);

                try
                {
                    r2 = await userbotClient.SendMessageAsync(peerBetter, text.Select(lang),
                                                              replyMarkup : tlAbsReplyMarkup);
                }
                catch
                {
                    return(null);
                }
            }

            return(r2);
        }
コード例 #2
0
        public static async Task <bool> FixTheFactThatSomeGroupsDoesNotHaveOurModerationBot2(
            TelegramBotAbstract telegramBotAbstract)
        {
            const int      LIMIT = 20;
            var            i     = 0;
            TLAbsInputPeer u     =
                await UserbotPeer.GetPeerUserWithAccessHash("polinetwork3bot", telegramBotAbstract._userbotClient);

            if (u == null)
            {
                return(false);
            }

            id_of_chats_we_know_are_ok = new Dictionary <long, bool>();

            while (true)
            {
                TLAbsDialogs   x = null;
                FloodException floodException1 = null;
                try
                {
                    x = await telegramBotAbstract._userbotClient.GetUserDialogsAsync(limit : LIMIT, offsetId : i);
                }
                catch (FloodException floodException)
                {
                    floodException1 = floodException;
                }

                if (x == null && floodException1 != null)
                {
                    var untilWhen = GetUntilWhenWeCanMakeRequests(floodException1);
                    WaitUntil(untilWhen);

                    try
                    {
                        x = await telegramBotAbstract._userbotClient.GetUserDialogsAsync(limit : LIMIT, offsetId : i);
                    }
                    catch (Exception e7)
                    {
                        ;
                    }
                }

                if (x == null)
                {
                    return(i > 0);
                }

                if (x is TLDialogs x2)
                {
                    if (x2.Chats != null)
                    {
                        foreach (var x4 in x2.Chats)
                        {
                            var r1 = await FixTheFactThatSomeGroupsDoesNotHaveOurModerationBot3(x4, u,
                                                                                                telegramBotAbstract);

                            await NotifyUtil.NotifyIfFalseAsync(r1, 1.ToString(), telegramBotAbstract);
                        }
                    }
                }
                else if (x is TLDialogsSlice x3)
                {
                    if (x3.Chats != null)
                    {
                        foreach (var x4 in x3.Chats)
                        {
                            var r1 = await FixTheFactThatSomeGroupsDoesNotHaveOurModerationBot3(x4, u,
                                                                                                telegramBotAbstract);

                            await NotifyUtil.NotifyIfFalseAsync(r1, 2.ToString(), telegramBotAbstract);
                        }
                    }
                }
                else
                {
                    ;
                }

                i += LIMIT;
            }

            throw new NotImplementedException();
        }