internal static FB_LocationAttachment _from_graphql(JToken data) { var url = data.get("url")?.Value <string>(); var address = Utils.get_url_parameter(Utils.get_url_parameter(url, "u"), "where1"); double latitude = 0, longitude = 0; try { var split = address.Split(new[] { ", " }, StringSplitOptions.None); latitude = Double.Parse(split[0]); longitude = Double.Parse(split[1]); address = null; } catch (Exception) { } var rtn = new FB_LocationAttachment( uid: data.get("deduplication_key")?.Value <string>(), latitude: latitude, longitude: longitude, address: address); var media = data.get("media"); if (media != null && media.get("image") != null) { rtn.image = FB_Image._from_uri_or_none(media?.get("image")); } rtn.url = url; return(rtn); }
public static FB_Attachment graphql_to_extensible_attachment(JToken data) { var story = data.get("story_attachment"); if (story == null) { return(null); } var target = story.get("target"); if (target == null) { return(new FB_UnsentMessage(uid: data.get("legacy_attachment_id")?.Value <string>())); } var _type = target.get("__typename")?.Value <string>(); if (_type == "MessageLocation") { return(FB_LocationAttachment._from_graphql(story)); } else if (_type == "MessageLiveLocation") { return(FB_LiveLocationAttachment._from_graphql(story)); } else if (new string[] { "ExternalUrl", "Story" }.Contains(_type)) { return(FB_ShareAttachment._from_graphql(story)); } return(null); }
private async Task <dynamic> _sendLocation( FB_LocationAttachment location, bool current = true, FB_Message message = null ) { var data = this._to_send_data(); if (message != null) { data.update(message._to_send_data()); } data["action_type"] = "ma-type:user-generated-message"; data["location_attachment[coordinates][latitude]"] = location.latitude; data["location_attachment[coordinates][longitude]"] = location.longitude; data["location_attachment[is_current_location]"] = current; return(await this.session._do_send_request(data)); }
/// <summary> /// Sends a given location to a thread as a pinned location /// </summary> /// <param name="location">Location to send</param> /// <param name="message">Additional message</param> /// <returns>:ref:`Message ID` of the sent message</returns> public async Task <string> sendPinnedLocation(FB_LocationAttachment location, FB_Message message = null) { /* * Sends a given location to a thread as a pinned location * :param location: Location to send * :param message: Additional message * :type location: LocationAttachment * :type message: Message * :return: :ref:`Message ID<intro_message_ids>` of the sent message * :raises: FBchatException if request failed * */ return(await this._sendLocation( location : location, current : false, message : message )); }