/// <summary> /// Creates an Instance of the TwitchAPI Class. /// </summary> /// <param name="logger">Instance Of Logger, otherwise no logging is used, </param> /// <param name="rateLimiter">Instance Of RateLimiter, otherwise no ratelimiter is used. </param> public TwitchAPI(ILogger <TwitchAPI> logger = null, IRateLimiter rateLimiter = null) { _logger = logger; _http = new HttpClient(new TwitchLibCustomHttpMessageHandler(new HttpClientHandler(), _logger)); _rateLimiter = rateLimiter ?? BypassLimiter.CreateLimiterBypassInstance(); Auth = new Auth(this); Blocks = new Blocks(this); Badges = new Badges(this); Bits = new Bits(this); ChannelFeeds = new ChannelFeeds(this); Channels = new Channels(this); Chat = new Chat(this); Clips = new Clips(this); Collections = new Collections(this); Communities = new Communities(this); Follows = new Follows(this); Games = new Games(this); Ingests = new Ingests(this); Root = new Root(this); Search = new Search(this); Streams = new Streams(this); Subscriptions = new Subscriptions(this); Teams = new Teams(this); ThirdParty = new ThirdParty(this); Undocumented = new Undocumented(this); Users = new Users(this); Videos = new Videos(this); Webhooks = new Webhooks(this); Debugging = new Debugging(); Settings = new ApiSettings(this); _jsonSerializer = new TwitchLibJsonSerializer(); }
private void Unfollow(User user) { Communities.Unfollow(FollowQuery.Users(UserIdList.Create(user.Id)), count => { _follows[user.Id] = false; }, error => _console.LogE(error.Message)); }
public void AddUser(VkBrwUser user) { Users.Add(user); if (user.Communitites.Count > 0) { foreach (VkBrwCommunity community in user.Communitites) { VkBrwCommunity existingCommunity = Communities.FirstOrDefault(c => c.CommunityId == community.CommunityId); if (existingCommunity == null) { Communities.Add(community); } else { VkBrwUser existingUser = existingCommunity.Users.FirstOrDefault(u => u.ProfileLink == user.ProfileLink); if (existingUser == null) { existingCommunity.Users.Add(user); } } } } }
private void Refresh(Topic topic) { Communities.GetTopic(topic.Id, refreshed => { _items[_items.FindIndex(item => item == topic)] = refreshed; }, error => _console.LogE(error.ToString())); }
private void Follow(Topic topic) { Communities.Follow(FollowQuery.Topics(topic.Id), count => { Refresh(topic); }, error => _console.LogE(error.Message)); }
private void AreFriends() { Communities.AreFriends(FormUserList(), result => { _console.LogD("Are friends: " + result.ToDebugString()); }, OnError); }
private void SetFriends() { Communities.SetFriends(FormUserList(), total => { _console.LogD("New friends total:" + total); }, OnError); }
private void GetUsers() { Communities.GetUsers(FormUserList(), users => { _console.LogD("Users: " + users.ToDebugString()); }, OnError); }
private void OnUserAvatarClicked(User publicUser) { if (GetSocial.GetCurrentUser().Id.Equals(publicUser.Id)) { var popup = new MNPopup("Action", "Choose Action"); popup.AddAction("Show My Feed", () => OpenUserGlobalFeed(publicUser)); popup.AddAction("Cancel", () => { }); popup.Show(); } else { Communities.IsFriend(UserId.Create(publicUser.Id), isFriend => { if (isFriend) { var popup = new MNPopup("Action", "Choose Action"); popup.AddAction("Show " + publicUser.DisplayName + " Feed", () => OpenUserGlobalFeed(publicUser)); popup.AddAction("Remove from Friends", () => RemoveFriend(publicUser)); popup.AddAction("Cancel", () => { }); popup.Show(); } else { var popup = new MNPopup("Action", "Choose Action"); popup.AddAction("Show " + publicUser.DisplayName + " Feed", () => OpenUserGlobalFeed(publicUser)); popup.AddAction("Add to Friends", () => AddFriend(publicUser)); popup.AddAction("Cancel", () => { }); popup.Show(); } }, error => _console.LogE("Failed to check if friends with " + publicUser.DisplayName + ", error:" + error.Message)); } }
/// <summary> /// Creates an Instance of the TwitchAPI Class. /// </summary> /// <param name="logger">Instance Of Logger, otherwise no logging is used, </param> /// <param name="rateLimiter">Instance Of RateLimiter, otherwise no ratelimiter is used. </param> public TwitchAPI(ILoggerFactory loggerFactory = null, IRateLimiter rateLimiter = null, IHttpCallHandler http = null) { _logger = loggerFactory?.CreateLogger <TwitchAPI>(); _http = http ?? new TwitchHttpClient(loggerFactory?.CreateLogger <TwitchHttpClient>()); _rateLimiter = rateLimiter ?? BypassLimiter.CreateLimiterBypassInstance(); Analytics = new Analytics(this); Auth = new Auth(this); Badges = new Badges(this); Bits = new Bits(this); ChannelFeeds = new ChannelFeeds(this); Channels = new Channels(this); Chat = new Chat(this); Clips = new Clips(this); Collections = new Collections(this); Communities = new Communities(this); Entitlements = new Entitlements(this); Games = new Games(this); Ingests = new Ingests(this); Root = new Root(this); Search = new Search(this); Streams = new Streams(this); Teams = new Teams(this); ThirdParty = new ThirdParty(this); Undocumented = new Undocumented(this); Users = new Users(this); Videos = new Videos(this); Webhooks = new Webhooks(this); Debugging = new Debugging(); Settings = new ApiSettings(this); _jsonSerializer = new TwitchLibJsonSerializer(); }
private void React(Activity activity) { var popup = Dialog().WithTitle("Actions"); var reactions = new List <string> { Reactions.Like, Reactions.Angry, Reactions.Haha, Reactions.Love, Reactions.Sad, Reactions.Wow }; foreach (var reaction in reactions) { popup.AddAction(reaction, () => { Communities.AddReaction(reaction, activity.Id, () => { Refresh(activity); _console.LogD("Reacted to activity", false); }, error => _console.LogE(error.ToString())); }); } if (activity.MyReactions.Count > 0) { popup.AddAction("Delete Reaction", () => { Communities.RemoveReaction(activity.MyReactions.First(), activity.Id, () => { Refresh(activity); _console.LogD("Reacted to activity", false); }, error => _console.LogE(error.ToString())); }); } popup.AddAction("Cancel", () => { }); popup.Show(); }
private void RemoveFriend(User user) { Communities.RemoveFriends(UserIdList.Create(user.Id), count => { _console.LogD($"Friend Removed: {count}", false); }, error => _console.LogE(error.Message)); }
private void Follow() { Communities.Follow(FollowQuery.Users(FormUserList()), newFollows => { _console.LogD("Followed user, total: " + newFollows); }, OnError); }
private void IsFollowing() { Communities.IsFollowing(UserId.CurrentUser(), FollowQuery.Users(FormUserList()), follows => { _console.LogD("Current user is following: " + follows.ToDebugString()); }, OnError); }
public async Task <VkApiCommunity> DiscoverCommunityAsync(string groupId) { VkApiCommunity result = null; try { //"kate_kul" error 100 var groupInfo = await UserApi.Groups.GetByIdAsync(null, groupId, GroupsFields.All); if (groupInfo.Count == 1) { VkApiCommunity community = new VkApiCommunity(this, groupInfo[0]); if (Communities.FirstOrDefault(c => c.Id == community.Id) == null) { Communities.Add(community); } result = community; } } catch (ParameterMissingOrInvalidException) { Console.WriteLine("Error discovering community " + groupId + ": community not found."); } catch (Exception e) { Console.WriteLine("Error discovering community " + groupId + ": " + e); } return(result); }
private void Refresh(Activity activity) { Communities.GetActivity(activity.Id, refreshed => { _items[_items.FindIndex(item => item == activity)] = refreshed; }, error => _console.LogE(error.ToString())); }
void newFriend(string userId) { Communities.GetUser(UserId.Create(userId), user => { DemoUtils.ShowPopup("You have a new friend!", user.DisplayName + " is now your friend."); }, error => { _console.LogE("Failed to get user: "******", code: " + error.ErrorCode); }); }
public ActionResult DeleteConfirmed(int id) { Communities communities = db.Communities.Find(id); db.Communities.Remove(communities); db.SaveChanges(); return(RedirectToAction("Index")); }
private void RemoveFriend(User user) { Communities.RemoveFriends(UserIdList.Create(user.Id), count => { _areFriends[user.Id] = false; _follows[user.Id] = false; }, error => _console.LogE(error.Message)); }
private void OnMentionClicked(string mention) { if (mention.Equals(MentionTypes.App)) { _console.LogD("Application mention clicked."); return; } Communities.GetUser(UserId.Create(mention), OnUserAvatarClicked, error => _console.LogE("Failed to get user details, error:" + error.Message)); }
public ActionResult MutualHelp(Communities com) { using (var db = new BlogDbContext()) { var comId = com.Id; comId = 3; var posts = db.Posts.Include(p => p.Author).Where(p => p.CommunityId == comId).ToList(); return(View(posts)); } }
public ActionResult DeleteConfirmed(Guid id) { var db = new ApplicationDbContext(); Communities communities = db.Communities.Find(id); db.Communities.Remove(communities); db.SaveChanges(); return(RedirectToAction("Administration", "Communities")); }
private void RemoveFriend(User user) { Communities.RemoveFriends(UserIdList.Create(user.Id), friendsCount => { var message = user.DisplayName + " is not your friend anymore."; _console.LogD(message); }, error => _console.LogE("Failed to remove a friend " + user.DisplayName + ", error:" + error.Message)); }
private void AddFriend(User user) { Communities.AddFriends(UserIdList.Create(user.Id), friendsCount => { var message = user.DisplayName + " is now your friend."; _console.LogD(message); }, error => _console.LogE("Failed to add a friend " + user.DisplayName + ", error:" + error.Message)); }
private void LoadDekalbCommunityData() { //Reading input files. string[] persons = File.ReadAllLines(@"../../../DataLoader/InputFiles/Dekalb/p.txt"); string[] houses = File.ReadAllLines(@"../../../DataLoader/InputFiles/Dekalb/r.txt"); string[] apartments = File.ReadAllLines(@"../../../DataLoader/InputFiles/Dekalb/a.txt"); string[] schools = File.ReadAllLines(@"../../../DataLoader/InputFiles/Dekalb/s.txt"); string[] business = File.ReadAllLines(@"../../../DataLoader/InputFiles/Dekalb/b.txt"); //Iterating over each of the input files and type casting them to relevant class types. foreach (var item in persons) { string[] items = item.Split('\t'); Person p = new Person(items); lstDekalbPersons.Add(p); } lstDekalbPersons.Sort(new PersonComparer()); foreach (var item in houses) { string[] items = item.Split('\t'); House h = new House(items); lstDekalbHouses.Add(h); } lstDekalbHouses.Sort(new PropertyComparer()); foreach (var item in apartments) { string[] items = item.Split('\t'); Apartment a = new Apartment(items); lstDekalbApartments.Add(a); } lstDekalbApartments.Sort(new PropertyComparer()); foreach (var item in schools) { string[] items = item.Split('\t'); School s = new School(items); lstDekalbSchools.Add(s); } foreach (var item in business) { string[] items = item.Split('\t'); Business b = new Business(items); lstDekalbBusiness.Add(b); } Community community = new Community(lstDekalbPersons, lstDekalbHouses, lstDekalbApartments, lstDekalbSchools, lstDekalbBusiness); Communities.Add(community); }
protected void ShowActions(User user) { Communities.IsFollowing(UserId.CurrentUser(), FollowQuery.Users(UserIdList.Create(user.Id)), result => { var isFollower = result.ContainsKey(user.Id) && result[user.Id]; Communities.IsFriend(UserId.Create(user.Id), isFriend => { ShowActions(user, isFollower, isFriend); }, error => _console.LogE(error.ToString())); }, error => _console.LogE(error.ToString())); }
public AuditXmlUpdate Merge(AuditXmlUpdate other) { return(new AuditXmlUpdate { Communities = Communities.Concat(other.Communities).DistinctBy(x => x.Name), Friends = Friends.Concat(other.Friends).DistinctBy(x => x.Id), Meetups = Meetups.Concat(other.Meetups).DistinctBy(x => x.Id), Speakers = Speakers.Concat(other.Speakers).DistinctBy(x => x.Id), Talks = Talks.Concat(other.Talks).DistinctBy(x => x.Id), Venues = Venues.Concat(other.Venues).DistinctBy(x => x.Id) }); }
public ActionResult Edit([Bind(Include = "CommunityId,CreationDate,Name,UserId")] Communities communities) { var db = new ApplicationDbContext(); if (ModelState.IsValid) { db.Entry(communities).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Community", "Communities", new { ComId = communities.CommunityId })); } return(View(communities)); }
// GET: Organizations/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Communities communities = db.Communities.Find(id); if (communities == null) { return(HttpNotFound()); } return(View(communities)); }
// GET: Organizations/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Communities organizations = db.Communities.Find(id); if (organizations == null) { return(HttpNotFound()); } return(View(organizations)); }