Guest User

Untitled

a guest
Nov 29th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. const alis = require("alis")
  2. module.exports["3Qjr7Y5DxwEN"] = async notification => {
  3. try {
  4. // 投げ銭ユーザーの最新の記事を取得
  5. let res = await alis.p.users.user_id.articles.public({
  6. limit: 1,
  7. user_id: notification.acted_user_id
  8. })
  9.  
  10. if (typeof res.Items === "undefined" || res.Items.length == 0) {
  11. // 記事がない場合はスキップ
  12. return false
  13. } else {
  14. // お礼のコメントを投稿
  15. let article_id = res.Items[0].article_id
  16. let text = `${
  17. notification.tip_value_normalized
  18. } ALISの投げ銭ありがとうございました!`
  19. let comment_result = await alis.p.me.articles.article_id.comments(
  20. { comment: { text: text }, article_id: "2xANm0jEzLPB" },
  21. {
  22. method: "POST",
  23. username: process.env.ALIS_USERNAME,
  24. password: process.env.ALIS_PASSWORD
  25. }
  26. )
  27.  
  28. // 処理成功フラグをリターン
  29. return true
  30. }
  31. } catch (e) {
  32. // なんらかのエラーが起きた場合はスキップ
  33. return false
  34. }
  35. }
Add Comment
Please, Sign In to add comment