pyconversations.message.FBPost

class pyconversations.message.FBPost(**kwargs)[source]

FB-specific FB Post object with Facebook specific features

static parse_datestr(x)[source]

Static method that specifies how to convert the native datetime string into a a Python datetime object.

Parameters

x (str) – The raw datetime string

Returns

datetime.datetime – The parsed datetime

static parse_raw(data, post_type='post', in_reply_to=None, lang_detect=False)[source]

Static method that must be implemented by all non-abstract child classes. Concrete implementations should specify how to parse the raw data into this object.

Parameters
  • data (JSON/dict) – The raw data to be pre-processed.

  • post_type (str) – Facebook specific feature; what type of FB object to parse: [‘post’, ‘comments’, ‘replies’]

  • in_reply_to (set(UID)) – Unique IDs of posts this object is replying to

  • lang_detect (bool) – A boolean which specifies whether language detection should be activated. (Default: False)

Returns

FBPost or list(FBPost) – The parsed posts

Raises

ValueError – When given an invalid post_type

static parse_raw_comments(data, in_reply_to=None, lang_detect=False)[source]

Parses the raw JSON of a FB comments object. Returns a list of parsed comments.

Parameters
  • data (JSON/dict) – The raw data to be pre-processed.

  • in_reply_to (set(UID)) – Unique IDs of posts this object is replying to

  • lang_detect (bool) – A boolean which specifies whether language detection should be activated. (Default: False)

Returns

list(FBPost) – The parsed comments

static parse_raw_post(data, lang_detect=False, in_reply_to=None)[source]

Parses the raw JSON of a FB post object

Parameters
  • data (JSON/dict) – The raw data to be pre-processed.

  • in_reply_to (set(UID)) – Unique IDs of posts this object is replying to

  • lang_detect (bool) – A boolean which specifies whether language detection should be activated. (Default: False)

Returns

FBPost – The parsed post

static parse_raw_replies(data, in_reply_to=None, lang_detect=False)[source]

Parses the raw JSON of a FB replies object. Returns a list of parsed comments.

Parameters
  • data (JSON/dict) – The raw data to be pre-processed.

  • in_reply_to (set(UID)) – Unique IDs of posts this object is replying to

  • lang_detect (bool) – A boolean which specifies whether language detection should be activated. (Default: False)

Returns

list(FBPost) – The parsed replies