From 2151e649c8905557cfe34f5702e777111bfed4a6 Mon Sep 17 00:00:00 2001 From: gil Date: Fri, 27 Sep 2024 10:49:57 +0200 Subject: [PATCH] improved pocketethereum --- handlers.js | 30 ++++++++++++++++++++---------- shitcoinLists.js | 3 +-- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/handlers.js b/handlers.js index 617ec5a..a480820 100644 --- a/handlers.js +++ b/handlers.js @@ -112,7 +112,7 @@ const handleAdminApproval = async (bot, callbackQuery) => { const eventNaddr = nip19.naddrEncode({ kind: publishedEvent.kind, pubkey: publishedEvent.pubkey, - identifier: publishedEvent.tags.find(t => t[0] === 'd')?. [1] || '', + identifier: publishedEvent.tags.find(t => t[0] === 'd')?.[1] || '', }); const flockstrLink = `https://www.flockstr.com/event/${eventNaddr}`; @@ -146,7 +146,7 @@ const filterEventsByTimeFrame = (allEvents, timeFrame) => { return allEvents.map(calendar => ({ ...calendar, events: calendar.events.filter(event => { - const eventDate = new Date(parseInt(event.tags.find(t => t[0] === 'start')?. [1] || '0') * 1000); + const eventDate = new Date(parseInt(event.tags.find(t => t[0] === 'start')?.[1] || '0') * 1000); switch (timeFrame) { case 'today': return eventDate >= today && eventDate <= endOfDay; @@ -418,13 +418,13 @@ Möchten Sie dieses Event löschen? const keyboard = { inline_keyboard: [ [{ - text: 'Genehmigen', - callback_data: `approve_delete_${userChatId}` - }, - { - text: 'Ablehnen', - callback_data: `reject_delete_${userChatId}` - } + text: 'Genehmigen', + callback_data: `approve_delete_${userChatId}` + }, + { + text: 'Ablehnen', + callback_data: `reject_delete_${userChatId}` + } ] ] }; @@ -540,8 +540,17 @@ const handleMessage = (bot, msg) => { // Check for trigger words in group chats const text = msg.text ? msg.text.toLowerCase() : ""; + let matchedEthereum = ''; + const isEthereum = ethereumTriggerWords.some(word => { + const match = new RegExp(`\\b${word}\\b`).test(text); + if (match) { + matchedEthereum = word; + } + return match; + }); + // Check for Ethereum trigger words - if (ethereumTriggerWords.some(word => text.includes(word))) { + if (isEthereum) { const response = ethereumResponses[Math.floor(Math.random() * ethereumResponses.length)]; bot.sendMessage(msg.chat.id, response, { parse_mode: 'HTML', @@ -557,6 +566,7 @@ const handleMessage = (bot, msg) => { } return match; }); + // Check for other shitcoin trigger words if (isShitcoin) { const response = matchedShitcoin.toUpperCase() + "?!\n\n" + shitCoinResponses[Math.floor(Math.random() * shitCoinResponses.length)]; diff --git a/shitcoinLists.js b/shitcoinLists.js index 41b128a..4c691a2 100644 --- a/shitcoinLists.js +++ b/shitcoinLists.js @@ -1,6 +1,5 @@ const ethereumTriggerWords = [ - "ethereum", "ether", "vitalik", "buterin", "evm", "gwei", "solidity", "vyper", "ethash", - "dao", "zkrollup", "etherium", "ethirium", "ithirium", "ethreum", "etherum", "etherium", "etheruem" + "ethereum", "ether", "vitalik", "buterin", "solidity", "etherium", "ethirium", "ithirium", "ethreum", "etherum", "etherium", "etheruem" ]; const ethereumResponses = [