Skip to content

Commit

Permalink
Merge pull request #448 from hanshino/chore
Browse files Browse the repository at this point in the history
精簡專案&升級套件
  • Loading branch information
hanshino authored Nov 11, 2023
2 parents c37401a + 1500241 commit 8c420cd
Show file tree
Hide file tree
Showing 46 changed files with 137 additions and 3,546 deletions.
11 changes: 2 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
| redis | [redis](https://hub.docker.com/_/redis) | 6379 | 記憶體快取資料庫 |
| crontab | [crontab](https://github.com/hanshino/redive_linebot/blob/master/job/Dockerfile) | | `node:lts-bullseye-slim` 定時排程執行 |
| phpmyadmin | [phpmyadmin](https://hub.docker.com/r/phpmyadmin/phpmyadmin/) | 80 | `phpmyadmin` 資料庫管理 |
| opencv | [opencv](https://github.com/hanshino/redive_linebot/blob/master/opencv/Dockerfile) | 3000 | `opencv` 影像處理 |

可使用`docker-compose`指令水平擴展主程式,端看於個人硬體強度來做提升。

Expand All @@ -69,7 +68,6 @@
| redis | [redis](https://hub.docker.com/_/redis) | 6379 | 記憶體快取資料庫 |
| crontab | [crontab](https://github.com/hanshino/redive_linebot/blob/master/job/Dockerfile) | | `node.js:12-alpine` 定時排程執行 |
| phpmyadmin | [phpmyadmin](https://hub.docker.com/r/phpmyadmin/phpmyadmin/) | 8080 | `phpmyadmin` 資料庫管理 |
| opencv | [opencv](https://github.com/hanshino/redive_linebot/blob/master/opencv/Dockerfile) | 3000 | `opencv` 影像處理 |

## 目前適用聊天軟體

Expand Down Expand Up @@ -135,14 +133,9 @@

`make build-project`

### 正式用
### 啟動專案

1. `docker-compose -f docker-compose-prod.yml up -d`
2. 此時電腦的 **80 port** 將會開啟服務,如無固定 ip 可用,可使用[ngrok](https://ngrok.com/)進行服務公開。

### 開發用

1. `docker-compose -f docker-compose-dev.yml up -d`
1. `docker-compose up -d`
2. 此時電腦的 **5000 port** 將會開啟服務,如無固定 ip 可用,可使用[ngrok](https://ngrok.com/)進行服務公開。

### 額外教學 (ngrok)
Expand Down
11 changes: 0 additions & 11 deletions app/locales/zh_tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -195,17 +195,6 @@
"upload_without_quote": "請直接針對要上傳得圖片回覆 `#圖片上傳`",
"upload_success": "上傳圖片成功\n圖片編號 {{ id }}\n圖片網址 {{{ url }}}"
},
"creatures": {
"not_found": "找不到培養中的角色,請先透過 `#養成` 創建一個角色",
"not_found_to_create": "您還沒有任何培養中的角色,即將幫您創立一位新的角色",
"already_exists": "您已經有一位培養中的角色,請先完成該角色的培養",
"admin_error": "此為異常錯誤,請向管理員報告此問題\n使用者編號 {{ userId }}",
"ask_for_nickname": "哦呀,你選擇了 `{{ name }}` 作為夥伴嗎\n那麼請幫他取個名字吧\n(請直接輸入名字,不要加空格)",
"ask_for_nickname_confirm": "您選擇的夥伴是 *{{ name }}* \n使用的暱稱是 *{{{ nickname }}}*\n是否確認這個暱稱?\n(請輸入 `是` 或 `否`)",
"nickname_has_space": "您的夥伴名稱不能有空格,請重新輸入",
"create_user_cancel": "已經取消了角色創立,如需重新創立請輸入 `#養成`",
"create_success": "已經成功創立角色\n角色 {{ name }}\n角色暱稱 {{ nickname }}\n更多詳細資訊請輸入 `#養成`"
},
"lottery": {
"no_holding_event": "目前沒有樂透活動",
"manual_buy": {
Expand Down
21 changes: 10 additions & 11 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,41 @@
"knex": "knex"
},
"dependencies": {
"@sentry/node": "^7.73.0",
"@sentry/node": "^7.80.0",
"ajv": "^8.12.0",
"ajv-formats": "^2.1.1",
"axios": "0.27.2",
"axios": "1.6.1",
"bottender": "1.5.5",
"brotli": "^1.3.3",
"cheerio": "^1.0.0-rc.12",
"config": "^3.3.9",
"cron": "^2.4.4",
"cron": "^3.1.6",
"date-format": "^4.0.14",
"express": "^4.18.2",
"express-rate-limit": "^7.1.0",
"human-number": "^2.0.3",
"express-rate-limit": "^7.1.4",
"human-number": "^2.0.4",
"i18n": "^0.15.1",
"imgur": "^2.3.0",
"knex": "^2.5.1",
"knex": "^3.0.1",
"lodash": "^4.17.21",
"log4js": "^6.9.1",
"math-random": "^2.0.1",
"md5": "^2.3.0",
"minimist": "^1.2.8",
"moment": "^2.29.4",
"mysql2": "^3.6.1",
"openai": "^3.3.0",
"mysql2": "^3.6.3",
"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.18",
"@types/express": "^4.17.21",
"cors": "^2.8.5",
"eslint": "^8.51.0",
"eslint": "^8.53.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-prettier": "^5.0.1",
"jest": "^29.7.0",
"nodemon": "^3.0.1",
"prettier": "^3.0.3"
Expand Down
42 changes: 1 addition & 41 deletions app/src/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const { router, text, route } = require("bottender/router");
// eslint-disable-next-line no-unused-vars
const { chain, withProps, Context } = require("bottender");
const { chain, withProps } = require("bottender");
const gacha = require("./controller/princess/gacha");
const battle = require("./controller/princess/battle");
const customerOrder = require("./controller/application/CustomerOrder");
Expand All @@ -17,8 +16,6 @@ const groupTemplate = require("./templates/application/Group/line");
const { GlobalOrderBase } = require("./controller/application/GlobalOrders");
const { showOrderManager } = require("./templates/application/CustomerOrder/line");
const ChatLevelController = require("./controller/application/ChatLevelController");
const BattleReportController = require("./controller/princess/BattleReportController");
const ArenaContoroller = require("./controller/princess/ArenaController");
const WorldBossController = require("./controller/application/WorldBossController");
const GuildServiceController = require("./controller/application/GuildServiceController");
const AdvertisementController = require("./controller/application/AdvertisementController");
Expand All @@ -32,7 +29,6 @@ const VoteController = require("./controller/application/VoteController");
const MarketController = require("./controller/application/MarketController");
const CouponController = require("./controller/application/CouponController");
const ImageController = require("./controller/application/ImageController");
const CreatureController = require("./controller/application/CreaturesController");
const StatusController = require("./controller/application/StatusController");
const LotteryController = require("./controller/application/LotteryController");
const BullshitController = require("./controller/application/BullshitController");
Expand All @@ -47,7 +43,6 @@ const AdminModel = require("./model/application/Admin");
const axios = require("axios");
const pConfig = require("config");
const FetchGameData = require("../bin/FetchGameData");
const { format } = require("util");

axios.defaults.timeout = 5000;

Expand Down Expand Up @@ -93,15 +88,10 @@ async function HandlePostback(context, { next }) {
route(() => action === "janken", withProps(JankenController.decide, { payload })),
route(() => action === "challenge", withProps(JankenController.challenge, { payload })),
route(() => action === "vote", withProps(VoteController.decide, { payload })),
route(
() => action === "initCreatureCreate",
withProps(CreatureController.initCreate, { payload })
),
route(
() => action === "confirmTransfer",
withProps(MarketController.doTransfer, { payload })
),
route(() => action === "useFood", withProps(CreatureController.useFood, { payload })),
route(() => action === "lottery_auto_buy", withProps(LotteryController.autoBuy, { payload })),
route(
() => action === "exchangeScratchCard",
Expand All @@ -128,7 +118,6 @@ async function OrderBased(context, { next }) {
...(isAdmin ? AdminOrder(context) : []),
...CustomerOrder(context),
...GroupOrder(context),
...ArenaContoroller.router(context),
...WorldBossController.router,
...GuildServiceController.router,
...AdvertisementController.router,
Expand Down Expand Up @@ -164,20 +153,6 @@ async function OrderBased(context, { next }) {
text("/people", function () {
traffic.getPeopleData().then(console.table);
}),
text("/chatsession", async context => {
const sourceType = context.event.source.type;
const sourceId = context.event.source[sourceType + "Id"];
const key = format(pConfig.get("redis.keys.groupSession"), sourceId);
const records = await redis.lRange(key, 0, -1);
context.replyText(["近 20 筆聊天記錄", ...records].join("\n"));
}),
text("/resetchatsession", async context => {
const sourceType = context.event.source.type;
const sourceId = context.event.source[sourceType + "Id"];
const key = format(pConfig.get("redis.keys.groupSession"), sourceId);
await redis.del(key);
context.replyText("已清除聊天記錄");
}),
text(/^[.#]自訂頭像( (?<param1>\S+))?( (?<param2>\S+))?/, guildConfig.setSender),
text(/^(#我的狀態|\/me)$/, context =>
withProps(ChatLevelController.showStatus, { userId: context.event.source.userId })
Expand Down Expand Up @@ -247,25 +222,10 @@ async function OrderBased(context, { next }) {
context.replyFlex("實用連結", carousel);
}),
text(".test", () => pushMessage({ message: "test", token: process.env.LINE_NOTIFY_TOKEN })),
...PersonOrder(context),
route("*", next),
]);
}

function PersonOrder(context) {
if (context.event.source.type !== "user") return [];
return [
text(/^[#.](重選報名表|formreset)$/, BattleReportController.resetGuild),
text(/^[#.](我要回報|formreport)(\s(?<formId>\S+))?/, BattleReportController.reportDamage),
text(
/^[#.](傷害回報|回報傷害)\s(?<recordId>\d+)\s(?<week>\d+)\s(?<boss>[1-5])$/,
BattleReportController.setAllowReport
),
route(BattleReportController.isAllowPersonalReport, BattleReportController.personalReport),
...CreatureController.router,
];
}

function AdminOrder() {
return [
text(/^[.#/](後台管理|system(call)?)/i, showManagePlace),
Expand Down
Loading

0 comments on commit 8c420cd

Please sign in to comment.