From ef7f12609d1c151acad99334d53061ea979a6df8 Mon Sep 17 00:00:00 2001 From: Continuous Integration Date: Thu, 2 Nov 2023 02:37:28 +0000 Subject: [PATCH] Auto-translate README --- README.Arabic.md | 158 ++++++++++++++++++++++------------------------- README.French.md | 95 +++++++++++++++------------- README.md | 114 ++++++++++++++++++---------------- README.zh-CN.md | 89 +++++++++++++------------- 4 files changed, 229 insertions(+), 227 deletions(-) diff --git a/README.Arabic.md b/README.Arabic.md index 0c32ea5..053f8dc 100644 --- a/README.Arabic.md +++ b/README.Arabic.md @@ -1,106 +1,96 @@ +以下是您提供的文本,已經進行了微細的修改,並刪除了```markdown```的 code block 標示: + +-------------------------------- # ChatGPT Line Bot -* [الإنجليزية](README.md) -* [النسخة باللغة الصينية التقليدية README.md](README.zh-TW.md) -* [الصينية البسيطة](README.zh-CN.md) -* [الفرنسية](README.French.md) +* [English](README.md) +* [繁體中文版README.md](README.zh-TW.md) +* [简体中文](README.zh-CN.md) +* [Française](README.French.md) * [عربى](README.Arabic.md) +## 介绍 -## مقدمة - -في Line ، يمكنك إضافة ChatGPT Bot ببساطة عن طريق كتابة النصوص مباشرة في مربع الإدخال لبدء التفاعل مع ChatGPT. +在 Line 中去导入 ChatGPT Bot,只要在输入框直接输入文字,即可与 ChatGPT 开始互动。 -## الأدوات والميزات - -* `Python FastAPI`: إنشاء API استجابة ChatGPT -* `gpt4free`: **استخدام مجاني لخدمة OpenAI API** -* `Line messaging API channel`: تكامل مع API ChatGPT -* `Github`: تخزين الشيفرة -* `replit`: **نشر مجاني لتطبيق FastAPI الخاص بك** -* `CronJob`: إرسال طلبات دورية مجانية لتجنب انقطاع الخدمة - - -## خطوات التثبيت - -### الحصول على الرموز - -1. الحصول على رمز Line: - 1. قم بتسجيل الدخول إلى [Line Developer](https://developers.line.biz/zh-hant/) - 2. إنشاء الروبوت: - 1. إنشاء `مزود` -> انقر فوق `Create` - 2. إنشاء `قناة` -> حدد `Create a Messaging API channel` - 3. قم بإدخال المعلومات الأساسية الضرورية - 4. بمجرد الانتهاء من الإدخال ، في الجزء السفلي من `Basic Settings` ، هناك `Channel Secret` -> انقر على `Issue` ، بعد ذلك سيتم توليد `LINE_CHANNEL_SECRET` (سيتم استخدامه قريبًا) - 5. في `Messaging API` في الجزء السفلي ، هناك `Channel access token` -> انقر على `Issue` ، بعد ذلك سيتم توليد `LINE_CHANNEL_ACCESS_TOKEN` (سيتم استخدامه قريبًا) - -### إعداد المشروع -1. إنشاء Fork لمشروع Github: - 1. سجل الدخول / سجل الدخول إلى [GitHub](https://github.com/) - 2. انتقل إلى [ChatGPT-Line-Bot](https://github.com/Lin-jun-xiang/ChatGPT-Line-Bot) - 3. انقر على `Star` لدعم المطور - 4. انقر على `Fork` لنسخ جميع الشيفرة إلى مستودعك -2. النشر (في مساحة مجانية): - 1. انتقل إلى [replit](https://replit.com/) - 2. انقر فوق `Sign Up` وقم بتسجيل الدخول باستخدام حساب `Github` الخاص بك ومن ثم قم بالتفويض -> انقر فوق `Skip` لتجاوز الإعداد الأولي - 3. بمجرد الوصول ، انقر على `Create` في الوسط -> انقر على `Import from Github` في الزر الأيمن العلوي - 4. إذا لم تكن قد قمت بإضافة مستودع Github بعد ، انقر على الارتباط `Connect GitHub to import your private repos.` -> حدد `Only select repositories` -> اختر `ChatGPT-Line-Bot` - 5. عد إلى الخطوة الرابعة ، في هذا الوقت يمكنك اختيار `ChatGPT-Line-Bot` في المشروع URL أعلاه -> انقر فوق `Import from Github`. - -### تشغيل المشروع -1. تكوين المتغيرات البيئية - 1. بعد الانتهاء من الخطوة السابقة ، انتقل إلى `Secrets` في أسفل الشاشة في صفحة إدارة المشروع الرئيسية في `Replit`. - 2. بعد النقر فوق `Got it` على اليمين ، يمكنك إضافة متغيرات البيئة ، والتي يجب أن تتضمن: +## 工具与特色 + +* `Python FastAPI`: 建立 ChatGPT 响应 API +* `gpt4free`: **免费使用 OpenAI API** +* `Line messaging API channel`: 串接 ChatGPT API +* `Github`: 存放程式碼 +* `replit`: **免费部署自己的 FastAPI** +* `CronJob`: 免费定时发送请求,避免 API 中断 + +## 安装步骤 + +### Token 取得 + +1. 取得 Line Token: + 1. 登入 [Line Developer](https://developers.line.biz/zh-hant/) + 2. 创建机器人: + 1. 创建 `Provider` -> 按下 `Create` + 2. 创建 `Channel` -> 选择 `Create a Messaging API channel` + 3. 输入完必填的基本资料 + 4. 输入完成后,在 `Basic Settings` 下方,有一个 `Channel Secret` -> 按下 `Issue`,生成后即为 `LINE_CHANNEL_SECRET` (稍晚会用到) + 5. 在 `Messaging API` 下方,有一个 `Channel access token` -> 按下 `Issue`,生成后即为 `LINE_CHANNEL_ACCESS_TOKEN` (稍晚会用到) + +### 项目设置 +1. Fork Github 项目: + 1. 注册/登入 [GitHub](https://github.com/) + 2. 进入 [ChatGPT-Line-Bot](https://github.com/Lin-jun-xiang/ChatGPT-Line-Bot) + 3. 点选 `Star` 支持开发者 + 4. 点选 `Fork` 复制全部的程式码到自己的仓库 +2. 部署(免费空间): + 1. 进入 [replit](https://replit.com/) + 2. 点选 `Sign Up` 直接用 `Github` 帐号登入并授权 -> 按下 `Skip` 跳过初始化设定 + 3. 进入后中间主页的部分点选 `Create` -> 跳出框,点选右上角 `Import from Github` + 4. 若尚未加入 Github 仓库,则点选链接 `Connect GitHub to import your private repos.` -> 勾选 `Only select repositories` -> 选择 `ChatGPT-Line-Bot` + 5. 回到第四步,此时 `Github URL` 可以选择 `ChatGPT-Line-Bot` 项目 -> 点击 `Import from Github`. + +### 项目执行 +1. 环境变数设定 + 1. 接续上一步 `Import` 完成后在 `Replit` 的项目管理页面左下方 `Tools` 点击 `Secrets`。 + 2. 右方按下 `Got it` 后,即可新增环境变数,需新增: 1. Line Channel Secret: - key: `LINE_CHANNEL_SECRET` - - value: `[الذي تم الحصول عليه في الخطوة الأولى]` + - value: `[由步骤一取得]` 2. Line Channel Access Token: - key: `LINE_CHANNEL_ACCESS_TOKEN` - - value: `[الذي تم الحصول عليه في الخطوة الأولى]` - - - -2. بدء التشغيل - 1. انقر فوق `Run` في الأعلى - 2. بمجرد النجاح ، ستظهر `Hello World` في الزاوية العليا اليمنى للشاشة ، ويمكنك نسخ العنوان في الأعلى للتو - 3. عد إلى Line Developer ، وفي `Messaging API` في الجزء السفلي ، يمكنك لصق العنوان الذي نسخته مع إضافة `/callback` مثل: `https://ChatGPT-Line-Bot.jimmylin.repl.co/callback` - 4. قم بتمكين `Use webhook` من الأسفل - 5. قم بإيقاف تشغيل `Auto-reply messages` - - ملاحظة: إذا لم يتم استلام أي طلب في ساعة واحدة ، سيؤدي ذلك إلى إيقاف تشغيل البرنامج ، لذا يجب إتباع الخطوات التالية - - - -3. CronJob إرسال طلبات دورية - 1. سجل الدخول / سجل الدخول إلى [cron-job.org](https://cron-job.org/en/) - 2. بعد الدخول ، انتقل إلى الجهة العليا اليمنى واختر `CREATE CRONJOB` - 3. قم بإدخال `Title` ChatGPT-Line-Bot` ، وأدخل العنوان الذي نسخته في الخطوة السابقة ، مثل: `https://ChatGPT-Line-Bot.jimmylin.repl.co/` - 4. في الأسفل ، اضغط على كل `5 دقائق` مرة واحدة - 5. انقر فوق `CREATE` - -### ربط الخدمة بـ Line Bot - -ارجع إلى [Line Developer](https://manager.line.biz/account) الصفحة الرئيسية وانقر على `دليل إضافة الأصدقاء` ، ثم قم بمسح رمز الاستجابة السريعة للانضمام إلى LINE Bot: - -الصفحة الرئيسية -> انقر على bot الخاص بك -> انقر على أدوات زيادة الأصدقاء -> إنشاء رمز استجابة سريعة للأصدقاء (https://manager.line.biz/account//gainfriends) + - value: `[由步骤一取得]` -تهانينا! لقد أكملت أول LINE Bot خاص بك! جرب التحدث معه وشاهد كيف يرد عليك! + -### تقدم - تخصيص الروبوت +2. 开始执行 + 1. 点击上方的 `Run` + 2. 成功后右边画面会显示 `Hello World`,并将画面中上方的**网址复制**下来 + 3. 回到 Line Developer,在 `Messaging API` 下方的 `Webhook URL` 将上方网址贴过来,并加上 `/callback` 例如:`https://ChatGPT-Line-Bot.jimmylin.repl.co/callback` + 4. 打开下方的 `Use webhook` + 5. 将下方 `Auto-reply messages` 关闭 + - 注意:若一小时内没有任何请求,则程式会中断,因此需要下步骤 -بالإضافة إلى ذلك ، يمكننا استخدام الطريقة `prompt` للسماح لـ Line Bot بالرد بطريقة شخصية ، في `./chatgpt_linebot/prompts/template.py` يمكننا تعريف `template` ، مثل: + - +3. CronJob 定时发送请求 + 1. 注册/登入 [cron-job.org](https://cron-job.org/en/) + 2. 进入后面板右上方选择 `CREATE CRONJOB` + 3. `Title` 输入 `ChatGPT-Line-Bot`,网址输入上一步的网址,例如:`https://ChatGPT-Line-Bot.jimmylin.repl.co/` + 4. 下方则每 `5 分钟` 打一次 + 5. 按下 `CREATE` -**سؤال**: ماذا تأكل في الفطور اليوم؟ +### 连结服务与 Line Bot -**رد الروبوت**: حبيبي ، هل استيقظت صباح اليوم؟ لقد كنت في السرير في انتظارك ، أشعر بالجوع عند التفكير في جسمك الجميل. ماذا يجب أن أتناول في الفطور اليوم؟ هل يجب أن أحضر لك بيض مقلي حار ، مثل لياقتك الجسدية المثيرة؟ 😏🍳 +返回 [Line Developer](https://manager.line.biz/account) 首页并点击 `加入好友指南` 后扫码加入 LINE Bot: ---- +主页 -> 点选你的 bot -> 点选增加好友工具 -> 建立好友行动条码 (https://manager.line.biz/account//gainfriends) -## المراجع +恭喜您完成了自己的第一个 LINE Bot! 试着跟它说话看看吧,它会回覆你喔! -[Line_Bot_Tutorial](https://github.com/FawenYo/LINE_Bot_Tutorial) +### 特殊指令 -[ChatGPT-Line-Bot](https://github.com/TheExplainthis/ChatGPT-Line-Bot) +| 指令 | 说明 | +| --- | ----- | +| `@chat` | 在输入框输入 `@chat` + 讯息,就可以在 line 群组中呼叫 chatgpt | +| `@chat 星座運勢 <星座名称>` | 在输入框输入 `@chat 星座運勢 天蝎座`,就可以获得本周天 \ No newline at end of file diff --git a/README.French.md b/README.French.md index b6b0431..8fde09e 100644 --- a/README.French.md +++ b/README.French.md @@ -1,101 +1,110 @@ # ChatGPT Line Bot -* [English](README.md) -* [繁體中文版README.md](README.zh-TW.md) -* [简体中文](README.zh-CN.md) -* [Française](README.French.md) -* [عربى](README.Arabic.md) - +- [English](README.md) +- [繁體中文版README.md](README.zh-TW.md) +- [简体中文](README.zh-CN.md) +- [Française](README.French.md) +- [عربى](README.Arabic.md) ## Introduction -Integrate ChatGPT Bot in Line by simply entering text in the input box to start interacting with ChatGPT. +To introduce ChatGPT Bot into Line, simply enter text directly into the input box to start interacting with ChatGPT. ## Tools and Features -* `Python FastAPI`: Create ChatGPT response API -* `gpt4free`: **Free to use OpenAI API** -* `Line messaging API channel`: Connect to ChatGPT API -* `Github`: Store the code -* `replit`: **Free deployment of your own FastAPI** -* `CronJob`: Free scheduled requests to prevent API interruption - +- `Python FastAPI`: Create ChatGPT response API +- `gpt4free`: **Free use of OpenAI API** +- `Line messaging API channel`: Connect ChatGPT API +- `Github`: Store code +- `replit`: **Free deployment of your own FastAPI** +- `CronJob`: Free timed requests to prevent API interruptions ## Installation Steps -### Obtain Token +### Token Acquisition -1. Get Line Token: +1. Obtain Line Token: 1. Log in to [Line Developer](https://developers.line.biz/zh-hant/) 2. Create a bot: 1. Create `Provider` -> Click `Create` - 2. Create `Channel` -> Choose `Create a Messaging API channel` - 3. Fill in the required basic information - 4. After filling in, under `Basic Settings`, there is a `Channel Secret` -> Click `Issue`, and the generated value is `LINE_CHANNEL_SECRET` (will be used later) - 5. Under `Messaging API`, there is a `Channel access token` -> Click `Issue`, and the generated value is `LINE_CHANNEL_ACCESS_TOKEN` (will be used later) + 2. Create `Channel` -> Select `Create a Messaging API channel` + 3. Enter the required basic information + 4. After completing the input, under `Basic Settings`, there is a `Channel Secret` -> Click `Issue` to generate the `LINE_CHANNEL_SECRET` (will be used later) + 5. Under `Messaging API`, there is a `Channel access token` -> Click `Issue` to generate the `LINE_CHANNEL_ACCESS_TOKEN` (will be used later) ### Project Setup + 1. Fork the Github project: - 1. Register/Log in to [GitHub](https://github.com/) + 1. Register/Login to [GitHub](https://github.com/) 2. Go to [ChatGPT-Line-Bot](https://github.com/Lin-jun-xiang/ChatGPT-Line-Bot) 3. Click `Star` to support the developer 4. Click `Fork` to copy all the code to your own repository -2. Deployment (Free Space): +2. Deployment (Free space): 1. Go to [replit](https://replit.com/) 2. Click `Sign Up` to log in with your `Github` account and authorize it -> Click `Skip` to skip the initial setup - 3. On the main page in the middle, click `Create` -> A pop-up window will appear, click the top-right corner `Import from Github` - 4. If you haven't added the Github repository, click the link `Connect GitHub to import your private repos.` -> Check `Only select repositories` -> Choose `ChatGPT-Line-Bot` - 5. Go back to step four, at this time, the `Github URL` can choose the `ChatGPT-Line-Bot` project -> Click `Import from Github`. + 3. After logging in, click `Create` in the middle of the homepage -> In the pop-up box, click the top right corner `Import from Github` + 4. If you haven't joined the Github repository, click the link `Connect GitHub to import your private repos.` -> Check `Only select repositories` -> Select `ChatGPT-Line-Bot` + 5. Go back to step 4, at this time, the `Github URL` can choose the `ChatGPT-Line-Bot` project -> Click `Import from Github`. ### Project Execution -1. Environment Variable Setup - 1. After completing the previous `Import` step, click `Tools` at the bottom left of the project management page in `Replit` and click `Secrets`. - 2. After clicking `Got it` on the right, you can add environment variables. You need to add: + +1. Environment variable setup + 1. After completing the previous step `Import` in `Replit`, click `Tools` in the lower left corner of the project management page. + 2. After clicking `Got it` on the right side, you can add environment variables. You need to add: 1. Line Channel Secret: - key: `LINE_CHANNEL_SECRET` - - value: `[Obtained from step one]` + - value: `[obtained from step one]` 2. Line Channel Access Token: - key: `LINE_CHANNEL_ACCESS_TOKEN` - - value: `[Obtained from step one]` + - value: `[obtained from step one]` -2. Start Execution +2. Start execution 1. Click `Run` at the top - 2. After successful execution, the right panel will display `Hello World`, and copy the URL in the upper right corner of the panel - 3. Go back to Line Developer, in `Messaging API`, paste the above URL in `Webhook URL`, and add `/callback` to it, for example: `https://ChatGPT-Line-Bot.jimmylin.repl.co/callback` - 4. Turn on `Use webhook` + 2. After successful execution, the right side of the screen will display `Hello World`, and copy the **URL** at the top of the screen + 3. Go back to Line Developer, in `Messaging API`, paste the URL from the previous step, and add `/callback` to it, for example: `https://ChatGPT-Line-Bot.jimmylin.repl.co/callback` + 4. Turn on `Use webhook` below 5. Turn off `Auto-reply messages` below - Note: If there are no requests within an hour, the program will be interrupted, so the next step is needed -3. CronJob Scheduled Requests - 1. Register/Log in to [cron-job.org](https://cron-job.org/en/) - 2. After logging in, choose `CREATE CRONJOB` at the top right of the panel +3. CronJob for timed requests + 1. Register/Login to [cron-job.org](https://cron-job.org/en/) + 2. After logging in, select `CREATE CRONJOB` in the upper right corner of the panel 3. Enter `ChatGPT-Line-Bot` for `Title`, enter the URL from the previous step, for example: `https://ChatGPT-Line-Bot.jimmylin.repl.co/` 4. Set it to run every `5 minutes` below 5. Click `CREATE` -### Connect Services and Line Bot +### Connect Service and Line Bot + +Go back to [Line Developer](https://manager.line.biz/account) homepage and click `Add friend guide` to scan the LINE Bot QR code: + +Homepage -> Click your bot -> Click `Add friend tools` -> Create a friend action barcode (https://manager.line.biz/account//gainfriends) + +Congratulations on creating your first LINE Bot! Try talking to it, it will reply to you! -Go back to [Line Developer](https://manager.line.biz/account) homepage and click `Add Friend Guide` to scan and add the LINE Bot: +### Special Commands -Homepage -> Click on your bot -> Click `Add Friend Tools` -> Create Friend QR Code (https://manager.line.biz/account//gainfriends) +| Command | Description | +| --- | ----- | +| `@chat` | Enter `@chat` + message in the input box to call chatgpt in the Line group | +| `@chat 星座運勢 <星座名稱>` (Chinese) | Enter `@chat 星座運勢 天蠍座` in the input box to get the weekly horoscope for Scorpio (or any other constellation) | -Congratulations on creating your first LINE Bot! Try talking to it and it will reply to you! +![](img/2023-11-02-10-00-32.png) ### Advanced - Personalized Bot -In addition, we can make the Line Bot answer more personalized by using the `prompt` method. In `./chatgpt_linebot/prompts/template.py`, we can define a `template`, for example: +In addition, we can use the `prompt` method to make the Line Bot answer in a personalized way. In `./chatgpt_linebot/prompts/template.py`, we can define a `template`, for example: **Question**: What did you have for breakfast today? -**Bot Answer**: Darling, are you awake yet? I've been waiting for you in bed and I'm feeling so hungry just thinking about your body. What should we have for breakfast today? How about some spicy scrambled eggs, as hot as your charming figure? 😏🍳 +**Bot's Answer**: Darling, did you wake up this morning? I've been waiting for you in bed, and thinking about your body makes me so hungry. What should we have for breakfast today? How about some spicy scrambled eggs, as hot as your charming figure? 😏🍳 --- diff --git a/README.md b/README.md index 8d371a3..005a671 100644 --- a/README.md +++ b/README.md @@ -1,101 +1,109 @@ +以下是您提供的文本的修正版本,已經適應 markdown 格式,不再包含 ```markdown``` code block 標示: + +-------------------------------- # ChatGPT Line Bot * [English](README.md) -* [Traditional Chinese Version README.md](README.zh-TW.md) +* [Traditional Chinese version README.md](README.zh-TW.md) * [Simplified Chinese](README.zh-CN.md) * [French](README.French.md) * [Arabic](README.Arabic.md) - ## Introduction -Introduce ChatGPT Bot in Line, you can start interacting with ChatGPT by entering text directly in the input box. +To introduce ChatGPT Bot in Line, simply enter text in the input box to start interacting with ChatGPT. - +![ChatGPT Line Bot](img/2023-10-25-10-03-47.png) ## Tools and Features -* `Python FastAPI`: Build a response API for ChatGPT -* `gpt4free`: **Free use of OpenAI API** -* `Line messaging API channel`: Integrate with ChatGPT API -* `Github`: Store the code -* `replit`: **Free deployment of your own FastAPI** -* `CronJob`: Free scheduled request sending to prevent API interruption - +* **Python FastAPI**: Create ChatGPT response API +* **gpt4free**: Free use of OpenAI API +* **Line messaging API channel**: Integrate ChatGPT API +* **Github**: Store code +* **replit**: Free deployment of your own FastAPI +* **CronJob**: Free scheduled request sending to prevent API interruptions ## Installation Steps -### Token Acquisition +### Obtaining Tokens 1. Get the Line Token: 1. Log in to [Line Developer](https://developers.line.biz/zh-hant/) 2. Create a bot: - 1. Create a `Provider` -> click `Create` - 2. Create a `Channel` -> choose `Create a Messaging API channel` - 3. Fill in the required basic information - 4. After completion, under `Basic Settings`, there is a `Channel Secret` -> click `Issue`, it will be generated as `LINE_CHANNEL_SECRET` (will be used later) - 5. Under `Messaging API`, there is a `Channel access token` -> click `Issue`, it will be generated as `LINE_CHANNEL_ACCESS_TOKEN` (will be used later) + 1. Create a `Provider` -> Click on `Create` + 2. Create a `Channel` -> Select `Create a Messaging API channel` + 3. Enter the required basic information + 4. After completing the entry, below "Basic Settings," there is a "Channel Secret" -> Click on "Issue," and the generated value is your `LINE_CHANNEL_SECRET` (will be used later) + 5. Below "Messaging API," there is a "Channel access token" -> Click on "Issue," and the generated value is your `LINE_CHANNEL_ACCESS_TOKEN` (will be used later) ### Project Setup + 1. Fork the Github project: - 1. Register/Login to [GitHub](https://github.com/) + 1. Register/Log in to [GitHub](https://github.com/) 2. Go to [ChatGPT-Line-Bot](https://github.com/Lin-jun-xiang/ChatGPT-Line-Bot) - 3. Click `Star` to support the developer - 4. Click `Fork` to copy all the code to your own repository -2. Deployment (Free Space): + 3. Click on `Star` to support the developer + 4. Click on `Fork` to copy all the code to your repository +2. Deployment (free space): 1. Go to [replit](https://replit.com/) - 2. Click `Sign Up` to log in with your `Github` account and authorize it -> click `Skip` to skip the initialization setup - 3. After entering, click `Create` on the middle homepage -> a pop-up box will appear, click the top right corner `Import from Github` - 4. If you haven't joined the Github repository, click the link `Connect GitHub to import your private repos.` -> check `Only select repositories` -> choose `ChatGPT-Line-Bot` - 5. Go back to step four, at this time the `Github URL` can choose the `ChatGPT-Line-Bot` project -> click `Import from Github`. + 2. Click on `Sign Up` and log in with your GitHub account and authorize it -> Click on `Skip` to skip the initial setup + 3. Once inside, click on `Create` in the middle of the homepage -> A dialog will pop up, click on "Import from Github" in the top right corner + 4. If you haven't added your Github repository, click on the link "Connect GitHub to import your private repos." -> Check "Only select repositories" -> Choose "ChatGPT-Line-Bot" + 5. Go back to step 4; at this point, the "Github URL" can be set to the "ChatGPT-Line-Bot" project -> Click on "Import from Github." ### Project Execution + 1. Environment Variable Setup - 1. After completing the previous step `Import` in `Replit`, click `Tools` at the bottom left of the project management page of `Replit` and click `Secrets`. - 2. After clicking `Got it` on the right side, you can add environment variables. You need to add: + 1. After completing the "Import" from the previous step, on the project management page in "Replit," click on "Tools" in the bottom left corner and then click on "Secrets." + 2. After clicking "Got it" on the right, you can add environment variables, including: 1. Line Channel Secret: - - key: `LINE_CHANNEL_SECRET` - - value: `[obtained from step one]` + - Key: `LINE_CHANNEL_SECRET` + - Value: `[Obtained in step one]` 2. Line Channel Access Token: - - key: `LINE_CHANNEL_ACCESS_TOKEN` - - value: `[obtained from step one]` - - + - Key: `LINE_CHANNEL_ACCESS_TOKEN` + - Value: `[Obtained in step one]` 2. Start Execution - 1. Click `Run` at the top - 2. After successful execution, the right panel will display `Hello World`, and copy the **URL** in the upper right corner of the panel - 3. Go back to Line Developer, paste the URL from the previous step into `Webhook URL` under `Messaging API`, and add `/callback` to it, for example: `https://ChatGPT-Line-Bot.jimmylin.repl.co/callback` - 4. Turn on `Use webhook` below - 5. Turn off `Auto-reply messages` below - - Note: If there is no request within an hour, the program will be interrupted, so the next step is needed - - + 1. Click on "Run" at the top + 2. After a successful run, the right side of the screen will display "Hello World," and copy the URL at the top of the screen + 3. Go back to Line Developer, in "Messaging API," paste the URL from above and add "/callback," for example: `https://ChatGPT-Line-Bot.jimmylin.repl.co/callback` + 4. Enable "Use webhook" below + 5. Turn off "Auto-reply messages" below + - Note: If there are no requests within an hour, the program will terminate, so this step is necessary 3. CronJob Scheduled Request Sending - 1. Register/Login to [cron-job.org](https://cron-job.org/en/) - 2. After logging in, select `CREATE CRONJOB` in the upper right corner of the dashboard - 3. Enter `ChatGPT-Line-Bot` for `Title`, enter the URL of the previous step, for example: `https://ChatGPT-Line-Bot.jimmylin.repl.co/` - 4. Set it to trigger every `5 minutes` below - 5. Click `CREATE` + 1. Register/Log in to [cron-job.org](https://cron-job.org/en/) + 2. Once logged in, select "CREATE CRONJOB" in the upper right corner + 3. Enter "ChatGPT-Line-Bot" as the title, and enter the URL from the previous step, for example: `https://ChatGPT-Line-Bot.jimmylin.repl.co/` + 4. Set it to run every "5 minutes" + 5. Click on "CREATE" + +### Connect Service and Line Bot + +Go back to [Line Developer](https://manager.line.biz/account) and click on "Join a Friend Guide" to scan and add the LINE Bot: + +Home -> Click on your bot -> Click on "Add Friends Tool" -> Create a Friend Action Code (https://manager.line.biz/account//gainfriends) -### Connect Services and Line Bot +Congratulations, you have created your first LINE Bot! Try talking to it, and it will reply to you! -Go back to [Line Developer](https://manager.line.biz/account) homepage and click `Add Friend Guide` to scan the LINE Bot QR code: +### Special Commands -Homepage -> Click your bot -> Click `Add Friend Tools` -> Create a Friend QR code (https://manager.line.biz/account//gainfriends) +| Command | Description | +| --- | ----- | +| `@chat` | Enter `@chat` + a message in the input box to call chatgpt in the Line group | +| `@chat Horoscope ` | Enter `@chat Horoscope Scorpio` in the input box to get this week's Scorpio (or any other zodiac sign) horoscope; this feature is available only in Traditional Chinese | -Congratulations on creating your first LINE Bot! Try talking to it and see how it responds! +![Sample Commands](img/2023-11-02-10-00-32.png) ### Advanced - Personalized Bot -In addition, we can make the Line Bot answer personalized by using the `prompt` method. In `./chatgpt_linebot/prompts/template.py`, we can define a `template`, for example: +Additionally, you can use the "prompt" method to make the Line Bot respond in a personalized way. In `./chatgpt_linebot/prompts/template.py`, you can define a `template`, for example: - +![Personalized Bot Example](img/2023-10-27-10-09-17.png) **Question**: What did you have for breakfast today? -**Bot's Answer**: Darling, are you awake in the morning? I've been waiting for you in bed, and thinking about your body makes me so hungry. What should we have for breakfast today? How about some spicy scrambled eggs, as hot as your charming figure? 😏🍳 +**Bot's Answer**: Darling, are you awake yet? I've been waiting for you in bed. Thinking of your body makes me so hungry. What should we have for breakfast today? How about a spicy omelette, just as hot as your seductive figure? 😏🍳 --- diff --git a/README.zh-CN.md b/README.zh-CN.md index a11fd35..e0e1dda 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -1,4 +1,8 @@ -# ChatGPT Line Bot +以下是您提供的文本,我已经根据您的要求进行微调,确保它不再包含Markdown代码块标识。请注意,以下文本将在您的环境中正常显示,而不是作为Markdown。 + +-------------------------------- + +ChatGPT Line Bot * [English](README.md) * [繁體中文版README.md](README.zh-TW.md) @@ -6,26 +10,24 @@ * [Française](README.French.md) * [عربى](README.Arabic.md) - -## 介绍 +介绍 在 Line 中去导入 ChatGPT Bot,只要在输入框直接输入文字,即可与 ChatGPT 开始互动。 - - -## 工具与特色 + -* `Python FastAPI`: 建立 ChatGPT 响应 API -* `gpt4free`: **免费使用 OpenAI API** -* `Line messaging API channel`: 串接 ChatGPT API -* `Github`: 存放程式码 -* `replit`: **免费部署自己的 FastAPI** -* `CronJob`: 免费定时发送请求,避免 API 中断 +工具与特色 +* Python FastAPI: 建立 ChatGPT 响应 API +* gpt4free: 免费使用 OpenAI API +* Line messaging API channel: 串接 ChatGPT API +* Github: 存放程式码 +* replit: 免费部署自己的 FastAPI +* CronJob: 免费定时发送请求,避免 API 中断 -## 安装步骤 +安装步骤 -### Token 取得 +Token 取得 1. 取得 Line Token: 1. 登入 [Line Developer](https://developers.line.biz/zh-hant/) @@ -36,31 +38,31 @@ 4. 输入完成后,在 `Basic Settings` 下方,有一个 `Channel Secret` -> 按下 `Issue`,生成后即为 `LINE_CHANNEL_SECRET` (稍晚会用到) 5. 在 `Messaging API` 下方,有一个 `Channel access token` -> 按下 `Issue`,生成后即为 `LINE_CHANNEL_ACCESS_TOKEN` (稍晚会用到) -### 專案設置 +專案設置 + 1. Fork Github 專案: - 1. 注册/登入 [GitHub](https://github.com/) + 1. 注册/登录 [GitHub](https://github.com/) 2. 进入 [ChatGPT-Line-Bot](https://github.com/Lin-jun-xiang/ChatGPT-Line-Bot) 3. 点击 `Star` 支持开发者 4. 点击 `Fork` 复制全部的程式码到自己的仓库 2. 部署(免费空间): 1. 进入 [replit](https://replit.com/) - 2. 点击 `Sign Up` 直接用 `Github` 帐号登入并授权 -> 按下 `Skip` 跳过初始化设定 - 3. 进入后中间主页的部分点击 `Create` -> 弹出框,点击右上角 `Import from Github` + 2. 点击 `Sign Up` 直接用 `Github` 帐号登录并授权 -> 按下 `Skip` 跳过初始化设定 + 3. 进入后中间主页的部分点击 `Create` -> 跳出框,点击右上角 `Import from Github` 4. 若尚未加入 Github 仓库,则点击链接 `Connect GitHub to import your private repos.` -> 勾选 `Only select repositories` -> 选择 `ChatGPT-Line-Bot` 5. 回到第四步,此时 `Github URL` 可以选择 `ChatGPT-Line-Bot` 專案 -> 点击 `Import from Github`。 -### 專案執行 +專案執行 + 1. 环境变数设定 1. 接续上一步 `Import` 完成后在 `Replit` 的專案管理页面左下方 `Tools` 点击 `Secrets`。 2. 右方按下 `Got it` 后,即可新增环境变数,需新增: 1. Line Channel Secret: - key: `LINE_CHANNEL_SECRET` - - value: `[由步驟一取得]` + - value: `[由步骤一取得]` 2. Line Channel Access Token: - key: `LINE_CHANNEL_ACCESS_TOKEN` - - value: `[由步驟一取得]` - - + - value: `[由步骤一取得]` 2. 开始执行 1. 点击上方的 `Run` @@ -68,39 +70,32 @@ 3. 回到 Line Developer,在 `Messaging API` 下方的 `Webhook URL` 将上方网址贴过来,并加上 `/callback` 例如:`https://ChatGPT-Line-Bot.jimmylin.repl.co/callback` 4. 打开下方的 `Use webhook` 5. 将下方 `Auto-reply messages` 关闭 - - 注意:若一小时内没有任何请求,则程式会中断,因此需要下步骤 - +3. 注意:若一小时内没有任何请求,则程式会中断,因此需要下步骤 -3. CronJob 定时发送请求 - 1. 注册/登入 [cron-job.org](https://cron-job.org/en/) - 2. 进入后面板右上方选择 `CREATE CRONJOB` - 3. `Title` 输入 `ChatGPT-Line-Bot`,网址输入上一步驟的网址,例如:`https://ChatGPT-Line-Bot.jimmylin.repl.co/` - 4. 下方则每 `5 分钟` 打一次 - 5. 按下 `CREATE` +CronJob 定时发送请求 -### 連結服務與 Line Bot +1. 注册/登录 [cron-job.org](https://cron-job.org/en/) +2. 进入后面板右上方选择 `CREATE CRONJOB` +3. `Title` 输入 `ChatGPT-Line-Bot`,网址输入上一步的网址,例如:`https://ChatGPT-Line-Bot.jimmylin.repl.co/` +4. 下方则每 `5 分钟` 打一次 +5. 按下 `CREATE` + +连结服务与 Line Bot 返回 [Line Developer](https://manager.line.biz/account) 首页并点击 `加入好友指南` 后扫码加入 LINE Bot: 主页 -> 点击你的 bot -> 点击增加好友工具 -> 建立好友行动条码 (https://manager.line.biz/account//gainfriends) -恭喜您完成了自己的第一个 LINE Bot! 试着跟它说话看看吧,它会回复你喔! - -### 進階 - 個性化 Bot - -另外,我们可以透过 `prompt` 的方式,来让 Line Bot 回答个性化,在 `./chatgpt_linebot/prompts/template.py` 中我们可以定义 `template`,例如: - - - -**提问内容**:今天早餐吃啥? - -**Bot回答**: 宝贝,早上起床了吗?我已经在床上等着你了,想着你的身体就觉得好饿呀。今天早餐该吃什么呢?是不是要来点辣辣的煎蛋卷,像你那迷人的身材一样火辣呢?😏🍳 +恭喜您完成了自己的第一个 LINE Bot! 试着跟它说话看看吧,它会回覆你喔! ---- +特殊指令 -## 参考 +| 指令 | 说明 | +| --- | ----- | +| `@chat` | 在输入框输入 `@chat` + 信息,就可以在 line 群组中呼叫 chatgpt | +| `@chat 星座运势 <星座名称>` | 在输入框输入 `@chat 星座运势 天蝎座`,就可以获得本周天蝎座(任意星座皆可)运势,该功能仅限用繁體中文 | -[Line_Bot_Tutorial](https://github.com/FawenYo/LINE_Bot_Tutorial) +![](img/2023-11-02-10-00-32.png) -[ChatGPT-Line-Bot](https://github.com/TheExplainthis/ChatGPT-Line-Bot) \ No newline at end of file +进阶 - 个性化 Bot \ No newline at end of file