internal static FB_ParticipantRemoved _parse(Session session, JToken data) { (FB_User author, FB_Thread thread, long at) = FB_ParticipantRemoved._parse_metadata(session, data); var removed = new FB_User(data?.get("leftParticipantFbId")?.Value <string>(), session); return(new FB_ParticipantRemoved() { author = author, thread = thread as FB_Group, removed = removed, at = at }); }
internal static FB_ParticipantRemoved _from_fetch(FB_Thread thread, JToken data) { (FB_User author, long at) = FB_ParticipantRemoved._parse_fetch(thread.session, data); var removed = new FB_User(data?.get("participants_removed")?.FirstOrDefault()?.get("id")?.Value <string>(), thread.session); return(new FB_ParticipantRemoved() { author = author, thread = thread as FB_Group, removed = removed, at = at }); }
/// <summary> /// Remove user from the group. /// If the group's approval mode is set to require admin approval, and you're not an /// admin, this will fail. /// Args: /// user_id: User ID to remove /// Example: /// >>> group.remove_participant("1234") /// </summary> /// <param name="user_id">User ID to remove</param> /// <returns></returns> public async Task <FB_ParticipantRemoved> removeParticipant(string user_id) { /* * Removes users from a group. * :param user_id: User ID to remove * :raises: FBchatException if request failed * */ var data = new Dictionary <string, object>() { { "uid", user_id }, { "tid", this.uid } }; var j = await this.session._payload_post("/chat/remove_participants/", data); return(FB_ParticipantRemoved._from_send(thread: this, removed_id: user_id)); }
public static FB_Event parse_delta(Session session, JToken data) { var class_ = data?.get("class")?.Value <string>(); if (class_ == "ParticipantsAddedToGroupThread") { return(FB_ParticipantsAdded._parse(session, data)); } else if (class_ == "ParticipantLeftGroupThread") { return(FB_ParticipantRemoved._parse(session, data)); } else if (class_ == "MarkFolderSeen") { // TODO: Finish this var folders = data.get("folders")?.Select(folder => folder?.Value <string>().Replace("FOLDER_", "")); var at = long.Parse(data?.get("timestamp")?.Value <string>()); return(null); } else if (class_ == "ThreadName") { return(FB_TitleSet._parse(session, data)); } else if (class_ == "ForcedFetch") { return(FB_UnfetchedThreadEvent._parse(session, data)); } else if (class_ == "DeliveryReceipt") { return(FB_MessagesDelivered._parse(session, data)); } else if (class_ == "ReadReceipt") { return(FB_ThreadsRead._parse_read_receipt(session, data)); } else if (class_ == "MarkRead") { return(FB_ThreadsRead._parse(session, data)); } else if (class_ == "NoOp") { // Skip "no operation" events return(null); } else if (class_ == "ClientPayload") { throw new FBchatParseError("This is implemented in `parse_events`"); } else if (class_ == "NewMessage") { return(FB_MessageEvent._parse(session, data)); } else if (class_ == "ThreadFolder") { return(FB_ThreadFolder._parse(session, data)); } return(new FB_UnknownEvent() { source = "Delta class", data = data }); }