levix-bot 4.9.1 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/README.md +57 -3
  2. package/SETUP.md +63 -7
  3. package/app.cjs +159 -46
  4. package/deploy/install.sh +10 -5
  5. package/package.json +9 -6
  6. package/public/dashboard/assets/40af6d88b63079a0-BZ8ojJNu.woff2 +0 -0
  7. package/public/dashboard/assets/481acf6760031cee-BypgxfGb.woff2 +0 -0
  8. package/public/dashboard/assets/6d3351fc535f8ef3-D2-eand5.woff2 +0 -0
  9. package/public/dashboard/assets/8ab0af53a3bda9d3-CyCXRvzh.woff2 +0 -0
  10. package/public/dashboard/assets/8f262393e9249e61-TQp-UTiE.woff2 +0 -0
  11. package/public/dashboard/assets/94d65887a83f1282-DmpS2jIq.woff2 +0 -0
  12. package/public/dashboard/assets/99e400330f36ae77-D3oMJlXt.woff2 +0 -0
  13. package/public/dashboard/assets/9d1f41b13e519d90-BVNSOH3d.woff2 +0 -0
  14. package/public/dashboard/assets/a005256cb957ecc7-CoYeBiSI.woff2 +0 -0
  15. package/public/dashboard/assets/b19c2080652a3c2b-DIC32ArD.woff2 +0 -0
  16. package/public/dashboard/assets/c4064400db3750ce-BehTv68k.woff2 +0 -0
  17. package/public/dashboard/assets/c69d345fa1068c2d-CmI34b-g.woff2 +0 -0
  18. package/public/dashboard/assets/cc27b30471250057-6fWv1k7M.woff2 +0 -0
  19. package/public/dashboard/assets/d8c30647abfeffe6-eXO_dkmS.woff2 +0 -0
  20. package/public/dashboard/assets/eb83d8d40af4411f-Buze_B52.woff2 +0 -0
  21. package/public/dashboard/assets/effc6711249e7349-qRpaaN48.woff2 +0 -0
  22. package/public/dashboard/assets/gateway-BDYet0pI.css +1 -0
  23. package/public/dashboard/assets/gateway-BYt6-s1O.js +1 -0
  24. package/public/dashboard/assets/index-B9wFpD_z.css +2 -0
  25. package/public/dashboard/assets/index-DWcQmu0_.js +124 -0
  26. package/public/dashboard/assets/index-Da-j89O-.js +458 -0
  27. package/public/dashboard/font-licenses/jetbrainsmono-OFL.txt +93 -0
  28. package/public/dashboard/font-licenses/plusjakartasans-OFL.txt +93 -0
  29. package/public/dashboard/font-licenses/tajawal-OFL.txt +93 -0
  30. package/public/dashboard/gateway.html +17 -0
  31. package/public/dashboard/index.html +3 -5
  32. package/public/ui-boot.js +33 -14
  33. package/scheduler.cjs +76 -23
  34. package/src/auth/auth-storage.cjs +54 -7
  35. package/src/auth/use-database-auth-state.js +70 -39
  36. package/src/automation/engine.js +412 -0
  37. package/src/automation/limits.cjs +6 -0
  38. package/src/automation/manage.js +290 -0
  39. package/src/automation/reactions.js +471 -0
  40. package/src/automation/rules.cjs +114 -0
  41. package/src/automation/status.cjs +76 -0
  42. package/src/backup/account.cjs +29 -0
  43. package/src/backup/activation.cjs +247 -0
  44. package/src/backup/content.cjs +36 -0
  45. package/src/backup/create.cjs +280 -0
  46. package/src/backup/extensions.cjs +101 -0
  47. package/src/backup/format.cjs +565 -0
  48. package/src/backup/jobs.cjs +111 -0
  49. package/src/backup/journal.cjs +41 -0
  50. package/src/backup/plan.cjs +223 -0
  51. package/src/backup/recovery.cjs +110 -0
  52. package/src/backup/restore.cjs +460 -0
  53. package/src/backup/uploads.cjs +146 -0
  54. package/src/bootstrap/core.js +50 -12
  55. package/src/bootstrap/panel.js +53 -2
  56. package/src/bootstrap/session-startup-policy.js +8 -1
  57. package/src/cli.js +163 -22
  58. package/src/commands/autodelete.cjs +41 -57
  59. package/src/commands/autoschedule.cjs +7 -33
  60. package/src/commands/blacklist.cjs +17 -35
  61. package/src/commands/block.cjs +4 -18
  62. package/src/commands/calc.cjs +22 -74
  63. package/src/commands/debt.cjs +28 -59
  64. package/src/commands/deleteschedule.cjs +7 -23
  65. package/src/commands/digit.cjs +5 -39
  66. package/src/commands/gemini.cjs +135 -218
  67. package/src/commands/group/add.cjs +28 -76
  68. package/src/commands/group/all.cjs +4 -15
  69. package/src/commands/group/antilink.cjs +28 -41
  70. package/src/commands/group/antispam.cjs +25 -35
  71. package/src/commands/group/approveall.cjs +7 -21
  72. package/src/commands/group/clearwarns.cjs +4 -18
  73. package/src/commands/group/deletenote.cjs +4 -18
  74. package/src/commands/group/demote.cjs +6 -23
  75. package/src/commands/group/flagged.cjs +10 -19
  76. package/src/commands/group/kick.cjs +26 -36
  77. package/src/commands/group/media.cjs +21 -36
  78. package/src/commands/group/members.cjs +16 -28
  79. package/src/commands/group/note.cjs +3 -14
  80. package/src/commands/group/policy.cjs +16 -37
  81. package/src/commands/group/promote.cjs +5 -22
  82. package/src/commands/group/removeall.cjs +6 -38
  83. package/src/commands/group/rules.cjs +4 -19
  84. package/src/commands/group/save.cjs +4 -18
  85. package/src/commands/group/setname.cjs +5 -19
  86. package/src/commands/group/setpp.cjs +8 -26
  87. package/src/commands/group/setrules.cjs +4 -15
  88. package/src/commands/group/setwarn.cjs +6 -23
  89. package/src/commands/group/tagadmins.cjs +5 -16
  90. package/src/commands/group/warn.cjs +5 -16
  91. package/src/commands/group/warns.cjs +12 -33
  92. package/src/commands/group/welcome.cjs +17 -34
  93. package/src/commands/group.cjs +91 -68
  94. package/src/commands/help.cjs +48 -89
  95. package/src/commands/lang.cjs +38 -97
  96. package/src/commands/listschedules.cjs +19 -30
  97. package/src/commands/loop.cjs +9 -55
  98. package/src/commands/md.cjs +2 -13
  99. package/src/commands/memory.cjs +53 -87
  100. package/src/commands/mod.cjs +40 -79
  101. package/src/commands/notes.cjs +4 -15
  102. package/src/commands/pack.cjs +26 -49
  103. package/src/commands/packs.cjs +8 -18
  104. package/src/commands/perm.cjs +48 -51
  105. package/src/commands/ping.cjs +2 -10
  106. package/src/commands/poll.cjs +5 -38
  107. package/src/commands/prayer.cjs +55 -36
  108. package/src/commands/qr.cjs +4 -18
  109. package/src/commands/rand.cjs +9 -58
  110. package/src/commands/restart.cjs +15 -33
  111. package/src/commands/schedule.cjs +5 -25
  112. package/src/commands/score.cjs +6 -27
  113. package/src/commands/send.cjs +4 -18
  114. package/src/commands/setprefix.cjs +11 -23
  115. package/src/commands/shortlink.cjs +13 -39
  116. package/src/commands/status.cjs +188 -76
  117. package/src/commands/sticker.cjs +5 -16
  118. package/src/commands/stickers.cjs +16 -20
  119. package/src/commands/stopbot.cjs +9 -25
  120. package/src/commands/stt.cjs +75 -107
  121. package/src/commands/todo.cjs +11 -31
  122. package/src/commands/toimage.cjs +11 -27
  123. package/src/commands/translate.cjs +53 -36
  124. package/src/commands/tts.cjs +46 -40
  125. package/src/commands/unblock.cjs +3 -17
  126. package/src/commands/update.cjs +23 -0
  127. package/src/commands/weather.cjs +40 -47
  128. package/src/config/ai-identity.cjs +14 -1
  129. package/src/config/baileys.config.js +16 -3
  130. package/src/config/data-dir.cjs +37 -0
  131. package/src/config/defaults.cjs +1 -0
  132. package/src/config/exit-codes.cjs +11 -0
  133. package/src/config/lock.cjs +55 -81
  134. package/src/config/official-links.cjs +61 -0
  135. package/src/config/paths.cjs +4 -33
  136. package/src/config/release.cjs +87 -0
  137. package/src/config/settings.cjs +199 -10
  138. package/src/core/connection.js +77 -9
  139. package/src/core/events.js +119 -33
  140. package/src/core/session.js +536 -84
  141. package/src/core/socket.js +81 -10
  142. package/src/db/copy.cjs +136 -0
  143. package/src/db/db.cjs +241 -36
  144. package/src/db/startup-guard.js +5 -0
  145. package/src/db/store.cjs +561 -54
  146. package/src/diagnostics/baileysLog.cjs +87 -0
  147. package/src/diagnostics/debugLog.cjs +16 -4
  148. package/src/diagnostics/device.cjs +4 -2
  149. package/src/diagnostics/nodeRuntime.cjs +131 -0
  150. package/src/diagnostics/signalSessionInspect.cjs +38 -0
  151. package/src/domain/command.js +24 -22
  152. package/src/extensions/autoReply.cjs +521 -0
  153. package/src/extensions/context.cjs +73 -0
  154. package/src/extensions/contract.cjs +69 -0
  155. package/src/extensions/entitlement/client.cjs +381 -0
  156. package/src/extensions/entitlement/index.cjs +629 -0
  157. package/src/extensions/entitlement/installation.cjs +117 -0
  158. package/src/extensions/entitlement/keys.cjs +72 -0
  159. package/src/extensions/entitlement/state.cjs +201 -0
  160. package/src/extensions/entitlement/target.cjs +7 -0
  161. package/src/extensions/entitlement/token.cjs +225 -0
  162. package/src/extensions/host.cjs +519 -0
  163. package/src/extensions/templateKeys.cjs +81 -0
  164. package/src/handlers/command.handler.js +191 -64
  165. package/src/handlers/group.handler.js +78 -18
  166. package/src/handlers/message.handler.js +56 -25
  167. package/src/i18n/catalog.generated.cjs +3537 -0
  168. package/src/index.js +51 -12
  169. package/src/legal/bundled/ar.json +102 -0
  170. package/src/legal/bundled/en.json +102 -0
  171. package/src/legal/bundled/es-419.json +102 -0
  172. package/src/legal/bundled/pt-BR.json +102 -0
  173. package/src/legal/cli.cjs +200 -0
  174. package/src/legal/consent.cjs +187 -0
  175. package/src/legal/document.cjs +156 -0
  176. package/src/legal/keys.cjs +100 -0
  177. package/src/legal/release.cjs +226 -0
  178. package/src/legal/remote.cjs +419 -0
  179. package/src/legal/terms.cjs +142 -0
  180. package/src/messaging/escape.cjs +31 -0
  181. package/src/messaging/health.cjs +65 -0
  182. package/src/messaging/identity.cjs +42 -0
  183. package/src/messaging/message.cjs +136 -0
  184. package/src/messaging/parser.cjs +88 -0
  185. package/src/messaging/router.cjs +217 -0
  186. package/src/middleware/permissions.middleware.js +34 -2
  187. package/src/panel/account-profile.cjs +489 -0
  188. package/src/panel/fallback-page.cjs +177 -0
  189. package/src/panel/password-reset.cjs +13 -14
  190. package/src/panel/recovery-email.cjs +3 -1
  191. package/src/routes/backup.api.esm.js +175 -0
  192. package/src/routes/dashboard.api.esm.js +183 -7
  193. package/src/routes/plus.api.esm.js +172 -0
  194. package/src/routes/reactions.api.esm.js +60 -0
  195. package/src/services/aiAgent.cjs +56 -43
  196. package/src/services/aiDocs.cjs +187 -0
  197. package/src/services/aiImage.cjs +183 -0
  198. package/src/services/aiMedia.cjs +146 -0
  199. package/src/services/aiProviders.cjs +76 -80
  200. package/src/services/aiRouter.cjs +2 -2
  201. package/src/services/aiToolAuth.cjs +76 -4
  202. package/src/services/aiTools.cjs +431 -105
  203. package/src/services/autoDelete.cjs +9 -1
  204. package/src/services/levix-docs.generated.json +2623 -0
  205. package/src/services/memoryPolicy.cjs +56 -0
  206. package/src/services/updateCheck.cjs +362 -0
  207. package/src/stickers/errors.cjs +53 -97
  208. package/src/stickers/library.cjs +13 -6
  209. package/src/stickers/owner.cjs +1 -1
  210. package/src/utils/commandContext.cjs +13 -0
  211. package/src/utils/commandDocs.cjs +42 -20
  212. package/src/utils/geminiHttpOptions.cjs +56 -0
  213. package/src/utils/geminiMedia.cjs +28 -3
  214. package/src/utils/groupMetadataCache.cjs +386 -21
  215. package/src/utils/httpsFetch.cjs +113 -0
  216. package/src/utils/i18n.cjs +117 -7
  217. package/src/utils/linkPreview.cjs +90 -0
  218. package/src/utils/logger.cjs +6 -0
  219. package/src/utils/markdownParser.cjs +3 -3
  220. package/src/utils/memory.cjs +375 -28
  221. package/src/utils/messageContent.cjs +7 -1
  222. package/src/utils/moderationAction.cjs +116 -73
  223. package/src/utils/moderationSummary.cjs +32 -56
  224. package/src/utils/permissionLevel.cjs +7 -28
  225. package/src/utils/permissions.cjs +23 -14
  226. package/src/utils/permissions.esm.js +99 -166
  227. package/src/utils/recentMessageCache.esm.js +241 -37
  228. package/src/utils/recurrence.cjs +78 -66
  229. package/src/utils/sendBotMessage.cjs +14 -29
  230. package/src/utils/sendBotMessage.esm.js +28 -13
  231. package/src/utils/statusMessage.cjs +94 -33
  232. package/src/utils/stickerBot.cjs +18 -16
  233. package/src/utils/storage.cjs +2 -0
  234. package/src/utils/storage.esm.js +2 -0
  235. package/src/utils/thumbnail.cjs +5 -21
  236. package/public/dashboard/assets/index-B1sOW2VX.js +0 -561
  237. package/public/dashboard/assets/index-CK8osB4o.css +0 -2
  238. package/public/dashboard.css +0 -3127
  239. package/public/dashboard.js +0 -1981
  240. package/public/gateway-i18n.js +0 -321
  241. package/public/gateway.js +0 -70
  242. package/views/dashboard.ejs +0 -775
  243. package/views/login.ejs +0 -408
  244. package/views/qr.ejs +0 -155
  245. package/views/setup.ejs +0 -118
