ilhamdev commited on
Commit
c015809
·
1 Parent(s): c2518b7

deploy: update quote-api backend for Hugging Face Spaces

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .editorconfig +0 -9
  2. .env.example +0 -3
  3. .eslintrc.json +0 -17
  4. .gitattributes +9 -40
  5. .github/workflows/emoji-apple-update.yaml +65 -0
  6. .gitignore +10 -66
  7. .vscode/launch.json +0 -18
  8. Dockerfile +16 -33
  9. LICENSE +21 -0
  10. Procfile +1 -0
  11. README.md +93 -217
  12. app.js +0 -56
  13. assets/Quotly.png +0 -0
  14. assets/emoji/emoji-blob-image.json +0 -0
  15. assets/fonts/.gitkeep +0 -0
  16. assets/{emoji/emoji-apple-image.json → image/pattern_02.png} +2 -2
  17. assets/{emoji/emoji-google-image.json → image/pattern_03.jpg} +2 -2
  18. assets/{emoji/emoji-joypixels-image.json → image/pattern_04.jpg} +2 -2
  19. assets/{emoji/emoji-twitter-image.json → image/pattern_05.jpg} +2 -2
  20. assets/image/pattern_06.jpg +3 -0
  21. assets/image/pattern_07.jpg +3 -0
  22. assets/image/pattern_08.jpg +3 -0
  23. assets/image/pattern_ny.png +3 -0
  24. assets/{pattern_ny_old.png → image/pattern_ny_old.png} +0 -0
  25. assets/img-emoji-apple/.version +1 -0
  26. assets/img-emoji-apple/0023-fe0f-20e3.png +0 -0
  27. assets/img-emoji-apple/002a-fe0f-20e3.png +0 -0
  28. assets/img-emoji-apple/0030-fe0f-20e3.png +0 -0
  29. assets/img-emoji-apple/0031-fe0f-20e3.png +0 -0
  30. assets/img-emoji-apple/0032-fe0f-20e3.png +0 -0
  31. assets/img-emoji-apple/0033-fe0f-20e3.png +0 -0
  32. assets/img-emoji-apple/0034-fe0f-20e3.png +0 -0
  33. assets/img-emoji-apple/0035-fe0f-20e3.png +0 -0
  34. assets/img-emoji-apple/0036-fe0f-20e3.png +0 -0
  35. assets/img-emoji-apple/0037-fe0f-20e3.png +0 -0
  36. assets/img-emoji-apple/0038-fe0f-20e3.png +0 -0
  37. assets/img-emoji-apple/0039-fe0f-20e3.png +0 -0
  38. assets/img-emoji-apple/00a9-fe0f.png +0 -0
  39. assets/img-emoji-apple/00ae-fe0f.png +0 -0
  40. assets/img-emoji-apple/1f004.png +0 -0
  41. assets/img-emoji-apple/1f0cf.png +0 -0
  42. assets/img-emoji-apple/1f170-fe0f.png +0 -0
  43. assets/img-emoji-apple/1f171-fe0f.png +0 -0
  44. assets/img-emoji-apple/1f17e-fe0f.png +0 -0
  45. assets/img-emoji-apple/1f17f-fe0f.png +0 -0
  46. assets/img-emoji-apple/1f18e.png +0 -0
  47. assets/img-emoji-apple/1f191.png +0 -0
  48. assets/img-emoji-apple/1f192.png +0 -0
  49. assets/img-emoji-apple/1f193.png +0 -0
  50. assets/img-emoji-apple/1f194.png +0 -0
.editorconfig DELETED
@@ -1,9 +0,0 @@
1
- root = true
2
-
3
- [*]
4
- charset = utf-8
5
- end_of_line = lf
6
- insert_final_newline = true
7
- trim_trailing_whitespace = true
8
- indent_style = space
9
- indent_size = 2
 
 
 
 
 
 
 
 
 
 
.env.example DELETED
@@ -1,3 +0,0 @@
1
- PORT="4888"
2
- BOT_TOKEN=""
3
- EMOJI_DOMAIN="https://emojipedia.org/"
 
 
 
 
.eslintrc.json DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "env": {
3
- "es6": true,
4
- "node": true
5
- },
6
- "extends": "standard",
7
- "globals": {
8
- "Atomics": "readonly",
9
- "SharedArrayBuffer": "readonly"
10
- },
11
- "parserOptions": {
12
- "ecmaVersion": 2018,
13
- "sourceType": "module"
14
- },
15
- "rules": {
16
- }
17
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.gitattributes CHANGED
@@ -1,40 +1,9 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
36
- assets/emoji/emoji-apple-image.json filter=lfs diff=lfs merge=lfs -text
37
- assets/emoji/emoji-google-image.json filter=lfs diff=lfs merge=lfs -text
38
- assets/emoji/emoji-joypixels-image.json filter=lfs diff=lfs merge=lfs -text
39
- assets/emoji/emoji-twitter-image.json filter=lfs diff=lfs merge=lfs -text
40
- assets/pattern_ny_old.png filter=lfs diff=lfs merge=lfs -text
 
