Alexainc commited on
Commit
2ed731a
Β·
1 Parent(s): bf64f37

assdasdfd

Browse files
Files changed (1) hide show
  1. bot.js +8 -8
bot.js CHANGED
@@ -77,7 +77,7 @@ bot.on('photo', async (ctx) => {
77
 
78
  const text = ctx.message.caption || '';
79
  const upperText = text.toUpperCase();
80
-
81
  // Detect grid dimension based on phrases or explicit NxN format
82
  let gridSize = 8;
83
  if (upperText.includes('HARD MODE CHALLENGE')) {
@@ -117,18 +117,18 @@ bot.on('photo', async (ctx) => {
117
  for (const p in results) {
118
  foundAny = true;
119
  const targetStart = p[0].toUpperCase();
120
-
121
  if (Array.isArray(results[p])) {
122
  const wordMatches = results[p]
123
  .map(m => {
124
  const match = m.match.toUpperCase();
125
  // 1. Perfect Match?
126
  if (isWord(match) && match[0] === targetStart) return match;
127
-
128
  // 2. OCR Error on first letter? (Try forcing target start)
129
  const forced = targetStart + match.slice(1);
130
  if (isWord(forced)) return forced;
131
-
132
  // 3. Is the raw match a word but starts with wrong letter? (Ignore for this pattern)
133
  return null;
134
  })
@@ -137,7 +137,7 @@ bot.on('photo', async (ctx) => {
137
  .filter((value, index, self) => self.indexOf(value) === index);
138
 
139
  if (wordMatches.length > 0) {
140
- responseText += `βœ… ${p}: ${wordMatches.join(', ')}\n`;
141
  stats.wordsFound += wordMatches.length;
142
  }
143
  }
@@ -146,10 +146,10 @@ bot.on('photo', async (ctx) => {
146
  if (responseText === '🎯 WORD GRID RESULTS 🎯\n\n') {
147
  responseText += 'πŸ˜” No real word matches found for these patterns.\n\n';
148
  }
149
-
150
  responseText += '\nπŸ” <b>Extracted Grid (Debug):</b>\n';
151
  responseText += '<pre>' + grid.map(row => row.join(' ')).join('\n') + '</pre>';
152
-
153
  ctx.reply(responseText, { parse_mode: 'HTML' });
154
 
155
  // Cleanup
@@ -178,7 +178,7 @@ if (BOT_TOKEN) {
178
  }).catch(err => {
179
  console.error('Failed to get bot info:', err.message);
180
  });
181
-
182
  bot.launch()
183
  .then(() => console.log('Bot shutdown cleanly.'))
184
  .catch(err => console.error('Bot launch error:', err));
 
77
 
78
  const text = ctx.message.caption || '';
79
  const upperText = text.toUpperCase();
80
+
81
  // Detect grid dimension based on phrases or explicit NxN format
82
  let gridSize = 8;
83
  if (upperText.includes('HARD MODE CHALLENGE')) {
 
117
  for (const p in results) {
118
  foundAny = true;
119
  const targetStart = p[0].toUpperCase();
120
+
121
  if (Array.isArray(results[p])) {
122
  const wordMatches = results[p]
123
  .map(m => {
124
  const match = m.match.toUpperCase();
125
  // 1. Perfect Match?
126
  if (isWord(match) && match[0] === targetStart) return match;
127
+
128
  // 2. OCR Error on first letter? (Try forcing target start)
129
  const forced = targetStart + match.slice(1);
130
  if (isWord(forced)) return forced;
131
+
132
  // 3. Is the raw match a word but starts with wrong letter? (Ignore for this pattern)
133
  return null;
134
  })
 
137
  .filter((value, index, self) => self.indexOf(value) === index);
138
 
139
  if (wordMatches.length > 0) {
140
+ responseText += `βœ… ${p}: ${wordMatches.map(w => `<code>${w}</code>`).join(', ')}\n`;
141
  stats.wordsFound += wordMatches.length;
142
  }
143
  }
 
146
  if (responseText === '🎯 WORD GRID RESULTS 🎯\n\n') {
147
  responseText += 'πŸ˜” No real word matches found for these patterns.\n\n';
148
  }
149
+
150
  responseText += '\nπŸ” <b>Extracted Grid (Debug):</b>\n';
151
  responseText += '<pre>' + grid.map(row => row.join(' ')).join('\n') + '</pre>';
152
+
153
  ctx.reply(responseText, { parse_mode: 'HTML' });
154
 
155
  // Cleanup
 
178
  }).catch(err => {
179
  console.error('Failed to get bot info:', err.message);
180
  });
181
+
182
  bot.launch()
183
  .then(() => console.log('Bot shutdown cleanly.'))
184
  .catch(err => console.error('Bot launch error:', err));