@@ -0,0 +1,93 @@
1
+ Copyright 2020 The JetBrains Mono Project Authors (https://github.com/JetBrains/JetBrainsMono)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+
5
+ This license is copied below, and is also available with a FAQ at: https://scripts.sil.org/OFL
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -0,0 +1,93 @@
1
+ Copyright 2020 The Plus Jakarta Sans Project Authors (https://github.com/tokotype/PlusJakartaSans)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ http://scripts.sil.org/OFL
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -0,0 +1,93 @@
1
+ Copyright 2018 Boutros International. (http://www.boutrosfonts.com)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ http://scripts.sil.org/OFL
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <script src="/ui-boot.js"></script>
5
+ <meta charset="UTF-8" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>Levix</title>
8
+ <link rel="icon" type="image/png" sizes="32x32" href="/brand/icon-32.png" />
9
+ <script type="module" crossorigin src="/dashboard/assets/gateway-BYt6-s1O.js"></script>
10
+ <link rel="modulepreload" crossorigin href="/dashboard/assets/index-DWcQmu0_.js">
11
+ <link rel="stylesheet" crossorigin href="/dashboard/assets/index-B9wFpD_z.css">
12
+ <link rel="stylesheet" crossorigin href="/dashboard/assets/gateway-BDYet0pI.css">
13
+ </head>
14
+ <body>
15
+ <div id="root"></div>
16
+ </body>
17
+ </html>
@@ -8,11 +8,9 @@
8
8
  <link rel="icon" type="image/png" sizes="32x32" href="/brand/icon-32.png" />
9
9
  <link rel="icon" type="image/png" sizes="16x16" href="/brand/icon-16.png" />
10
10
  <link rel="apple-touch-icon" href="/brand/apple-touch-icon.png" />
11
- <link rel="preconnect" href="https://fonts.googleapis.com" />
12
- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
13
- <link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=Tajawal:wght@400;500;700;800&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet" />
14
- <script type="module" crossorigin src="/dashboard/assets/index-B1sOW2VX.js"></script>
15
- <link rel="stylesheet" crossorigin href="/dashboard/assets/index-CK8osB4o.css">
11
+ <script type="module" crossorigin src="/dashboard/assets/index-Da-j89O-.js"></script>
12
+ <link rel="modulepreload" crossorigin href="/dashboard/assets/index-DWcQmu0_.js">
13
+ <link rel="stylesheet" crossorigin href="/dashboard/assets/index-B9wFpD_z.css">
16
14
  </head>
17
15
  <body>
18
16
  <div id="root"></div>
package/public/ui-boot.js CHANGED
@@ -1,8 +1,8 @@
1
1
  // Decides lang, dir and data-theme before first paint, for the panel and
2
2
  // every gateway page. Order: the Android host's preference, then what this
3
- // browser saved, then the OS. Every gateway page is bilingual now, so none
4
- // passes data-page-lang; the attribute remains an escape hatch for a future
5
- // page whose text exists in one language only.
3
+ // browser saved, then the OS. Every gateway page follows the shared language,
4
+ // so none passes data-page-lang; the attribute remains an escape hatch for a
5
+ // future page whose text exists in one language only.
6
6
  (function () {
7
7
  var root = document.documentElement;
8
8
  var host = window.LevixHost;
@@ -16,20 +16,36 @@
16
16
  if (host && typeof host.getUiPrefs === "function") {
17
17
  try { prefs = JSON.parse(host.getUiPrefs()); } catch (_) {}
18
18
  }
19
- var language = prefs && (prefs.language === "ar" || prefs.language === "en")
20
- ? prefs.language : (savedLang === "ar" || savedLang === "en" ? savedLang
21
- : /^ar\b/i.test((navigator.languages && navigator.languages[0]) || navigator.language || "") ? "ar" : "en");
19
+ // Same subtag rule as frontend/src/i18n/locale.ts. This file loads first, so
20
+ // it cannot import that module. "_" or "-", any case: ar, pt -> pt-BR,
21
+ // es -> es-419, en. Anything else is unknown.
22
+ function normalizeLocale(value) {
23
+ if (typeof value !== "string") return null;
24
+ var subtag = value.trim().split(/[_-]/)[0].toLowerCase();
25
+ if (subtag === "ar") return "ar";
26
+ if (subtag === "pt") return "pt-BR";
27
+ if (subtag === "es") return "es-419";
28
+ if (subtag === "en") return "en";
29
+ return null;
30
+ }
31
+ var language = normalizeLocale(prefs && prefs.language)
32
+ || normalizeLocale(savedLang)
33
+ || normalizeLocale((navigator.languages && navigator.languages[0]) || navigator.language)
34
+ || "en";
22
35
  var dark = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)");
23
36
  var theme = prefs && (prefs.theme === "dark" || prefs.theme === "light")
24
37
  ? prefs.theme : (savedTheme === "dark" || savedTheme === "light" ? savedTheme
25
38
  : dark && dark.matches ? "dark" : "light");
26
39
  function apply(next) {
27
- var lang = pageLang || next.language;
28
- if (lang === "ar" || lang === "en") {
40
+ var lang = normalizeLocale(pageLang);
41
+ if (!lang && next) lang = normalizeLocale(next.language);
42
+ if (lang && (pageLang || (next && typeof next.language === "string"))) {
29
43
  root.lang = lang;
30
44
  root.dir = lang === "ar" ? "rtl" : "ltr";
31
45
  }
32
- if (next.theme === "dark" || next.theme === "light") root.setAttribute("data-theme", next.theme);
46
+ if (next && (next.theme === "dark" || next.theme === "light")) {
47
+ root.setAttribute("data-theme", next.theme);
48
+ }
33
49
  }
34
50
  apply({ language: language, theme: theme });
35
51
  if (prefs) {
@@ -40,10 +56,11 @@
40
56
  }
41
57
  window.addEventListener("levix-ui-prefs", function (event) {
42
58
  var next = event.detail || {};
43
- apply(next);
59
+ var lang = normalizeLocale(next.language);
60
+ apply(lang ? { language: lang, theme: next.theme } : next);
44
61
  if (host) {
45
62
  try {
46
- if (next.language === "ar" || next.language === "en") localStorage.setItem("levix_lang", next.language);
63
+ if (lang) localStorage.setItem("levix_lang", lang);
47
64
  if (next.theme === "dark" || next.theme === "light") localStorage.setItem("levix_theme", next.theme);
48
65
  } catch (_) {}
49
66
  }
@@ -53,11 +70,13 @@
53
70
  if (event.key === "levix_theme" && (event.newValue === "dark" || event.newValue === "light")) {
54
71
  next.theme = event.newValue;
55
72
  }
56
- if (event.key === "levix_lang" && (event.newValue === "ar" || event.newValue === "en")) {
57
- next.language = event.newValue;
58
- }
73
+ var saved = event.key === "levix_lang" ? normalizeLocale(event.newValue) : null;
74
+ if (saved) next.language = saved;
59
75
  if (next.theme || next.language) {
60
76
  apply(next);
77
+ // Same signal as the system theme listener. React listens for this
78
+ // event. A storage event does not reach the tab that wrote the value.
79
+ window.dispatchEvent(new CustomEvent("levix-ui-prefs", { detail: next }));
61
80
  }
62
81
  });
63
82
  if (!host && savedTheme !== "dark" && savedTheme !== "light" && dark) {
package/scheduler.cjs CHANGED
@@ -7,7 +7,8 @@ const logger = require("./src/utils/logger.cjs");
7
7
  const settings = require("./src/config/settings.cjs");
8
8
  const { ensureDataDir } = require("./src/config/paths.cjs");
9
9
  const storage = require("./src/utils/storage.cjs");
10
- const { detectLang, withLang, tr } = require("./src/utils/i18n.cjs");
10
+ const { detectLang, withLang, t } = require("./src/utils/i18n.cjs");
11
+ const normalizeJid = require("./src/utils/normalizeJid.cjs");
11
12
 
12
13
  // الجدولة كانت في config/schedule.json: الداشبورد مش شايفاه، وكراش وسط
13
14
  // الكتابة كان ممكن يقصّه. دلوقتي جدول في نفس قاعدة البيانات زي أي حاجة تانية.
@@ -44,14 +45,46 @@ function getScheduledJobs() {
44
45
  }
45
46
  }
46
47
 
48
+ /**
49
+ * The jobs that belong to one chat. A group matches its normalized JID exactly;
50
+ * a private chat matches when its normalized target JID equals the normalized
51
+ * chat JID or the normalized alt JID (only when altJid is a non-empty string).
52
+ * Never compared by digits, so another chat's reminders cannot be read or
53
+ * removed through this list.
54
+ */
55
+ function getScheduledJobsForChat(chatJid, altJid) {
56
+ if (!chatJid || typeof chatJid !== "string") return [];
57
+ const inGroup = chatJid.endsWith("@g.us");
58
+ const wanted = normalizeJid(chatJid);
59
+ const hasAlt = typeof altJid === "string" && altJid.length > 0;
60
+ const wantedAlt = hasAlt ? normalizeJid(altJid) : null;
61
+ return getScheduledJobs().filter((job) => {
62
+ const target = job?.targetJid;
63
+ if (!target || typeof target !== "string") return false;
64
+ const norm = normalizeJid(target);
65
+ if (inGroup) return norm === wanted;
66
+ return norm === wanted || (hasAlt && norm === wantedAlt);
67
+ });
68
+ }
69
+
47
70
  function saveScheduledJob(job) {
48
71
  return storage.saveSchedule(job);
49
72
  }
50
73
 
51
74
  const runningTasks = new Map();
52
- const deliveriesInFlight = new Set();
53
- // The socket the jobs were last armed with. Callers that don't hold a socket
54
- // themselves (the AI agent's reminder tool) arm new jobs through it.
75
+ const deliveriesInFlight = new Map();
76
+ let scheduleGeneration = 0;
77
+ function bumpScheduleGeneration() { scheduleGeneration += 1; }
78
+ function staleDelivery(jobId, generation) {
79
+ if (generation === scheduleGeneration) return false;
80
+ logger.debug({ jobId }, "[Scheduler] Stale delivery stopped after account activation");
81
+ return true;
82
+ }
83
+ // The scheduler's own live raw socket: set by initializeScheduledJobs(), cleared
84
+ // by stopAllScheduledJobs(). Every delivery goes out through it — never through
85
+ // a socket a caller handed to scheduleNewJob(), which may be a per-command reply
86
+ // proxy. Callers that don't hold a socket themselves (the AI agent's reminder
87
+ // tool) arm new jobs through its presence.
55
88
  let currentSock = null;
56
89
  let cleanupScheduled = false;
57
90
 
@@ -128,12 +161,11 @@ function scheduleAt(whenMs, run) {
128
161
  }
129
162
 
130
163
  /**
131
- * Stop every running task.
164
+ * Stop every running task and drop the live socket.
132
165
  *
133
- * Each task closes over the socket it was armed with (see scheduleNewJob), so
134
- * once that socket is gone the task can only fail. The connection handler calls
135
- * initializeScheduledJobs() again on the next open, which re-arms every job
136
- * against the socket that is actually alive.
166
+ * With no socket a delivery can only fail, so nothing stays armed. The
167
+ * connection handler calls initializeScheduledJobs() again on the next open,
168
+ * which sets the new socket and re-arms every job.
137
169
  */
138
170
  function stopAllScheduledJobs() {
139
171
  currentSock = null;
@@ -173,10 +205,10 @@ function recordDelivery(jobId, status, runAt, error = null) {
173
205
  * What sendMessage receives for one job, in order: the text, or the stored
174
206
  * media with the text as its caption. Audio and stickers take no caption, so
175
207
  * their text follows as a message of its own instead of being dropped. Runs
176
- * inside withLang() so tr() picks the right header.
208
+ * inside withLang() so t() picks the right header.
177
209
  */
178
210
  function buildScheduledPayloads(job) {
179
- const header = tr("*Scheduled message 🗓️*", "*رسالة مجدولة 🗓️*");
211
+ const header = t("bot.schedules.scheduler.header");
180
212
  const text = job.message ? `${header}\n\n${job.message}` : header;
181
213
  if (!job.media) return [{ text }];
182
214
 
@@ -205,37 +237,49 @@ function buildScheduledPayloads(job) {
205
237
  }
206
238
  }
207
239
 
208
- async function deliverScheduledJob(sock, job) {
209
- if (deliveriesInFlight.has(job.id)) {
240
+ async function deliverScheduledJob(job) {
241
+ const generation = scheduleGeneration;
242
+ // Captured once: every payload of this attempt goes through the same socket,
243
+ // even if a reconnect swaps currentSock while a send is awaited.
244
+ const sock = currentSock;
245
+ if (deliveriesInFlight.get(job.id) === generation) {
210
246
  logger.warn(`[Scheduler] Job ${job.id} is already being delivered — skipping overlap`);
211
247
  return { ok: false, reason: "in_flight", skipped: true };
212
248
  }
213
249
 
214
- deliveriesInFlight.add(job.id);
250
+ deliveriesInFlight.set(job.id, generation);
215
251
  const runAt = Date.now();
216
252
 
217
253
  try {
254
+ if (staleDelivery(job.id, generation)) return { ok: false, reason: "stale", skipped: true };
255
+ if (!sock) throw new Error("No live WhatsApp connection");
218
256
  // No message is being answered here, so the header follows the scheduled
219
257
  // text itself (in "auto"), or the bot's language.
220
258
  const payloads = withLang(detectLang(job.message || " "), () => buildScheduledPayloads(job));
221
259
  for (const payload of payloads) {
260
+ if (staleDelivery(job.id, generation)) return { ok: false, reason: "stale", skipped: true };
222
261
  await sock.sendMessage(job.targetJid, payload);
223
262
  }
263
+ if (staleDelivery(job.id, generation)) return { ok: false, reason: "stale", skipped: true };
224
264
  recordDelivery(job.id, "sent", runAt);
225
- logger.info(`[Scheduler] Executed job ${job.id} -> ${job.targetJid}`);
265
+ logger.info(`[Scheduler] Executed job ${job.id}`);
226
266
  return { ok: true, reason: "sent" };
227
267
  } catch (error) {
268
+ if (staleDelivery(job.id, generation)) return { ok: false, reason: "stale", skipped: true };
228
269
  const message = deliveryErrorMessage(error);
229
270
  recordDelivery(job.id, "failed", runAt, message);
230
271
  logger.error({ err: error, jobId: job.id }, "[Scheduler] failed to send scheduled message");
231
272
  return { ok: false, reason: "delivery_failed", error: message };
232
273
  } finally {
233
- deliveriesInFlight.delete(job.id);
274
+ if (deliveriesInFlight.get(job.id) === generation) deliveriesInFlight.delete(job.id);
234
275
  }
235
276
  }
236
277
 
237
- async function executeScheduledJob(sock, job) {
238
- const result = await deliverScheduledJob(sock, job);
278
+ async function executeScheduledJob(job) {
279
+ const generation = scheduleGeneration;
280
+ const result = await deliverScheduledJob(job);
281
+ if (result.reason === "stale") return result;
282
+ if (staleDelivery(job.id, generation)) return { ok: false, reason: "stale", skipped: true };
239
283
 
240
284
  if (job.type !== "recurring" && !result.skipped) {
241
285
  try {
@@ -254,7 +298,13 @@ async function executeScheduledJob(sock, job) {
254
298
  return result;
255
299
  }
256
300
 
257
- function scheduleNewJob(sock, job) {
301
+ /**
302
+ * Arm one job. `_sock` is only here so callers keep their signature: it is not
303
+ * used to deliver. Delivery always goes through the scheduler's own live raw
304
+ * socket (`currentSock`, see deliverScheduledJob), so a per-command reply proxy
305
+ * passed here is never kept.
306
+ */
307
+ function scheduleNewJob(_sock, job) {
258
308
  stopTask(job.id);
259
309
 
260
310
  if (job.type === "recurring") {
@@ -268,7 +318,7 @@ function scheduleNewJob(sock, job) {
268
318
 
269
319
  runningTasks.set(
270
320
  job.id,
271
- cron.schedule(job.cronString, () => executeScheduledJob(sock, job), {
321
+ cron.schedule(job.cronString, () => executeScheduledJob(job), {
272
322
  timezone: settings.get("bot_timezone"),
273
323
  }),
274
324
  );
@@ -292,7 +342,7 @@ function scheduleNewJob(sock, job) {
292
342
  job.id,
293
343
  scheduleAt(when, async () => {
294
344
  try {
295
- await executeScheduledJob(sock, job);
345
+ await executeScheduledJob(job);
296
346
  } finally {
297
347
  runningTasks.delete(job.id);
298
348
  }
@@ -304,7 +354,8 @@ function scheduleNewJob(sock, job) {
304
354
  return true;
305
355
  }
306
356
 
307
- async function retryScheduledJob(sock, jobId) {
357
+ /** Retry a failed job now. `_sock` is unused: delivery goes through `currentSock`. */
358
+ async function retryScheduledJob(_sock, jobId) {
308
359
  const job = storage.getSchedule(jobId);
309
360
  if (!job) return { ok: false, reason: "not_found" };
310
361
 
@@ -313,7 +364,7 @@ async function retryScheduledJob(sock, jobId) {
313
364
  (job.type === "recurring" && job.status === "active" && job.lastDeliveryStatus === "failed");
314
365
  if (!retryable) return { ok: false, reason: "not_failed", job };
315
366
 
316
- const result = await executeScheduledJob(sock, job);
367
+ const result = await executeScheduledJob(job);
317
368
  return { ...result, job: storage.getSchedule(jobId) };
318
369
  }
319
370
 
@@ -346,10 +397,12 @@ module.exports = {
346
397
  SCHEDULE_MEDIA_MAX_BYTES,
347
398
  initializeScheduledJobs,
348
399
  stopAllScheduledJobs,
400
+ bumpScheduleGeneration,
349
401
  scheduleNewJob,
350
402
  scheduleJobNow,
351
403
  retryScheduledJob,
352
404
  getScheduledJobs,
405
+ getScheduledJobsForChat,
353
406
  saveScheduledJob,
354
407
  deleteScheduledJob,
355
408
  scheduleMediaPath,