1
+ assets/image/*.png filter=lfs diff=lfs merge=lfs -text
2
+ assets/image/*.jpg filter=lfs diff=lfs merge=lfs -text
3
+ assets/image/*.jpeg filter=lfs diff=lfs merge=lfs -text
4
+ public/*.png filter=lfs diff=lfs merge=lfs -text
5
+ public/*.jpg filter=lfs diff=lfs merge=lfs -text
6
+ public/*.jpeg filter=lfs diff=lfs merge=lfs -text
7
+ public/*.ico filter=lfs diff=lfs merge=lfs -text
8
+ frontend/public/*.ico filter=lfs diff=lfs merge=lfs -text
9
+ frontend/public/*.png filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.github/workflows/emoji-apple-update.yaml ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Emoji Apple Update
2
+
3
+ on:
4
+ # schedule:
5
+ # - cron: '0 0 * * 0' # Runs weekly at midnight on Sunday
6
+ workflow_dispatch: # Allows manual trigger
7
+
8
+ jobs:
9
+ update-emoji:
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - name: Checkout repository
14
+ uses: actions/checkout@v4
15
+ with:
16
+ token: ${{ secrets.GITHUB_TOKEN }}
17
+
18
+ - name: Get current version
19
+ id: current_version
20
+ run: |
21
+ if [ -f "assets/img-emoji-apple/.version" ]; then
22
+ echo "version=$(cat assets/img-emoji-apple/.version)" >> $GITHUB_OUTPUT
23
+ else
24
+ echo "version=0" >> $GITHUB_OUTPUT
25
+ fi
26
+
27
+ - name: Get latest commit SHA from source repo
28
+ id: latest_version
29
+ run: |
30
+ response=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/iamcal/emoji-data/commits?path=img-apple-64&per_page=1)
31
+ echo "::set-output name=sha::$(jq -r '.[0].sha' <<< "$response")"
32
+
33
+ - name: Check if update needed
34
+ id: check_update
35
+ run: |
36
+ if [ "${{ steps.current_version.outputs.version }}" != "${{ steps.latest_version.outputs.sha }}" ]; then
37
+ echo "needs_update=true" >> $GITHUB_OUTPUT
38
+ else
39
+ echo "needs_update=false" >> $GITHUB_OUTPUT
40
+ fi
41
+
42
+ - name: Download emoji images
43
+ if: steps.check_update.outputs.needs_update == 'true'
44
+ run: |
45
+ cd assets/img-emoji-apple
46
+
47
+ # Get list of files from the folder
48
+ FILES=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/iamcal/emoji-data/contents/img-apple-64 | jq -r '.[] | select(.type=="file") | .download_url')
49
+
50
+ # Download each file
51
+ for file_url in $FILES; do
52
+ wget -q "$file_url"
53
+ done
54
+
55
+ # Save version
56
+ echo "${{ steps.latest_version.outputs.sha }}" > .version
57
+
58
+ - name: Commit and push changes
59
+ if: steps.check_update.outputs.needs_update == 'true'
60
+ run: |
61
+ git config --local user.email "github-actions[bot]@users.noreply.github.com"
62
+ git config --local user.name "github-actions[bot]"
63
+ git add assets/img-emoji-apple/
64
+ git commit -m "Update emoji apple images - ${{ steps.latest_version.outputs.sha }}"
65
+ git push
.gitignore CHANGED
@@ -1,66 +1,10 @@
1
- # Logs
2
- logs
3
- *.log
4
- npm-debug.log*
5
- yarn-debug.log*
6
- yarn-error.log*
7
-
8
- # Runtime data
9
- pids
10
- *.pid
11
- *.seed
12
- *.pid.lock
13
-
14
- # Directory for instrumented libs generated by jscoverage/JSCover
15
- lib-cov
16
-
17
- # Coverage directory used by tools like istanbul
18
- coverage
19
-
20
- # nyc test coverage
21
- .nyc_output
22
-
23
- # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24
- .grunt
25
-
26
- # Bower dependency directory (https://bower.io/)
27
- bower_components
28
-
29
- # node-waf configuration
30
- .lock-wscript
31
-
32
- # Compiled binary addons (https://nodejs.org/api/addons.html)
33
- build/Release
34
-
35
- # Dependency directories
36
- node_modules/
37
- jspm_packages/
38
-
39
- # TypeScript v1 declaration files
40
- typings/
41
-
42
- # Optional npm cache directory
43
- .npm
44
-
45
- # Optional eslint cache
46
- .eslintcache
47
-
48
- # Optional REPL history
49
- .node_repl_history
50
-
51
- # Output of 'npm pack'
52
- *.tgz
53
-
54
- # Yarn Integrity file
55
- .yarn-integrity
56
-
57
- # dotenv environment variables file
58
- .env
59
-
60
- # next.js build output
61
- .next
62
-
63
- assets/fonts/*
64
- assets/emojis/*
65
-
66
- !.gitkeep
 
1
+ .DS_Store
2
+ .env
3
+ */.DS_Store
4
+ lib
5
+ node_modules
6
+ package-lock.json
7
+ test*
8
+ dist
9
+ frontend/dist
10
+ .superpowers
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.vscode/launch.json DELETED
@@ -1,18 +0,0 @@
1
- {
2
- // Use IntelliSense to learn about possible attributes.
3
- // Hover to view descriptions of existing attributes.
4
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
- "version": "0.2.0",
6
- "configurations": [
7
- {
8
- "type": "node",
9
- "runtimeVersion": "16.5.0",
10
- "request": "launch",
11
- "name": "Launch Program",
12
- "skipFiles": [
13
- "<node_internals>/**"
14
- ],
15
- "program": "${workspaceFolder}/index.js"
16
- }
17
- ]
18
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Dockerfile CHANGED
@@ -1,33 +1,16 @@
1
- # Gunakan versi Node.js yang spesifik untuk menghindari masalah yang mungkin timbul dari perubahan versi terbaru
2
- FROM node:14
3
-
4
- # Buat direktori aplikasi
5
- WORKDIR /app
6
-
7
- # Salin package.json dan package-lock.json terlebih dahulu untuk manfaatkan caching Docker
8
- COPY package*.json ./
9
-
10
- # Install paket yang diperlukan untuk canvas dan dependencies lainnya
11
- RUN apt-get update && apt-get install -y \
12
- build-essential \
13
- gcc \
14
- wget \
15
- git \
16
- libvips \
17
- libcairo2-dev \
18
- libjpeg-dev \
19
- libpango1.0-dev \
20
- libgif-dev \
21
- && rm -rf /var/lib/apt/lists/*
22
-
23
- # Install semua dependencies proyek
24
- RUN npm install
25
-
26
- # Salin semua file proyek ke dalam image
27
- COPY . .
28
-
29
- # Bebaskan port yang digunakan oleh aplikasi
30
- EXPOSE 7860
31
-
32
- # Jalankan aplikasi menggunakan pm2-runtime
33
- CMD ["node", "index.js"]
 
1
+ FROM oven/bun:canary
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apk add --no-cache font-noto font-noto-cjk font-noto-extra gcompat libstdc++ libuuid vips-dev build-base jpeg-dev pango-dev cairo-dev imagemagick libssl1.1
6
+ RUN ln -s /lib/libresolv.so.2 /usr/lib/libresolv.so.2 || true
7
+
8
+ COPY package.json bun.lock* ./
9
+ RUN bun install --frozen-lockfile --production
10
+
11
+ COPY . .
12
+
13
+ ENV PORT=7860
14
+ EXPOSE 7860
15
+
16
+ CMD ["bun", "start"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Dika Ardnt.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
Procfile ADDED
@@ -0,0 +1 @@
 
 
1
+ web: bun start
README.md CHANGED
@@ -1,239 +1,115 @@
1
  ---
2
- title: quote-api
 
 
 
3
  sdk: docker
4
- emoji: 👁
5
- colorFrom: green
6
- colorTo: blue
7
  ---
8
- # quote-api
9
 
10
- [![wakatime](https://wakatime.com/badge/github/LyoSU/quote-api.svg)](https://wakatime.com/badge/github/LyoSU/quote-api)
11
 
12
- Апи для генерации Telegram цитат
13
 
14
- ## Методы
15
- ##### Создание цитаты
16
  ```http
17
- POST /generate
18
  ```
19
 
20
- Пример JSON запроса:
21
- ```json
22
- {
23
- "type": "quote",
24
- "format": "png",
25
- "backgroundColor": "#1b1429",
26
- "width": 512,
27
- "height": 768,
28
- "scale": 2,
29
- "messages": [
30
- {
31
- "entities": [],
32
- "chatId": 66478514,
33
- "avatar": true,
34
- "from": {
35
- "id": 66478514,
36
- "first_name": "Yuri 💜",
37
- "last_name": "Ly",
38
- "username": "LyoSU",
39
- "language_code": "ru",
40
- "title": "Yuri 💜 Ly",
41
- "photo": {
42
- "small_file_id": "AQADAgADCKoxG7Jh9gMACBbSEZguAAMCAAOyYfYDAATieVimvJOu7M43BQABHgQ",
43
- "small_file_unique_id": "AQADFtIRmC4AA843BQAB",
44
- "big_file_id": "AQADAgADCKoxG7Jh9gMACBbSEZguAAMDAAOyYfYDAATieVimvJOu7NA3BQABHgQ",
45
- "big_file_unique_id": "AQADFtIRmC4AA9A3BQAB"
46
- },
47
- "type": "private",
48
- "name": "Yuri 💜 Ly"
49
- },
50
- "text": "I love you 💜",
51
- "replyMessage": {}
52
- }
53
- ]
54
- }
55
- ```
 
 
 
 
 
 
 
 
 
 
 
 
56
 
57
- Медиа:
58
  ```json
59
  {
60
- "type": "quote",
61
- "format": "png",
62
- "backgroundColor": "#1b1429",
63
- "width": 512,
64
- "height": 768,
65
- "scale": 2,
66
- "messages": [
67
- {
68
- "media": [
69
- {
70
- "file_id": "CAACAgIAAxkBAAIyH2AAAUcJoPJqv4uOPabtiSR3judSnQACaQEAAiI3jgQe29BUaNTqrx4E",
71
- "file_size": 22811,
72
- "height": 512,
73
- "width": 512
74
- }
75
- ],
76
- "mediaType": "sticker",
77
- "chatId": 66478514,
78
- "avatar": true,
79
- "from": {
80
- "id": 66478514,
81
- "first_name": "Yuri 💜",
82
- "last_name": "Ly",
83
- "username": "LyoSU",
84
- "language_code": "ru",
85
- "title": "Yuri 💜 Ly",
86
- "photo": {
87
- "small_file_id": "AQADAgADCKoxG7Jh9gMACBbSEZguAAMCAAOyYfYDAATieVimvJOu7M43BQABHgQ",
88
- "small_file_unique_id": "AQADFtIRmC4AA843BQAB",
89
- "big_file_id": "AQADAgADCKoxG7Jh9gMACBbSEZguAAMDAAOyYfYDAATieVimvJOu7NA3BQABHgQ",
90
- "big_file_unique_id": "AQADFtIRmC4AA9A3BQAB"
91
- },
92
- "type": "private",
93
- "name": "Yuri 💜 Ly"
94
- },
95
- "replyMessage": {}
96
- }
97
- ]
98
  }
99
  ```
100
 
101
- Без Telegram
102
- ```json
103
- {
104
- "type": "quote",
105
- "format": "png",
106
- "backgroundColor": "#1b1429",
107
- "width": 512,
108
- "height": 768,
109
- "scale": 2,
110
- "messages": [
111
- {
112
- "entities": [],
113
- "media": {
114
- "url": "https://via.placeholder.com/1000"
115
- },
116
- "avatar": true,
117
- "from": {
118
- "id": 1,
119
- "name": "Mike",
120
- "photo": {
121
- "url": "https://via.placeholder.com/100"
122
- }
123
- },
124
- "text": "Hey",
125
- "replyMessage": {}
126
- }
127
- ]
128
- }
129
- ```
130
-
131
- Параметры:
132
- | Поле | Тип | Описание |
133
- | :------------ | :------------ | :------------ |
134
- | type | string | Тип выходного изображения. Может быть: quote, image, null |
135
- | backgroundColor | string | Цвет фона цитаты. Может быть Hex, название или random для случайного цвета |
136
- | messages | array | Массив из сообщений |
137
- | width | number | Максимальная ширина |
138
- | height | number | Максимальная высота |
139
- | scale | number | Маcштаб |
140
-
141
- Пример ответа:
142
 
143
  ```json
144
  {
145
- "ok": true,
146
- "result": {
147
- "image": "base64 image",
148
- "type": "quote",
149
- "width": 512,
150
- "height": 359
151
- }
152
  }
153
-
154
  ```
155
 
156
- ## Примеры запросов:
157
- > JavaScript
158
- ```js
159
- const axios = require('axios')
160
- const fs = require('fs')
161
-
162
- const text = "Hello World"
163
- const username = "Alι_Aryαɴ"
164
- const avatar = "https://telegra.ph/file/59952c903fdfb10b752b3.jpg"
165
-
166
- const json = {
167
- "type": "quote",
168
- "format": "png",
169
- "backgroundColor": "#FFFFFF",
170
- "width": 512,
171
- "height": 768,
172
- "scale": 2,
173
- "messages": [
174
- {
175
- "entities": [],
176
- "avatar": true,
177
- "from": {
178
- "id": 1,
179
- "name": username,
180
- "photo": {
181
- "url": avatar
182
- }
183
- },
184
- "text": text,
185
- "replyMessage": {}
186
- }
187
- ]
188
- };
189
- const response = axios.post('https://bot.lyo.su/quote/generate', json, {
190
- headers: {'Content-Type': 'application/json'}
191
- }).then(res => {
192
- const buffer = Buffer.from(res.data.result.image, 'base64')
193
- fs.writeFile('Quotly.png', buffer, (err) => {
194
- if (err) throw err;
195
- })
196
- });
197
- ```
198
-
199
- > Python
200
- ```py
201
- import requests
202
- import base64
203
-
204
- text = "Hello World"
205
- username = "Alι_Aryαɴ"
206
- avatar = "https://telegra.ph/file/59952c903fdfb10b752b3.jpg"
207
-
208
- json = {
209
- "type": "quote",
210
- "format": "webp",
211
- "backgroundColor": "#FFFFFF",
212
- "width": 512,
213
- "height": 768,
214
- "scale": 2,
215
- "messages": [
216
- {
217
- "entities": [],
218
- "avatar": True,
219
- "from": {
220
- "id": 1,
221
- "name": username,
222
- "photo": {
223
- "url": avatar
224
- }
225
- },
226
- "text": text,
227
- "replyMessage": {}
228
- }
229
- ]
230
- }
231
-
232
- response = requests.post('https://bot.lyo.su/quote/generate', json=json).json()
233
- buffer = base64.b64decode(response['result']['image'].encode('utf-8'))
234
- open('Quotly.png', 'wb').write(buffer)
235
- print('Quotly.png')
236
- ```
237
  ### Response
238
-
239
- ![Quotly.png](assets/Quotly.png)
 
 
 
1
  ---
2
+ title: Quote API
3
+ emoji: 💬
4
+ colorFrom: indigo
5
+ colorTo: purple
6
  sdk: docker
7
+ app_port: 7860
 
 
8
  ---
 
9
 
10
+ # API For Generating Telegram Quote
11
 
12
+ ## Method
13
 
 
 
14
  ```http
15
+ POST /
16
  ```
17
 
18
+ ## Parameters:
19
+
20
+ | Field | Type | Description |
21
+ | :-------------- | :----- | :------------------------------------------------------------------------------- |
22
+ | type | string | Output Image Type. Can be: quote, image, stories, null |
23
+ | backgroundColor | string | The background color of the quote. Can be Hex, name or random for a random color |
24
+ | backgroundImage | string | The background image of the quote. Can be a URL or base64 encoded image. |
25
+ | messages | array | Array of messages |
26
+ | width | number | Maximum width |
27
+ | height | number | Maximum height |
28
+ | scale | number | Scale |
29
+
30
+ ## Messages Data
31
+ | Field | Type | Required | Description |
32
+ | :-------------------------------- | :----- | :-------- | :----------------------------------------------- |
33
+ | entities | array | false | by default the value must be an array, but you can fill it with the string _auto_ |
34
+ | entities[].type | string | false | Can be bold, custom_emoji, code, url, hashtag, mention, italic, strikethrough, monospace, spoiler |
35
+ | entities[].offset | number | false | offset text |
36
+ | entities[].length | number | false | length text |
37
+ | chatId | number | false | id chat telegram |
38
+ | avatar | string | false | load an avatar or profile |
39
+ | text | string | true | message |
40
+ | mediaType | string | false | Can be sticker, image, gif |
41
+ | from.id | string | false | sender telegram id
42
+ | from.first_name | string | false | first name telegram |
43
+ | from.last_name | string | false | last name telegram |
44
+ | from.username | string | false | username telegram |
45
+ | from.language_code | string | false | language code telegram |
46
+ | from.title | string | false | title on telegram like admin, satpam, dll. |
47
+ | from.type | string | false | Type profile on telegram, default as _public_, can be _private_ |
48
+ | from.name | string | true | name of the message sender |
49
+ | from.photo.small_file_id | string | false | profile picture file id telegram |
50
+ | from.photo.small_file_unique_id | string | false | profile picture file unique id telegram |
51
+ | from.photo.big_file_id | string | false | profile picture file id telegram |
52
+ | from.photo.big_file_unique_id | string | false | profile picture file unique id telegram |
53
+ | from.photo.url | string | false | profile picture message sender |
54
+ | replyMessage.name | string | false | quoted name |
55
+ | replyMessage.text | string | false | quoted message |
56
+ | replyMessage.entities | string | false | same as before |
57
+ | media.file_id | string | false | file media id message telegram |
58
+ | media.file_size | number | false | file size media message telegram |
59
+ | media.height | number | false | media height message telegram |
60
+ | media.width | number | false | media width message telegram |
61
+ | media.url | string | false | media message |
62
+
63
+ <br>
64
+
65
+ ## Example Simple request:
66
 
 
67
  ```json
68
  {
69
+ "type": "",
70
+ "format": "png",
71
+ "backgroundColor": "#1b1e23",
72
+ "width": 512,
73
+ "height": 720,
74
+ "scale": 2, // type "stories" use scale 4
75
+ "watermark": "hisoka.net", // only for type "stories"
76
+ "messages": [
77
+ {
78
+ "entities": "auto",
79
+ "avatar": true,
80
+ "from": {
81
+ "name": "Hisoka.net",
82
+ "photo": {
83
+ "url": "https://hisoka.net/img/hisoka.png"
84
+ }
85
+ },
86
+ "text": "Hisoka is a WhatsApp Bot hosting service built to streamline automation management\n\n🔗 https://www.hisoka.net",
87
+ "replyMessage": {
88
+ "name": "Dika Ardnt.",
89
+ "text": "What is Hisoka?",
90
+ "entities": "auto"
91
+ },
92
+ "media": {
93
+ "url": "https://quote.kua.lat/hisoka.jpg"
94
+ }
95
+ }
96
+ ]
 
 
 
 
 
 
 
 
 
 
97
  }
98
  ```
99
 
100
+ Example response:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
 
102
  ```json
103
  {
104
+ "image": "base64 image",
105
+ "type": "quote",
106
+ "width": 512,
107
+ "height": 359
 
 
 
108
  }
 
109
  ```
110
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
  ### Response
112
+ ## [Stories](/Stories.png)
113
+ ## [Image](/Image.png)
114
+ ## [Quote](/#quote)
115
+ <img id="quote" loading="lazy" width="480" height="230" src="/Quotly.png" title="Quotly"></img>
app.js DELETED
@@ -1,56 +0,0 @@
1
- const logger = require('koa-logger')
2
- const responseTime = require('koa-response-time')
3
- const bodyParser = require('koa-bodyparser')
4
- const ratelimit = require('koa-ratelimit')
5
- const Router = require('koa-router')
6
- const Koa = require('koa')
7
-
8
- const app = new Koa()
9
-
10
- app.use(logger())
11
- app.use(responseTime())
12
- app.use(bodyParser())
13
-
14
- const ratelimitВb = new Map()
15
-
16
- app.use(ratelimit({
17
- driver: 'memory',
18
- db: ratelimitВb,
19
- duration: 1000 * 55,
20
- errorMessage: {
21
- ok: false,
22
- error: {
23
- code: 429,
24
- message: 'Rate limit exceeded. See "Retry-After"'
25
- }
26
- },
27
- id: (ctx) => ctx.ip,
28
- headers: {
29
- remaining: 'Rate-Limit-Remaining',
30
- reset: 'Rate-Limit-Reset',
31
- total: 'Rate-Limit-Total'
32
- },
33
- max: 20,
34
- disableHeader: false,
35
- whitelist: (ctx) => {
36
- return ctx.query.botToken === process.env.BOT_TOKEN
37
- },
38
- blacklist: (ctx) => {
39
- }
40
- }))
41
-
42
- app.use(require('./helpers').helpersApi)
43
-
44
- const route = new Router()
45
-
46
- const routes = require('./routes')
47
-
48
- route.use('/*', routes.routeApi.routes())
49
-
50
- app.use(route.routes())
51
-
52
- const port = process.env.PORT || 3000
53
-
54
- app.listen(port, () => {
55
- console.log('Listening on localhost, port', port)
56
- })
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/Quotly.png DELETED
Binary file (28.9 kB)
 
assets/emoji/emoji-blob-image.json DELETED
The diff for this file is too large to render. See raw diff
 
assets/fonts/.gitkeep DELETED
File without changes
assets/{emoji/emoji-apple-image.json → image/pattern_02.png} RENAMED
File without changes
assets/{emoji/emoji-google-image.json → image/pattern_03.jpg} RENAMED
File without changes
assets/{emoji/emoji-joypixels-image.json → image/pattern_04.jpg} RENAMED
File without changes
assets/{emoji/emoji-twitter-image.json → image/pattern_05.jpg} RENAMED
File without changes
assets/image/pattern_06.jpg ADDED

Git LFS Details

  • SHA256: b588a7319715b527195bed4e9d08972a6248ae8121b61cb890d9e59f681dd5d8
  • Pointer size: 131 Bytes
  • Size of remote file: 107 kB
assets/image/pattern_07.jpg ADDED

Git LFS Details

  • SHA256: e043a8f794f8587680527b8d42542c27a2d912dbb2ffd0a8aa4a8e3f0d99f45d
  • Pointer size: 131 Bytes
  • Size of remote file: 125 kB
assets/image/pattern_08.jpg ADDED

Git LFS Details

  • SHA256: e4afa5a17cc242ebfa2cee2c43163140c04876709c41f036c315c3c15c4e408b
  • Pointer size: 131 Bytes
  • Size of remote file: 179 kB
assets/image/pattern_ny.png ADDED

Git LFS Details

  • SHA256: ce1d27dfe6ac5e717d578415bdcd24824293e44288e2a51391842c5c9e083499
  • Pointer size: 131 Bytes
  • Size of remote file: 366 kB
assets/{pattern_ny_old.png → image/pattern_ny_old.png} RENAMED
File without changes
assets/img-emoji-apple/.version ADDED
@@ -0,0 +1 @@
 
 
1
+ a810aad0e9458c99f688b9055dd896e7baee02a8
assets/img-emoji-apple/0023-fe0f-20e3.png ADDED
assets/img-emoji-apple/002a-fe0f-20e3.png ADDED
assets/img-emoji-apple/0030-fe0f-20e3.png ADDED
assets/img-emoji-apple/0031-fe0f-20e3.png ADDED
assets/img-emoji-apple/0032-fe0f-20e3.png ADDED
assets/img-emoji-apple/0033-fe0f-20e3.png ADDED
assets/img-emoji-apple/0034-fe0f-20e3.png ADDED
assets/img-emoji-apple/0035-fe0f-20e3.png ADDED
assets/img-emoji-apple/0036-fe0f-20e3.png ADDED
assets/img-emoji-apple/0037-fe0f-20e3.png ADDED
assets/img-emoji-apple/0038-fe0f-20e3.png ADDED
assets/img-emoji-apple/0039-fe0f-20e3.png ADDED
assets/img-emoji-apple/00a9-fe0f.png ADDED
assets/img-emoji-apple/00ae-fe0f.png ADDED
assets/img-emoji-apple/1f004.png ADDED
assets/img-emoji-apple/1f0cf.png ADDED
assets/img-emoji-apple/1f170-fe0f.png ADDED
assets/img-emoji-apple/1f171-fe0f.png ADDED
assets/img-emoji-apple/1f17e-fe0f.png ADDED
assets/img-emoji-apple/1f17f-fe0f.png ADDED
assets/img-emoji-apple/1f18e.png ADDED
assets/img-emoji-apple/1f191.png ADDED
assets/img-emoji-apple/1f192.png ADDED
assets/img-emoji-apple/1f193.png ADDED
assets/img-emoji-apple/1f194.png ADDED