Skip to content

Commit 326d8bf

Browse files
4gerueucyt
andauthored
create rich menu operation (#121)
* create six-splited richmenu * add templates * create rich-menu folder * separate the generateRichMenuImage function * add example images * refactor some * add h3 tag on templete 04 * change return messave * add create richmenu * add create rich menu command * update the create rich menu * change the image size * create the rich menu * refactor the code * change the templetes * change TempleteNo and height * change templete actions area * refactor the codes * use const variable * rename the filename * add the areas and some * debug * update the templetes * self review * fix the ci * use puppeteer * reply successful message * change the file name * change the templete to template * add fonts on docker * update the tools argument * add max and min argument * update chatBarText message * remove rich menu examples * change the chatBatText description * change the font * add the READMEs * change the z option * include finally * remove end of space * remove templateNumber * remove console.log * npm run format --------- Co-authored-by: Yuta Euchi <[email protected]> Co-authored-by: Euchi Yuta <[email protected]>
1 parent b5b8104 commit 326d8bf

File tree

14 files changed

+2367
-398
lines changed

14 files changed

+2367
-398
lines changed

Dockerfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,33 @@ RUN --mount=type=cache,target=/root/.npm npm run build
1111
# --- Release Stage ---
1212
FROM node:24-alpine AS release
1313

14+
# Install necessary tools and base fonts
15+
RUN apk add --no-cache \
16+
fontconfig \
17+
font-noto-cjk \
18+
ttf-freefont \
19+
curl \
20+
unzip \
21+
chromium \
22+
nss
23+
24+
# Download and install Japanese fonts from GitHub
25+
RUN mkdir -p /usr/share/fonts/truetype/google && \
26+
# Noto Sans JP from GitHub
27+
curl -L "https://github.com/googlefonts/noto-cjk/raw/main/Sans/OTF/Japanese/NotoSansJP-Regular.otf" -o /usr/share/fonts/truetype/google/NotoSansJP-Regular.otf && \
28+
curl -L "https://github.com/googlefonts/noto-cjk/raw/main/Sans/OTF/Japanese/NotoSansJP-Bold.otf" -o /usr/share/fonts/truetype/google/NotoSansJP-Bold.otf && \
29+
# IPAex Gothic font as fallback
30+
curl -L "https://moji.or.jp/wp-content/ipafont/IPAexfont/IPAexfont00401.zip" -o ipaex.zip && \
31+
unzip ipaex.zip && \
32+
cp IPAexfont00401/*.ttf /usr/share/fonts/truetype/google/ && \
33+
rm -rf IPAexfont00401 ipaex.zip
34+
35+
# Update font cache
36+
RUN fc-cache -f -v
37+
38+
# Set Puppeteer to use system Chromium
39+
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
40+
1441
# Set up a non-root user ('appuser'/'appgroup') to avoid running as root - good security practice!
1542
# (-S is the Alpine option for a system user/group, suitable here)
1643
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
@@ -19,6 +46,7 @@ RUN addgroup -S appgroup && adduser -S appuser -G appgroup
1946
COPY --from=builder /app/dist /app/dist
2047
COPY --from=builder /app/package.json /app/package.json
2148
COPY --from=builder /app/package-lock.json /app/package-lock.json
49+
COPY --from=builder /app/richmenu-template /app/richmenu-template
2250

2351
ENV NODE_ENV=production
2452

README.ja.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,20 @@ LINE公式アカウントとAI Agentを接続するために、LINE Messaging AP
5757
- デフォルトのリッチメニューを解除する。
5858
- **入力:**
5959
- なし
60+
11. **create_rich_menu**
61+
- 指定されたアクションに基づいてリッチメニューを作成。画像を生成してアップロード。デフォルトとして設定する。
62+
- **入力:**
63+
- `chatBarText` (string): チャットバー表示、リッチメニュー名にされるテキスト。
64+
- `actions` (array): リッチメニューのアクション。最小1つから最大6つのアクションを指定できる。各アクションは以下のいずれかのタイプを指定できる:
65+
- `postback`: ポストバックアクションを送信する
66+
- `message`: テキストメッセージを送信する
67+
- `uri`: URLを開く
68+
- `datetimepicker`: 日付/時間選択ツールを開く
69+
- `camera`: カメラを開く
70+
- `cameraRoll`: カメラロールを開く
71+
- `location`: 現在位置を送信する
72+
- `richmenuswitch`: 別のリッチメニューに切り替える
73+
- `clipboard`: テキストをクリップボードにコピーする
6074

6175
## インストール (npxを使用)
6276

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,20 @@
5959
- Cancel the default rich menu.
6060
- **Inputs:**
6161
- None
62+
11. **create_rich_menu**
63+
- Create a rich menu based on the given actions. Generate and upload an image. Set as default.
64+
- **Inputs:**
65+
- `chatBarText` (string): Text displayed in chat bar, also used as rich menu name.
66+
- `actions` (array): The actions of the rich menu. You can specify minimum 1 to maximum 6 actions. Each action can be one of the following types:
67+
- `postback`: For sending a postback action
68+
- `message`: For sending a text message
69+
- `uri`: For opening a URL
70+
- `datetimepicker`: For opening a date/time picker
71+
- `camera`: For opening the camera
72+
- `cameraRoll`: For opening the camera roll
73+
- `location`: For sending the current location
74+
- `richmenuswitch`: For switching to another rich menu
75+
- `clipboard`: For copying text to clipboard
6276

6377
## Installation (Using npx)
6478

0 commit comments

Comments
 (0)