Skip to content

Commit

Permalink
Merge pull request #438 from hanshino/feat/quote-reply
Browse files Browse the repository at this point in the history
新增標註訊息回覆的功能
  • Loading branch information
hanshino authored Sep 25, 2023
2 parents 30ed27a + 80a62b5 commit 26d680b
Show file tree
Hide file tree
Showing 3 changed files with 535 additions and 466 deletions.
20 changes: 10 additions & 10 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
"knex": "knex"
},
"dependencies": {
"@sentry/node": "^7.63.0",
"@sentry/node": "^7.70.0",
"ajv": "^8.12.0",
"ajv-formats": "^2.1.1",
"axios": "0.27.2",
"bottender": "1.5.5",
"brotli": "^1.3.3",
"cheerio": "^1.0.0-rc.12",
"config": "^3.3.9",
"cron": "^2.4.1",
"cron": "^2.4.3",
"date-format": "^4.0.14",
"express": "^4.18.2",
"express-rate-limit": "^6.9.0",
"human-number": "^2.0.1",
"express-rate-limit": "^6.11.2",
"human-number": "^2.0.3",
"i18n": "^0.15.1",
"imgur": "^2.3.0",
"knex": "^2.5.1",
Expand All @@ -35,22 +35,22 @@
"md5": "^2.3.0",
"minimist": "^1.2.8",
"moment": "^2.29.4",
"mysql2": "^3.6.0",
"mysql2": "^3.6.1",
"openai": "^3.3.0",
"redis": "^4.6.8",
"redis": "^4.6.10",
"socket.io": "^4.7.2",
"sqlite3": "^5.1.6",
"table": "^6.8.1",
"uuid-random": "^1.3.2"
},
"devDependencies": {
"@types/express": "^4.17.17",
"@types/express": "^4.17.18",
"cors": "^2.8.5",
"eslint": "^8.46.0",
"eslint": "^8.50.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"jest": "^29.6.2",
"jest": "^29.7.0",
"nodemon": "^3.0.1",
"prettier": "^3.0.1"
"prettier": "^3.0.3"
}
}
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
Loading

0 comments on commit 26d680b

Please sign in to comment.