private void SendMessageToFriendWithNames(Filter filter) { var stack = new Stack <string>(filter.IncludedPeopleNames.ZaloSplitText()); while (stack.Count > 0) { Delay(1000); TouchAtIconBottomLeft();//Open search Delay(500); var name = stack.Pop(); TouchAt(Screen.HomeScreenFriendTabSearchTextField); Delay(500); SendText(name); var rowFriends = ZaloImageProcessing.GetFriendProfileList(CaptureScreenNow(), Screen); if (!rowFriends.Any()) { ZaloHelper.Output("Không có kết quả"); TouchAtIconTopLeft(); continue; } TouchAt(Screen.HomeScreenFriendTabSearchFristItem); Delay(500); var request = new ChatRequest() { Objective = ChatObjective.FriendInContactList, Profile = new ProfileMessage() }; NavigateToProfileScreenFromChatScreenToGetInfoThenGoBack(request); string reason; if (!filter.IsValidProfile(request.Profile, out reason)) { ZaloHelper.Output("Bỏ qua bạn này, lý do: " + reason); TouchAtIconTopLeft(); //Touch to close side bar Delay(400); } else { Chat(request, filter); TouchAtIconTopLeft();//GO BACK PROFILE } } //Search in contact }
public void SearchFriendInContactList() { try { GotoPage(Activity.MainTab); Delay(1000); TouchAt(Screen.HomeScreenFriendTab); Delay(1000); ZaloHelper.Output("Đang phân tích dữ liệu"); var fileCapture = CaptureScreenNow(); var friends = ZaloImageProcessing.GetFriendProfileList(fileCapture, Screen); ZaloHelper.OutputLine(); friends.ToList().ForEach(x => ZaloHelper.Output(x.Name)); ZaloHelper.OutputLine(); var stack = new Stack <FriendPositionMessage>(friends.Where(x => !string.IsNullOrWhiteSpace(x.Name)).OrderByDescending(x => x.Point.Y)); var profilesPage1 = stack.Select(x => x.Name).ToArray(); while (true) { while (stack.Count == 0) { ScrollList(9); ZaloHelper.Output("Đang phân tích dữ liệu màn hình"); fileCapture = CaptureScreenNow(); friends = ZaloImageProcessing.GetFriendProfileList(fileCapture, Screen); ZaloHelper.OutputLine(); friends.ToList().ForEach(x => ZaloHelper.Output(x.Name)); ZaloHelper.OutputLine(); stack = new Stack <FriendPositionMessage>(friends.OrderByDescending(x => x.Point.Y)); var profilesPage2 = stack.Select(x => x.Name).ToArray(); if (!profilesPage2.Except(profilesPage1).Any()) { ZaloHelper.Output("Hết danh sách"); return; } profilesPage1 = profilesPage2; } Delay(2000); var rowFriend = stack.Pop(); if (DbContext.ProfileSet.FirstOrDefault(x => x.Name == rowFriend.Name && x.Account == Settings.User.Username) != null) { ZaloHelper.Output($"Thu nhập thông tin bạn {rowFriend.Name} rồi"); continue; } if (!Screen.InfoRect.Contains(rowFriend.Point)) { continue; } TouchAt(rowFriend.Point); Delay(2000); //GrabInfomation TouchAtIconTopRight(); Delay(1000); TouchAt(Screen.ChatScreenProfileAvartar); Delay(2000); var profile = new ProfileMessage() { Name = rowFriend.Name }; var infoGrab = GrabProfileInfo(profile.Name); ZaloHelper.CopyProfile(ref profile, infoGrab); TouchAtIconTopLeft(); //Back to chat screen Delay(400); TouchAtIconTopLeft(); //Close sidebar Delay(400); TouchAtIconTopLeft(); //Goback friend list Delay(400); DbContext.AddProfile(profile, Settings.User.Username, true); Delay(400); } } catch (Exception ex) { _log.Error(ex); } finally { ZaloHelper.SendCompletedTaskSignal(); } }
public void SendMessageToFriendInContactList(Filter filter) { try { var countSuccess = 0; GotoPage(Activity.MainTab); Delay(1000); TouchAt(Screen.HomeScreenFriendTab); if (!string.IsNullOrWhiteSpace(filter.IncludedPeopleNames)) { SendMessageToFriendWithNames(filter); return; } Delay(1000); ZaloHelper.Output("Đang phân tích dữ liệu"); var fileCapture = CaptureScreenNow(); var friends = ZaloImageProcessing.GetFriendProfileList(fileCapture, Screen); ZaloHelper.OutputLine(); friends.ToList().ForEach(x => ZaloHelper.Output(x.Name)); ZaloHelper.OutputLine(); var stack = new Stack <FriendPositionMessage>(friends.Where(x => !string.IsNullOrWhiteSpace(x.Name)).OrderByDescending(x => x.Point.Y)); var profilesPage1 = stack.Select(x => x.Name).ToArray(); while (countSuccess <= filter.NumberOfAction) { while (stack.Count == 0) { ScrollList(9); ZaloHelper.Output("Đang phân tích dữ liệu màn hình"); fileCapture = CaptureScreenNow(); friends = ZaloImageProcessing.GetFriendProfileList(fileCapture, Screen); ZaloHelper.OutputLine(); friends.ToList().ForEach(x => ZaloHelper.Output(x.Name)); ZaloHelper.OutputLine(); stack = new Stack <FriendPositionMessage>(friends.OrderByDescending(x => x.Point.Y)); var profilesPage2 = stack.Select(x => x.Name).ToArray(); if (!profilesPage2.Except(profilesPage1).Any()) { ZaloHelper.Output("Hết danh sách"); return; } profilesPage1 = profilesPage2; } Delay(2000); var rowFriend = stack.Pop(); if (DbContext.LogMessageSentToFriendSet.FirstOrDefault(x => x.Name == rowFriend.Name && x.Account == Settings.User.Username) != null) { ZaloHelper.Output($"Đã gửi tin cho bạn {rowFriend.Name} rồi"); continue; } var profile = DbContext.ProfileSet.FirstOrDefault(x => x.Name == rowFriend.Name); var request = new ChatRequest { Profile = new ProfileMessage { Name = rowFriend.Name, Location = profile?.Location, PhoneNumber = profile?.PhoneNumber }, Objective = ChatObjective.FriendInContactList }; if (Screen.InfoRect.Contains(rowFriend.Point)) { TouchAt(rowFriend.Point); Delay(2000); NavigateToProfileScreenFromChatScreenToGetInfoThenGoBack(request); string reason; if (!filter.IsValidProfile(request.Profile, out reason)) { ZaloHelper.Output("Bỏ qua bạn này, lý do: " + reason); TouchAtIconTopLeft(); //Touch to close side bar Delay(400); } else { if (Chat(request, filter)) { countSuccess++; if (profile == null) { DbContext.AddProfile(request.Profile, Settings.User.Username); } } TouchAtIconTopLeft();//GO BACK PROFILE } } } } catch (Exception ex) { _log.Error(ex); } finally { ZaloHelper.SendCompletedTaskSignal(); } }