Guest User

Untitled

a guest
Nov 29th, 2018
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. const alis = require("alis")
  2. module.exports["2APJkQqzNbeb"] = async notification => {
  3. try {
  4. // 投げ銭ユーザーの最新の記事を取得
  5. const 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. const article_id = res.Items[0].article_id
  16. const text = `${
  17. notification.tip_value_normalized
  18. } ALISの投げ銭ありがとうございました!`
  19. const comment_result = await alis.p.me.articles.article_id.comments(
  20. { comment: { text: text }, article_id: article_id },
  21. {
  22. method: "POST",
  23. username: process.env.ALIS_USERNAME,
  24. password: process.env.ALIS_PASSWORD
  25. }
  26. )
  27. if (typeof comment_result.comment_id === "string") {
  28. // 処理成功フラグをリターン
  29. return true
  30. } else {
  31. // なんらかのエラーが起きた場合はスキップ
  32. return false
  33. }
  34. }
  35. } catch (e) {
  36. // なんらかのエラーが起きた場合はスキップ
  37. return false
  38. }
  39. }
Add Comment
Please, Sign In to add comment