@kaikybrofc/omnizap-system 2.1.8
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.
- package/.env.example +534 -0
- package/LICENSE +21 -0
- package/README.md +431 -0
- package/RELEASE-v2.1.2.md +83 -0
- package/app/config/adminIdentity.js +87 -0
- package/app/config/baileysConfig.js +693 -0
- package/app/config/groupUtils.js +388 -0
- package/app/connection/socketController.js +992 -0
- package/app/controllers/messageController.js +354 -0
- package/app/modules/adminModule/groupCommandHandlers.js +1294 -0
- package/app/modules/adminModule/groupEventHandlers.js +355 -0
- package/app/modules/aiModule/catCommand.js +1006 -0
- package/app/modules/broadcastModule/noticeCommand.js +416 -0
- package/app/modules/gameModule/diceCommand.js +67 -0
- package/app/modules/menuModule/common.js +311 -0
- package/app/modules/menuModule/menus.js +59 -0
- package/app/modules/playModule/playCommand.js +1615 -0
- package/app/modules/quoteModule/quoteCommand.js +851 -0
- package/app/modules/rpgPokemonModule/rpgBattleCanvasRenderer.js +786 -0
- package/app/modules/rpgPokemonModule/rpgBattleService.js +2082 -0
- package/app/modules/rpgPokemonModule/rpgBattleService.test.js +760 -0
- package/app/modules/rpgPokemonModule/rpgEvolutionUtils.js +22 -0
- package/app/modules/rpgPokemonModule/rpgPokemonCommand.js +172 -0
- package/app/modules/rpgPokemonModule/rpgPokemonDomain.js +192 -0
- package/app/modules/rpgPokemonModule/rpgPokemonDomain.test.js +93 -0
- package/app/modules/rpgPokemonModule/rpgPokemonEvolution.test.js +46 -0
- package/app/modules/rpgPokemonModule/rpgPokemonMessages.js +746 -0
- package/app/modules/rpgPokemonModule/rpgPokemonRepository.js +1859 -0
- package/app/modules/rpgPokemonModule/rpgPokemonService.js +6738 -0
- package/app/modules/rpgPokemonModule/rpgProfileCanvasRenderer.js +354 -0
- package/app/modules/statsModule/globalRankingCommand.js +65 -0
- package/app/modules/statsModule/noMessageCommand.js +288 -0
- package/app/modules/statsModule/rankingCommand.js +60 -0
- package/app/modules/statsModule/rankingCommon.js +889 -0
- package/app/modules/stickerModule/addStickerMetadata.js +239 -0
- package/app/modules/stickerModule/convertToWebp.js +390 -0
- package/app/modules/stickerModule/stickerCommand.js +454 -0
- package/app/modules/stickerModule/stickerConvertCommand.js +156 -0
- package/app/modules/stickerModule/stickerTextCommand.js +657 -0
- package/app/modules/stickerPackModule/autoPackCollectorRuntime.js +20 -0
- package/app/modules/stickerPackModule/autoPackCollectorService.js +284 -0
- package/app/modules/stickerPackModule/semanticReclassificationEngine.js +466 -0
- package/app/modules/stickerPackModule/semanticReclassificationEngine.test.js +88 -0
- package/app/modules/stickerPackModule/semanticThemeClusterService.js +571 -0
- package/app/modules/stickerPackModule/stickerAssetClassificationRepository.js +449 -0
- package/app/modules/stickerPackModule/stickerAssetRepository.js +400 -0
- package/app/modules/stickerPackModule/stickerAssetReprocessQueueRepository.js +180 -0
- package/app/modules/stickerPackModule/stickerAutoPackByTagsRuntime.js +4078 -0
- package/app/modules/stickerPackModule/stickerClassificationBackgroundRuntime.js +598 -0
- package/app/modules/stickerPackModule/stickerClassificationService.js +588 -0
- package/app/modules/stickerPackModule/stickerMarketplaceDriftService.js +102 -0
- package/app/modules/stickerPackModule/stickerPackCatalogHttp.js +7506 -0
- package/app/modules/stickerPackModule/stickerPackCommandHandlers.js +1095 -0
- package/app/modules/stickerPackModule/stickerPackEngagementRepository.js +108 -0
- package/app/modules/stickerPackModule/stickerPackErrors.js +30 -0
- package/app/modules/stickerPackModule/stickerPackInteractionEventRepository.js +110 -0
- package/app/modules/stickerPackModule/stickerPackItemRepository.js +440 -0
- package/app/modules/stickerPackModule/stickerPackMarketplaceService.js +337 -0
- package/app/modules/stickerPackModule/stickerPackMessageService.js +296 -0
- package/app/modules/stickerPackModule/stickerPackRepository.js +442 -0
- package/app/modules/stickerPackModule/stickerPackService.js +788 -0
- package/app/modules/stickerPackModule/stickerPackServiceRuntime.js +51 -0
- package/app/modules/stickerPackModule/stickerPackUtils.js +97 -0
- package/app/modules/stickerPackModule/stickerStorageService.js +507 -0
- package/app/modules/stickerPackModule/stickerWorkerPipelineRuntime.js +233 -0
- package/app/modules/stickerPackModule/stickerWorkerTaskQueueRepository.js +205 -0
- package/app/modules/systemMetricsModule/pingCommand.js +421 -0
- package/app/modules/tiktokModule/tiktokCommand.js +798 -0
- package/app/modules/userModule/userCommand.js +1217 -0
- package/app/modules/waifuPicsModule/waifuPicsCommand.js +177 -0
- package/app/observability/metrics.js +734 -0
- package/app/services/captchaService.js +492 -0
- package/app/services/dbWriteQueue.js +572 -0
- package/app/services/groupMetadataService.js +279 -0
- package/app/services/lidMapService.js +663 -0
- package/app/services/messagePersistenceService.js +56 -0
- package/app/services/newsBroadcastService.js +351 -0
- package/app/services/pokeApiService.js +398 -0
- package/app/services/queueUtils.js +57 -0
- package/app/services/socketState.js +7 -0
- package/app/store/aiPromptStore.js +38 -0
- package/app/store/groupConfigStore.js +58 -0
- package/app/store/premiumUserStore.js +36 -0
- package/app/utils/antiLink/antiLinkModule.js +804 -0
- package/app/utils/http/getImageBufferModule.js +18 -0
- package/app/utils/json/jsonSanitizer.js +113 -0
- package/app/utils/json/jsonSanitizer.test.js +40 -0
- package/app/utils/logger/loggerModule.js +262 -0
- package/app/utils/systemMetrics/systemMetricsModule.js +91 -0
- package/database/index.js +2052 -0
- package/database/init.js +516 -0
- package/database/migrations/20260203_0001_sticker_packs.sql +54 -0
- package/database/migrations/20260210_0003_rpg_pokemon.sql +58 -0
- package/database/migrations/20260210_0004_rpg_shiny_biome.sql +9 -0
- package/database/migrations/20260210_0005_rpg_missions.sql +14 -0
- package/database/migrations/20260210_0006_rpg_world_pokedex_traits.sql +27 -0
- package/database/migrations/20260210_0007_rpg_raid_pvp.sql +56 -0
- package/database/migrations/20260210_0008_rpg_social_system.sql +195 -0
- package/database/migrations/20260211_0009_rpg_social_xp.sql +36 -0
- package/database/migrations/20260222_0010_remove_message_xp.sql +2 -0
- package/database/migrations/20260226_0011_sticker_asset_classification.sql +17 -0
- package/database/migrations/20260226_0012_sticker_pack_engagement.sql +16 -0
- package/database/migrations/20260226_0013_sticker_marketplace_intelligence.sql +19 -0
- package/database/migrations/20260226_0014_sticker_pack_publish_flow.sql +30 -0
- package/database/migrations/20260226_0014_sticker_worker_queues.sql +42 -0
- package/database/migrations/20260226_0015_sticker_auto_pack_curation_integrity.sql +18 -0
- package/database/migrations/20260226_0016_sticker_web_google_auth_persistence.sql +34 -0
- package/database/migrations/20260226_0017_sticker_web_admin_ban.sql +22 -0
- package/database/migrations/20260226_0018_sticker_web_admin_moderator.sql +18 -0
- package/database/migrations/20260227_0019_sticker_classification_v2_signals.sql +12 -0
- package/database/migrations/20260227_0020_semantic_theme_clusters.sql +35 -0
- package/docker-compose.yml +103 -0
- package/ecosystem.prod.config.cjs +35 -0
- package/eslint.config.js +61 -0
- package/index.js +437 -0
- package/ml/clip_classifier/Dockerfile +16 -0
- package/ml/clip_classifier/README.md +120 -0
- package/ml/clip_classifier/adaptive_scoring.py +40 -0
- package/ml/clip_classifier/classifier.py +654 -0
- package/ml/clip_classifier/embedding_store.py +481 -0
- package/ml/clip_classifier/env_loader.py +15 -0
- package/ml/clip_classifier/llm_label_expander.py +144 -0
- package/ml/clip_classifier/main.py +213 -0
- package/ml/clip_classifier/requirements.txt +10 -0
- package/ml/clip_classifier/similarity_engine.py +74 -0
- package/observability/alert-rules.yml +60 -0
- package/observability/grafana/dashboards/omnizap-mysql.json +136 -0
- package/observability/grafana/dashboards/omnizap-overview.json +170 -0
- package/observability/grafana/provisioning/dashboards/dashboards.yml +11 -0
- package/observability/grafana/provisioning/datasources/datasources.yml +15 -0
- package/observability/loki-config.yml +38 -0
- package/observability/mysql-exporter.cnf +5 -0
- package/observability/mysql-setup.sql +46 -0
- package/observability/prometheus.yml +32 -0
- package/observability/promtail-config.yml +84 -0
- package/package.json +109 -0
- package/public/api-docs/index.html +144 -0
- package/public/css/github-project-panel.css +297 -0
- package/public/css/stickers-admin.css +1272 -0
- package/public/css/styles.css +671 -0
- package/public/index.html +1311 -0
- package/public/js/apps/apiDocsApp.js +310 -0
- package/public/js/apps/createPackApp.js +2069 -0
- package/public/js/apps/homeApp.js +396 -0
- package/public/js/apps/stickersAdminApp.js +1744 -0
- package/public/js/apps/stickersApp.js +4830 -0
- package/public/js/catalog.js +1019 -0
- package/public/js/github-panel/components/CommitList.js +34 -0
- package/public/js/github-panel/components/ErrorState.js +16 -0
- package/public/js/github-panel/components/GithubProjectPanel.js +106 -0
- package/public/js/github-panel/components/ReleaseList.js +38 -0
- package/public/js/github-panel/components/SkeletonPanel.js +22 -0
- package/public/js/github-panel/components/StatCard.js +15 -0
- package/public/js/github-panel/index.js +15 -0
- package/public/js/github-panel/useGithubRepoData.js +154 -0
- package/public/js/github-panel/vendor/react.js +11 -0
- package/public/js/runtime/react-runtime.js +19 -0
- package/public/licenca/index.html +106 -0
- package/public/stickers/admin/index.html +23 -0
- package/public/stickers/create/index.html +47 -0
- package/public/stickers/index.html +48 -0
- package/public/termos-de-uso/index.html +125 -0
- package/scripts/cache-bust.mjs +107 -0
- package/scripts/deploy.sh +458 -0
- package/scripts/github-deploy-notify.mjs +174 -0
- package/scripts/release.sh +129 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
|
|
3
|
+
import logger from '../../utils/logger/loggerModule.js';
|
|
4
|
+
import groupConfigStore from '../../store/groupConfigStore.js';
|
|
5
|
+
import { sendAndStore } from '../../services/messagePersistenceService.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Prefixo padrão de comandos do bot.
|
|
9
|
+
* @type {string}
|
|
10
|
+
*/
|
|
11
|
+
const DEFAULT_COMMAND_PREFIX = process.env.COMMAND_PREFIX || '/';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* URL base da API Waifu.pics.
|
|
15
|
+
* @type {string}
|
|
16
|
+
*/
|
|
17
|
+
const WAIFU_PICS_BASE = (process.env.WAIFU_PICS_BASE || 'https://api.waifu.pics').replace(/\/$/, '');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Timeout das requisições para a Waifu.pics (em ms).
|
|
21
|
+
* @type {number}
|
|
22
|
+
*/
|
|
23
|
+
const WAIFU_PICS_TIMEOUT_MS = Number.parseInt(process.env.WAIFU_PICS_TIMEOUT_MS || '15000', 10);
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Define se conteúdo NSFW é permitido globalmente.
|
|
27
|
+
* @type {boolean}
|
|
28
|
+
*/
|
|
29
|
+
const WAIFU_PICS_ALLOW_NSFW = process.env.WAIFU_PICS_ALLOW_NSFW === 'true';
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Categorias SFW disponíveis na Waifu.pics.
|
|
33
|
+
* @type {string[]}
|
|
34
|
+
*/
|
|
35
|
+
const SFW_CATEGORIES = ['waifu', 'neko', 'shinobu', 'megumin', 'bully', 'cuddle', 'cry', 'hug', 'awoo', 'kiss', 'lick', 'pat', 'smug', 'bonk', 'yeet', 'blush', 'smile', 'wave', 'highfive', 'handhold', 'nom', 'bite', 'glomp', 'slap', 'kill', 'kick', 'happy', 'wink', 'poke', 'dance', 'cringe'];
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Categorias NSFW disponíveis na Waifu.pics.
|
|
39
|
+
* @type {string[]}
|
|
40
|
+
*/
|
|
41
|
+
const NSFW_CATEGORIES = ['waifu', 'neko', 'trap', 'blowjob'];
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Quebra categorias em linhas menores para leitura no WhatsApp.
|
|
45
|
+
*
|
|
46
|
+
* @param {string[]} categories
|
|
47
|
+
* @param {number} [chunkSize=6]
|
|
48
|
+
* @returns {string[][]}
|
|
49
|
+
*/
|
|
50
|
+
const chunkCategories = (categories, chunkSize = 6) => {
|
|
51
|
+
const chunks = [];
|
|
52
|
+
for (let index = 0; index < categories.length; index += chunkSize) {
|
|
53
|
+
chunks.push(categories.slice(index, index + chunkSize));
|
|
54
|
+
}
|
|
55
|
+
return chunks;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Formata categorias em múltiplas linhas com bullets.
|
|
60
|
+
*
|
|
61
|
+
* @param {string[]} categories
|
|
62
|
+
* @returns {string}
|
|
63
|
+
*/
|
|
64
|
+
const formatCategoriesList = (categories) =>
|
|
65
|
+
chunkCategories(categories)
|
|
66
|
+
.map((chunk) => `• ${chunk.join(' • ')}`)
|
|
67
|
+
.join('\n');
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Envia mensagem de uso/categorias disponíveis para o usuário.
|
|
71
|
+
*
|
|
72
|
+
* @param {object} sock - Instância do socket Baileys.
|
|
73
|
+
* @param {string} remoteJid - JID do chat.
|
|
74
|
+
* @param {object} messageInfo - Mensagem original para reply.
|
|
75
|
+
* @param {number|undefined} expirationMessage - Tempo de expiração da mensagem.
|
|
76
|
+
* @param {'sfw'|'nsfw'} type - Tipo de conteúdo.
|
|
77
|
+
* @param {string} [commandPrefix] - Prefixo do comando.
|
|
78
|
+
* @returns {Promise<void>}
|
|
79
|
+
*/
|
|
80
|
+
const sendUsage = async (sock, remoteJid, messageInfo, expirationMessage, type, commandPrefix = DEFAULT_COMMAND_PREFIX) => {
|
|
81
|
+
const list = type === 'nsfw' ? NSFW_CATEGORIES : SFW_CATEGORIES;
|
|
82
|
+
const modeLabel = type === 'nsfw' ? '🔞 NSFW (adulto)' : '📗 SFW (seguro)';
|
|
83
|
+
const command = `${commandPrefix}wp${type === 'nsfw' ? 'nsfw' : ''} <categoria>`;
|
|
84
|
+
|
|
85
|
+
await sendAndStore(
|
|
86
|
+
sock,
|
|
87
|
+
remoteJid,
|
|
88
|
+
{
|
|
89
|
+
text: ['🖼️ *Waifu pics*', '', `Modo: *${modeLabel}*`, `Use: *${command}*`, '', formatCategoriesList(list), '', `ℹ️ Dica: use *${commandPrefix}menu anime* para ver SFW e NSFW juntos.`].join('\n'),
|
|
90
|
+
},
|
|
91
|
+
{ quoted: messageInfo, ephemeralExpiration: expirationMessage },
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Busca uma imagem na API Waifu.pics.
|
|
97
|
+
*
|
|
98
|
+
* @param {'sfw'|'nsfw'} type - Tipo de conteúdo.
|
|
99
|
+
* @param {string} category - Categoria desejada.
|
|
100
|
+
* @returns {Promise<string|null>} URL da imagem ou null em caso de falha.
|
|
101
|
+
*/
|
|
102
|
+
const fetchWaifuPics = async (type, category) => {
|
|
103
|
+
const url = `${WAIFU_PICS_BASE}/${type}/${category}`;
|
|
104
|
+
const { data } = await axios.get(url, { timeout: WAIFU_PICS_TIMEOUT_MS });
|
|
105
|
+
return data?.url || null;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Handler principal do comando Waifu.pics.
|
|
110
|
+
*
|
|
111
|
+
* Responsável por:
|
|
112
|
+
* - Validar NSFW global e por grupo
|
|
113
|
+
* - Validar categoria
|
|
114
|
+
* - Buscar imagem na API
|
|
115
|
+
* - Enviar resposta ao usuário
|
|
116
|
+
*
|
|
117
|
+
* @param {object} params
|
|
118
|
+
* @param {object} params.sock - Instância do socket Baileys.
|
|
119
|
+
* @param {string} params.remoteJid - JID do chat.
|
|
120
|
+
* @param {object} params.messageInfo - Mensagem original.
|
|
121
|
+
* @param {number|undefined} params.expirationMessage - Tempo de expiração da mensagem.
|
|
122
|
+
* @param {string} params.text - Texto enviado pelo usuário.
|
|
123
|
+
* @param {'sfw'|'nsfw'} [params.type='sfw'] - Tipo de conteúdo.
|
|
124
|
+
* @param {string} [params.commandPrefix] - Prefixo do comando.
|
|
125
|
+
* @returns {Promise<void>}
|
|
126
|
+
*/
|
|
127
|
+
export async function handleWaifuPicsCommand({ sock, remoteJid, messageInfo, expirationMessage, text, type = 'sfw', commandPrefix = DEFAULT_COMMAND_PREFIX }) {
|
|
128
|
+
const category = (text || '').trim().toLowerCase() || 'waifu';
|
|
129
|
+
|
|
130
|
+
if (type === 'nsfw' && !WAIFU_PICS_ALLOW_NSFW) {
|
|
131
|
+
await sendAndStore(sock, remoteJid, { text: '⚠️ Conteúdo NSFW desativado. Habilite WAIFU_PICS_ALLOW_NSFW=true no .env.' }, { quoted: messageInfo, ephemeralExpiration: expirationMessage });
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (type === 'nsfw') {
|
|
136
|
+
const config = await groupConfigStore.getGroupConfig(remoteJid);
|
|
137
|
+
if (!config?.nsfwEnabled) {
|
|
138
|
+
await sendAndStore(sock, remoteJid, { text: `🔞 NSFW está desativado neste grupo. Um admin pode ativar com ${commandPrefix}nsfw on.` }, { quoted: messageInfo, ephemeralExpiration: expirationMessage });
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const allowed = type === 'nsfw' ? NSFW_CATEGORIES : SFW_CATEGORIES;
|
|
144
|
+
if (!allowed.includes(category)) {
|
|
145
|
+
await sendUsage(sock, remoteJid, messageInfo, expirationMessage, type, commandPrefix);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
try {
|
|
150
|
+
const imageUrl = await fetchWaifuPics(type, category);
|
|
151
|
+
if (!imageUrl) {
|
|
152
|
+
await sendAndStore(sock, remoteJid, { text: '❌ Não foi possível obter a imagem agora. Tente novamente.' }, { quoted: messageInfo, ephemeralExpiration: expirationMessage });
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
await sendAndStore(
|
|
157
|
+
sock,
|
|
158
|
+
remoteJid,
|
|
159
|
+
{
|
|
160
|
+
image: { url: imageUrl },
|
|
161
|
+
caption: `🖼️ ${type.toUpperCase()} • ${category}`,
|
|
162
|
+
},
|
|
163
|
+
{ quoted: messageInfo, ephemeralExpiration: expirationMessage },
|
|
164
|
+
);
|
|
165
|
+
} catch (error) {
|
|
166
|
+
logger.error('handleWaifuPicsCommand: erro na Waifu.pics.', error);
|
|
167
|
+
await sendAndStore(sock, remoteJid, { text: '❌ Erro ao consultar a Waifu.pics. Tente novamente.' }, { quoted: messageInfo, ephemeralExpiration: expirationMessage });
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Retorna o texto de ajuda/uso do comando Waifu.pics.
|
|
173
|
+
*
|
|
174
|
+
* @param {string} [commandPrefix] - Prefixo do comando.
|
|
175
|
+
* @returns {string}
|
|
176
|
+
*/
|
|
177
|
+
export const getWaifuPicsUsageText = (commandPrefix = DEFAULT_COMMAND_PREFIX) => ['🖼️ *Waifu pics — Categorias*', '', '📗 *SFW (seguro)*', `Comando: *${commandPrefix}wp* <categoria>`, formatCategoriesList(SFW_CATEGORIES), '', '🔞 *NSFW (adulto)*', `Comando: *${commandPrefix}wpnsfw* <categoria>`, formatCategoriesList(NSFW_CATEGORIES), '', `Ex.: *${commandPrefix}wp neko*`].join('\n');
|