[Nodejs] FB Page post comment/reply event engine

岩岩寫左隻FB Page post comment/reply event engine既Nodejs module。

個module目的係幫FB page owner去mon住個FB page係咪有新comment,然後generate event & 俾個位d人自己去寫callback logic。

實際做法就係佢背底會行個schedule job去call FB graph API黎check post既new comments。

NodeJS module for keep track Facebook Page Posts New Comments

NodeJS module “fb-page-comment-event”

This module can keep track your Facebook page posts’ first level comment events. Hence, if someone commented on your post, you will be notified by an event.

This module support running an event-engine which would manage a background schedule job to check new comment and generating events. This module also support raw APIs which you can check new comments and digest as events by yourself via APIs.

 

Related Pages

Github page: https://github.com/airicyu/fb-page-comment-event
NPM: https://www.npmjs.com/package/fb-page-comment-event

 

Description

This module can keep track your Facebook page posts’ first level comment events. Hence, if someone commented on your post, you will be notified by an event.

This module support running an event-engine which would manage a background schedule job to check new comment and generating events. This module also support raw APIs which you can check new comments and digest as events by yourself via APIs.


Running the event engine

You may use the lib.pageCommentEventApp(options) API to get a event engine app and then start it with run function. This event engine app would manage a schedule job to auto pull data.

Sample:

  • Remarks: pageId is the facebook page ID. postId is the facebook page post ID of post which you want to monitor its comment. accessToken is the Facebook page access token(remember to use the long live token) which Facebook page owner can generate in developer dashboard.

Sample console log output:


(DIY) Use the APIs to check new comments and generating events

Sample:


event engine APIs

let app = lib.pageCommentEventApp({accessToken, pullInterval})

Description:

Initializing the event engine app.

parameters:

  • accessToken: The required accessToken(need permission manage_pages) for the API calls.
  • pullInterval: The sleep time(ms) interval between each scheduled page post new comment checking.

return:

The event engine app.

app.registerMonitorPost({pageId, postId})

Description:

Registering a page post which the event engine would tracking for new comments

parameters:

  • pageId: The page ID.
  • postId: The post ID.

app.run(eventsCallback)

Description:

Start running the event engine and register the new-comment-events callback. Once users write new comments, new-comment-events would be fired and handled by the callback.

parameters:

  • eventsCallback: The batch new-comment-events handling function.

app.stop()

Description:

Stop the event engine


DIY APIs

let queryPostCommentAgent = lib.api.getQueryPostCommentAgent(options)

Description:

Initialize a agent for query post comments.

parameters:

  • options: object with attribute accessToken which holding the required accessToken(need permission manage_pages) for the API calls.

return:

The agent object.

let postCommentFetcher = lib.api.getPostCommentFetcher(queryPostCommentAgent)

Description:

Initialize a fetcher for fetching new post comment.

parameters:

  • queryPostCommentAgent: The agent object which come from lib.api.getQueryPostCommentAgent(options)

return:

The fetcher object.

let postCommentObj = await postCommentFetcher.fetch(postObjId, since)

Description:

Use the fetcher object to fetch post object with comments. We can use this API to get all new comments under the target post which those comments are created since the since time.

parameters:

  • postObjId: The post object ID which is in format of ${pageId}_${postId} in Facebook Graph API.
  • since: The timestamp in second

return:

The post object with comments (All comments child objects are new comments).

let postDigestor = lib.api.getPostDigestor();

Description:

Getting a digestor object which can turn the post-comment object from postCommentFetcher.fetch() result into new-comment-events.

return:

The digestor object.

let newCommentEvents = await postDigestor.digest(postWithNewComments)

Description:

Use the digestor object to digest post-comment object into new-comment-events

parameters:

  • postWithNewComments: The post object with attaching new comments.

return:

New comment event objects

關於呂麗瑤事件的評論

關於呂麗瑤事件,
我認為,對(疑似)受害者最大的支持,不是訴諸同情地輕信,而是求法制上﹑社會上的公平對待﹑保護。

法制那些我不熟悉就且不多說。
就「社會上的公平對待」而言,我認為社會是該用正面肯定的角度去對待受害者肯站出來面對的這件事。
但肯定受害者站出來面對,這件事從來不應簡單地等同於輕信單方面片面之詞,這是完完全全的兩件事。

好些人可能會說,大眾若持有這種理性批評,不輕信受害人,這對疑似受害人構成壓力,是一般被非禮/強姦者不願站出來的原因。
我get到的言下之意(如果冇get錯)好像就是說,你若不信疑似受害人所說的內容,就是在壓迫疑似受害人。
姑勿論是真非禮還是老作,女方較易受同情及信任,這是社會客觀現實。
但觀感上的同情情緒並不等於真相。
呂麗瑤選擇公開處理這件事,雖然沒有點名那名教練,但已令對方被辭退。(好似係)
若事件不明不白只是半透明地處理,其實大眾只是被借助社會壓力向校方施壓。
借助大眾的社會壓力本身無可厚非,但若件事不明不白地就發生,則這種訴諸同情而非真相的culture/做法對社會長遠有害無益。

很多人看待件事,可能是很簡化地either選擇了男方或女方立場。
件事內情其實至今仍然是外人大眾不大清楚,所以只能用推測角度去看,難以下定論,不用跟車太貼。
觀乎一般大眾那種「歸邊」,以及把「支持受害者站出來」以及「確信其所指內容」兩者的綑綁,在一片爭議之中對疑似非禮/被非禮方都是不公平的。

在這種處理不當﹑對雙方也有欠公允的情況下,我覺得社會大眾是應該再反省一下hashtag “metoo”的意義及社會大眾對待這些事的態度。
單單是一個hashtag “metoo”,加上一個人的片面之詞,是否就代表著真相與充分的證據??我看法是有點保留的。
陶傑那篇文,是有點抽水諷刺意味,寫出來引起嘩然。但他就社會輕信處理metoo hashtag的這個point而言,是有一定道理的。

關於blockchain的少少個人理解與想法

講少少個人理解,blockchain大概是一種在處理asset擁有及轉移的應用技術。
對於這種應用,傳統社會的做法牽涉大量trust與資訊交換機制與成本。而因為trust issue, 所以形態上是很多parties各自的centralized trust機制,所以加大了交易成本。

blockchain的做法,是去中心化的trust(rathet than only data storage層面)機制。
藉着公有公開驗證的做法,所有資產轉移都是自帶驗證。
所以大大解決了trust與驗證的成本。(這是blockchain的最大價值)

但當然,技術還技術上的價值,應用上仍然可以是空殼廢紙,所以把資產本質由實體($)轉為虛擬貨幣的應用,用家進入市場有很大風險。

另外,在應用層面,blockchain一定是資產轉移流水帳的use case。若否,則blockchain技術不會帶來太大價值。

另外,blockchain需要公開帳目,我沒仔細研究過,但我懷疑仍有可能由transaction之間去trace back到account持有者身份。
例如,我是e store, 我賣了一件貨給某人,進行了某bitcoin交易,那應該有一條transaction是若干bit coin由某人銀包轉移到我銀包。那我是否能由“某人銀包”去識別出其他關於某人的bitcoin交易?若我掌握大量銀包識別資訊,那會否讓我能知道大眾的帳目資訊?
(我不熟這範疇,純粹ff 想想而已)