Skip to content

Commit

Permalink
feat: 支援回覆訊息功能
Browse files Browse the repository at this point in the history
  • Loading branch information
hanshino committed Sep 25, 2023
1 parent cbb8362 commit 80a62b5
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions app/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,52 @@ function Nothing(context) {

async function App(context) {
traffic.recordPeople(context);

context.replyText = function (...args) {
const { quoteToken } = context.event.message;
const [text] = args;
let replyObject = {};

const textType = typeof text;

if (textType === "string") {
replyObject = [
{
type: "text",
text,
quoteToken,
},
];
} else if (Array.isArray(text)) {
replyObject = text.map((t, index) => {
let reply;
if (typeof t === "string") {
reply = {
type: "text",
text: t,
};
} else if (typeof t === "object") {
reply = {
...t,
};
}

if (index === 0) {
reply.quoteToken = quoteToken;
}

return reply;
});
} else if (textType === "object") {
replyObject = {
...text,
quoteToken,
};
}

return context.reply(replyObject);
};

return chain([
setProfile, // 設置各式用戶資料
statistics, // 數據蒐集
Expand Down

0 comments on commit 80a62b5

Please sign in to comment.