示例#1
0
        private async void Main_Load(object sender, EventArgs e)
        {
            bool anticaptchaInitialized = AnticaptchaWorker.TryInitialize();

            if (anticaptchaInitialized)
            {
                this.Text = $"Главная | Баланс: {AnticaptchaWorker.Api.GetBalance()}";
            }

            VkApp.Auth();
            await WinFormsExt.LoadListsAsync();

            foreach (var friendList in VkApp.CurrentFriendlists)
            {
                this.lstFriendLists.Items.Add($"{friendList.Id}: {friendList.Name}");
                this.lstExclude.Items.Add($"{friendList.Id}: {friendList.Name}");
            }

            this.lstFriendLists.SetSelected(0, true);

            await this.UpdateMessagesSentCount();
        }
示例#2
0
        private async Task SendToListAsync(IEnumerable <VkNet.Model.User> currentFriendlist, Button buttonSend)
        {
            string _messageTemplate = this.txtMessage.Text.Trim();

            int allFriendsInListCount = currentFriendlist.Count();
            int sentCount             = 0;

            foreach (var friend in currentFriendlist)
            {
                if (this.MessageCache.AlreadySentMessage(_messageTemplate, friend.Id))
                {
                    continue;
                }

                string messageToCurrentFriend = _messageTemplate.Replace("<firstname>", friend.FirstName);

                var isSent = await this.TrySendMessage(messageToCurrentFriend, friend.Id);

                if (isSent)
                {
                    this.MessageCache.Add(_messageTemplate, friend.Id);
                    sentCount++;
                    await this.UpdateMessagesSentCount();
                }

                AnticaptchaWorker.ClearCaptchaInfo();

                if (AnticaptchaWorker.Api != null)
                {
                    this.Text = $"Главная | Баланс: {AnticaptchaWorker.Api.GetBalance()} | {buttonSend.Text}";
                }
                else
                {
                    this.Text = $"Главная | Баланс: --- | {buttonSend.Text}";
                }
            }
        }