public static FB_Page _from_graphql(JToken data) { if (data.get("profile_picture") == null) { data["profile_picture"] = new JObject(new JProperty("uri", "")); } if (data.get("city") == null) { data["city"] = new JObject(new JProperty("name", "")); } FB_Plan plan = null; if (data.get("event_reminders") != null && data.get("event_reminders")?.get("nodes") != null) { plan = FB_Plan._from_graphql(data.get("event_reminders")?.get("nodes")?.FirstOrDefault()); } return(new FB_Page( uid: data.get("id")?.Value <string>(), url: data.get("url")?.Value <string>(), city: data.get("city")?.get("name")?.Value <string>(), category: data.get("category_type")?.Value <string>(), photo: data.get("profile_picture")?.get("uri")?.Value <string>(), name: data.get("name")?.Value <string>(), message_count: data.get("messages_count")?.Value <int>() ?? 0, plan: plan )); }
/// <summary> /// Represents a Facebook thread /// </summary> /// <param name="type"></param> /// <param name="uid"></param> /// <param name="photo"></param> /// <param name="name"></param> /// <param name="last_message_timestamp"></param> /// <param name="message_count"></param> /// <param name="plan"></param> public FB_Thread(ThreadType type, string uid, string photo = null, string name = null, string last_message_timestamp = null, int message_count = 0, FB_Plan plan = null) { this.uid = uid; this.type = type; this.photo = photo; this.name = name; this.last_message_timestamp = last_message_timestamp; this.message_count = message_count; this.plan = plan; }
/// <summary> /// Represents a Facebook thread /// </summary> /// <param name="uid"></param> /// <param name="session"></param> /// <param name="photo"></param> /// <param name="name"></param> /// <param name="last_message_timestamp"></param> /// <param name="message_count"></param> /// <param name="plan"></param> public FB_Thread(string uid, Session session, FB_Image photo = null, string name = null, string last_message_timestamp = null, int message_count = 0, FB_Plan plan = null) { this.uid = uid; this.session = session; this.photo = photo; this.name = name; this.last_message_timestamp = last_message_timestamp; this.message_count = message_count; this.plan = plan; }
internal static FB_PlanDeleted _parse(Session session, JToken data) { (FB_User author, FB_Thread thread, long at) = FB_PlanDeleted._parse_metadata(session, data); var plan = FB_Plan._from_pull(data?.get("untypedData"), session); return(new FB_PlanDeleted() { author = author, thread = thread, plan = plan, at = at }); }
/// <summary> /// Fetches a `Plan` object from the plan id /// </summary> /// <returns></returns> public async Task <FB_Plan> fetch() { /* * Fetch fresh `PlanData` object. * */ var data = new Dictionary <string, object>() { { "event_reminder_id", this.uid } }; var j = await this.session._payload_post("/ajax/eventreminder", data); return(FB_Plan._from_fetch(j, session)); }
public static FB_Plan _from_graphql(JToken data) { FB_Plan rtn = new FB_Plan( time: data.get("time")?.Value <string>(), title: data.get("event_title")?.Value <string>(), location: data.get("location_name")?.Value <string>() ); rtn.uid = data.get("id")?.Value <string>(); rtn.author_id = data.get("lightweight_event_creator")?.get("id")?.Value <string>(); rtn.guests = data.get("event_reminder_members")?.get("edges")?.Select((x) => { return(new { Key = x.get("node")?.get("id")?.Value <string>(), Value = FB_Plan_Constants.GUESTS[x.get("guest_list_state")?.Value <string>()] }); }).ToDictionary(t => t.Key, t => t.Value); return(rtn); }
internal static FB_PlanResponded _parse(Session session, JToken data) { (FB_User author, FB_Thread thread, long at) = FB_PlanResponded._parse_metadata(session, data); var plan = FB_Plan._from_pull(data?.get("untypedData"), session); var take_part = data.get("untypedData")?.get("guest_status")?.Value <string>() == "GOING"; return(new FB_PlanResponded() { author = author, thread = thread, plan = plan, take_part = take_part, at = at }); }
internal static FB_User _from_graphql(Session session, JToken data) { var c_info = FB_User._parse_customization_info(data); var plan = data.get("event_reminders")?.get("nodes")?.FirstOrDefault() != null? FB_Plan._from_graphql(data.get("event_reminders")?.get("nodes")?.FirstOrDefault(), session) : null; var name = data.get("name")?.Value <string>(); var first_name = data.get("first_name")?.Value <string>() ?? data.get("short_name")?.Value <string>(); var last_name = first_name != null?name?.Replace(first_name, "")?.Trim() : null; var gender = GENDER.graphql_GENDERS["UNKNOWN"]; if (data.get("gender")?.Type == JTokenType.Integer) { gender = GENDER.standard_GENDERS[data.get("gender")?.Value <int>() ?? 0]; } else { int gender_int = 0; if (int.TryParse(data.get("gender")?.Value <string>(), out gender_int)) { gender = GENDER.standard_GENDERS[gender_int]; } else { gender = GENDER.graphql_GENDERS[data.get("gender")?.Value <string>() ?? "UNKNOWN"]; } }; return(new FB_User( uid: data.get("id")?.Value <string>(), session: session, url: data.get("url")?.Value <string>(), name: name, first_name: first_name, last_name: last_name, is_friend: data.get("is_viewer_friend")?.Value <bool>() ?? false, gender: gender, affinity: data.get("viewer_affinity")?.Value <float>() ?? 0, nickname: (string)c_info.GetValueOrDefault("nickname"), color: (string)c_info.GetValueOrDefault("color"), emoji: (JToken)c_info.GetValueOrDefault("emoji"), own_nickname: (string)c_info.GetValueOrDefault("own_nickname"), photo: FB_Image._from_uri_or_none(data?.get("profile_picture")), message_count: data.get("messages_count")?.Value <int>() ?? 0, plan: plan)); }
public static FB_Plan _from_fetch(JToken data) { FB_Plan rtn = new FB_Plan( time: data.get("event_time")?.Value <string>(), title: data.get("title")?.Value <string>(), location: data.get("location_name")?.Value <string>(), location_id: data.get("location_id")?.Value <string>() ); rtn.uid = data.get("oid")?.Value <string>(); rtn.author_id = data.get("creator_id")?.Value <string>(); rtn.guests = data.get("event_members")?.Value <JObject>().Properties().Select((x) => { return(new { Key = x.Name, Value = FB_Plan_Constants.GUESTS[x.Value?.Value <string>()] }); }).ToDictionary(t => t.Key, t => t.Value); return(rtn); }
public static FB_Plan _from_pull(JToken data) { FB_Plan rtn = new FB_Plan( time: data.get("event_time")?.Value <string>(), title: data.get("event_title")?.Value <string>(), location: data.get("event_location_name")?.Value <string>(), location_id: data.get("event_location_id")?.Value <string>() ); rtn.uid = data.get("event_id")?.Value <string>(); rtn.author_id = data.get("event_creator_id")?.Value <string>(); rtn.guests = JToken.Parse(data.get("guest_state_list")?.Value <string>()).Select((x) => { return(new { Key = x.get("node")?.get("id")?.Value <string>(), Value = FB_Plan_Constants.GUESTS[x.get("guest_list_state")?.Value <string>()] }); }).ToDictionary(t => t.Key, t => t.Value); return(rtn); }
internal static FB_User _from_thread_fetch(Session session, JToken data) { var c_info = FB_User._parse_customization_info(data); var participants = data.get("all_participants")?.get("nodes")?.Select(node => node.get("messaging_actor")); var user = participants.Where((p) => p.get("id")?.Value <string>() == data.get("thread_key")?.get("other_user_id")?.Value <string>())?.FirstOrDefault(); var last_message_timestamp = data.get("last_message")?.get("nodes")?.FirstOrDefault()?.get("timestamp_precise")?.Value <string>(); var name = user.get("name")?.Value <string>(); var first_name = user.get("first_name")?.Value <string>() ?? user.get("short_name")?.Value <string>(); var last_name = first_name != null?name?.Replace(first_name, "")?.Trim() : null; var gender = GENDER.graphql_GENDERS["UNKNOWN"]; if (data.get("gender")?.Type == JTokenType.Integer) { gender = GENDER.standard_GENDERS[data.get("gender")?.Value <int>() ?? 0]; } else { int gender_int = 0; if (int.TryParse(data.get("gender")?.Value <string>(), out gender_int)) { gender = GENDER.standard_GENDERS[gender_int]; } else { gender = GENDER.graphql_GENDERS[data.get("gender")?.Value <string>() ?? "UNKNOWN"]; } }; var plan = data.get("event_reminders")?.get("nodes")?.FirstOrDefault() != null?FB_Plan._from_graphql(data.get("event_reminders")?.get("nodes")?.FirstOrDefault(), session) : null; return(new FB_User( uid: user.get("id")?.Value <string>(), session: session, url: user.get("url")?.Value <string>(), name: name, first_name: first_name, last_name: last_name, is_friend: user.get("is_viewer_friend")?.Value <bool>() ?? false, gender: gender, affinity: user.get("viewer_affinity")?.Value <float>() ?? 0, nickname: (string)c_info.GetValueOrDefault("nickname"), color: (string)c_info.GetValueOrDefault("color"), emoji: (JToken)c_info.GetValueOrDefault("emoji"), own_nickname: (string)c_info.GetValueOrDefault("own_nickname"), photo: FB_Image._from_uri_or_none(user?.get("big_image_src")), message_count: data.get("messages_count")?.Value <int>() ?? 0, last_message_timestamp: last_message_timestamp, //last_active = _util.millis_to_datetime(int(data["updated_time_precise"])), plan: plan)); }
/// <summary> /// Represents a Facebook user. Inherits `Thread` /// </summary> /// <param name="uid"></param> /// <param name="session"></param> /// <param name="photo"></param> /// <param name="name"></param> /// <param name="message_count"></param> /// <param name="last_message_timestamp"></param> /// <param name="plan"></param> /// <param name="url"></param> /// <param name="first_name"></param> /// <param name="last_name"></param> /// <param name="is_friend"></param> /// <param name="gender"></param> /// <param name="affinity"></param> /// <param name="nickname"></param> /// <param name="own_nickname"></param> /// <param name="color"></param> /// <param name="emoji"></param> public FB_User(string uid, Session session, FB_Image photo = null, string name = null, int message_count = 0, string last_message_timestamp = null, FB_Plan plan = null, string url = null, string first_name = null, string last_name = null, bool is_friend = false, string gender = null, float affinity = 0, string nickname = null, string own_nickname = null, string color = null, JToken emoji = null) : base(uid, session, photo, name, message_count: message_count, last_message_timestamp: last_message_timestamp, plan: plan) { this.url = url; this.first_name = first_name; this.last_name = last_name ?? (first_name != null ? name?.Replace(first_name, "")?.Trim() : null); this.is_friend = is_friend; this.gender = gender; this.affinity = affinity; this.nickname = nickname; this.own_nickname = own_nickname; this.color = color ?? ThreadColor.MESSENGER_BLUE; this.emoji = emoji; }
public static FB_Marketplace _from_graphql(JToken data) { if (data.get("image") == null) { data["image"] = new JObject(new JProperty("uri", "")); } var c_info = FB_Group._parse_customization_info(data); var last_message_timestamp = data.get("last_message")?.get("nodes")?.FirstOrDefault()?.get("timestamp_precise")?.Value <string>(); var plan = data.get("event_reminders")?.get("nodes")?.FirstOrDefault() != null?FB_Plan._from_graphql(data.get("event_reminders")?.get("nodes")?.FirstOrDefault()) : null; return(new FB_Marketplace( uid: data.get("thread_key")?.get("thread_fbid")?.Value <string>(), participants: new HashSet <string>(data.get("all_participants")?.get("nodes")?.Select(node => node.get("messaging_actor")?.get("id")?.Value <string>())), nicknames: (Dictionary <string, string>)c_info.GetValueOrDefault("nicknames"), color: (string)c_info.GetValueOrDefault("color"), emoji: (JToken)c_info.GetValueOrDefault("emoji"), admins: new HashSet <string>(data.get("thread_admins")?.Select(node => node.get("id")?.Value <string>())), approval_mode: data.get("approval_mode")?.Value <bool>() ?? false, approval_requests: data.get("group_approval_queue") != null ? new HashSet <string>(data.get("group_approval_queue")?.get("nodes")?.Select(node => node.get("requester")?.get("id")?.Value <string>())) : null, photo: data.get("image")?.get("uri")?.Value <string>(), name: data.get("name")?.Value <string>(), message_count: data.get("messages_count")?.Value <int>() ?? 0, last_message_timestamp: last_message_timestamp, plan: plan)); }
/// <summary> /// Represents a Facebook marketplace. Inherits `Thread` /// </summary> /// <param name="uid"></param> /// <param name="photo"></param> /// <param name="name"></param> /// <param name="message_count"></param> /// <param name="last_message_timestamp"></param> /// <param name="plan"></param> /// <param name="participants"></param> /// <param name="nicknames"></param> /// <param name="color"></param> /// <param name="emoji"></param> /// <param name="admins"></param> /// <param name="approval_mode"></param> /// <param name="approval_requests"></param> /// <param name="join_link"></param> public FB_Marketplace(string uid, string photo = null, string name = null, int message_count = 0, string last_message_timestamp = null, FB_Plan plan = null, ISet <string> participants = null, Dictionary <string, string> nicknames = null, string color = null, JToken emoji = null, ISet <string> admins = null, bool approval_mode = false, ISet <string> approval_requests = null, string join_link = null) : base(ThreadType.MARKETPLACE, uid, photo, name, message_count: message_count, last_message_timestamp: last_message_timestamp, plan: plan) { this.participants = participants ?? new HashSet <string>(); this.nicknames = nicknames ?? new Dictionary <string, string>(); this.color = color ?? ThreadColor.MESSENGER_BLUE; this.emoji = emoji; this.admins = admins ?? new HashSet <string>(); this.approval_mode = approval_mode; this.approval_requests = approval_requests ?? new HashSet <string>(); this.join_link = join_link; }
/// <summary> /// Represents a Facebook page. Inherits `Thread` /// </summary> /// <param name="uid"></param> /// <param name="photo"></param> /// <param name="name"></param> /// <param name="message_count"></param> /// <param name="plan"></param> /// <param name="url"></param> /// <param name="city"></param> /// <param name="likes"></param> /// <param name="sub_title"></param> /// <param name="category"></param> public FB_Page(string uid, string photo = null, string name = null, int message_count = 0, FB_Plan plan = null, string url = null, string city = null, int likes = 0, string sub_title = null, string category = null) : base(ThreadType.PAGE, uid, photo, name, message_count: message_count, plan: plan) { // Represents a Facebook page. Inherits `Thread` this.url = url; this.city = city; this.likes = likes; this.sub_title = sub_title; this.category = category; }
/// <summary> /// Represents a Facebook room. Inherits `Group` /// </summary> /// <param name="uid"></param> /// <param name="photo"></param> /// <param name="name"></param> /// <param name="message_count"></param> /// <param name="last_message_timestamp"></param> /// <param name="plan"></param> /// <param name="participants"></param> /// <param name="nicknames"></param> /// <param name="color"></param> /// <param name="emoji"></param> /// <param name="admins"></param> /// <param name="approval_mode"></param> /// <param name="approval_requests"></param> /// <param name="join_link"></param> /// <param name="privacy_mode"></param> public FB_Room(string uid, string photo = null, string name = null, int message_count = 0, string last_message_timestamp = null, FB_Plan plan = null, ISet <string> participants = null, Dictionary <string, string> nicknames = null, string color = null, string emoji = null, ISet <string> admins = null, bool approval_mode = false, ISet <string> approval_requests = null, string join_link = null, bool privacy_mode = false) : base(uid, photo, name, message_count, last_message_timestamp, plan, participants, nicknames, color, emoji, admins, approval_mode, approval_requests, join_link) { this.type = ThreadType.ROOM; this.privacy_mode = privacy_mode; }