Skip to content

Commit

Permalink
Merge branch 'main' of github.com:gillohner/dezentralschweiz_bot
Browse files Browse the repository at this point in the history
  • Loading branch information
gillohner committed Nov 10, 2024
2 parents 0a1042f + 56be871 commit 104e4c3
Show file tree
Hide file tree
Showing 91 changed files with 54,361 additions and 177 deletions.
8 changes: 5 additions & 3 deletions bot.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// External Libraries
import TelegramBot from 'node-telegram-bot-api';
import { getPublicKey, nip19 } from 'nostr-tools';

// Config and State
// Config
import config from './bot/config.js';
import userStates from './userStates.js';

// Import Tasks
import { scheduleWeeklyMeetupPost } from "./scheduledTasks.js"

// Handlers
import { setupCommands } from './bot/commands.js';
Expand Down Expand Up @@ -52,6 +53,7 @@ const main = async () => {
await setupCommands(bot);
await initializeBot(bot);
setupEventHandlers(bot);
scheduleWeeklyMeetupPost(bot);
};

main();
3 changes: 2 additions & 1 deletion bot/commands.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const commands = [{
const commands = [
{
command: 'start',
description: 'Starte den Bot'
},
Expand Down
1 change: 1 addition & 0 deletions bot/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const config = {
DEFAULT_RELAYS: process.env.DEFAULT_RELAYS?.split(',') || [],
FETCH_RELAY: process.env.FETCH_RELAY,
ADMIN_CHAT_ID: process.env.ADMIN_CHAT_ID,
MEETUP_CHAT_ID: process.env.MEETUP_CHAT_ID,
BOT_NSEC: process.env.BOT_NSEC,
EVENT_CALENDAR_NADDR: process.env.EVENT_CALENDAR_NADDR,
};
Expand Down
76 changes: 50 additions & 26 deletions datasets/communityLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ const communityLinks = {
'Dezentralschweiz Gruppen': [
{
name: 'Bitcoin Gruppe 💬',
url: 'https://t.me/+iu9fNXw0NeE4ZmE0'
url: 'https://t.me/+iu9fNXw0NeE4ZmE0',
id: '-1001759384231'
},
{
name: 'Meetup Gruppe 🍻',
url: 'https://t.me/+XEWwvUPaxPBlZjM0'
url: 'https://t.me/+XEWwvUPaxPBlZjM0',
id: '-1001284407897'
},
{
name: 'Offtopic Gruppe 👀',
url: 'https://t.me/joinchat/NL5C5XuMSwczMzJh'
url: 'https://t.me/joinchat/NL5C5XuMSwczMzJh',
id: '-1001750710633'
},
{
name: 'Dezentralschweiz Backup 🔐 (P2P)',
Expand All @@ -19,44 +22,49 @@ const communityLinks = {
],
'Regionale Gruppen': [
{
name: "Bitcoin Alps",
url: "https://t.me/bitcoin_alps"
name: 'Bitcoin Alps',
url: 'https://t.me/bitcoin_alps'
},
{
name: "Bitcoin Baden",
url: "https://bitcoinbaden.ch/"
name: 'Bitcoin Baden',
url: 'https://bitcoinbaden.ch/'
},
{
name: "Einundzwanzig Meetup Ostschweiz",
url: "https://t.me/+dl7U3c1THKE2ODhk"
name: 'Einundzwanzig Meetup Ostschweiz',
url: 'https://t.me/+dl7U3c1THKE2ODhk',
id: '-1001737615727'
},
{
name: 'Bitcoin Luzern',
url: 'https://t.me/bitcoinluzern'
url: 'https://t.me/bitcoinluzern',
id: '-1001886830711'
},
{
name: '21⚡️BITCOIN WINTI',
url: 'https://t.me/+Tle8OoJnAJw2YWRk'
},
{
name: 'Einundzwanzig Meetup Einsiedeln',
url: 'https://t.me/+sdT8TNEJIMc2Y2U8'
url: 'https://t.me/+sdT8TNEJIMc2Y2U8',
id: '-1001885048851'
},
{
name: " Einezwänzg Solothurn",
url: "https://t.me/+BPb0b8yHLbM4NTY5"
name: ' Einezwänzg Solothurn',
url: 'https://t.me/+BPb0b8yHLbM4NTY5',
id: '-1001965341056'
},
{
name: "Einundzwanzig Basel",
url: "https://t.me/+LWtqciNZDiNmNTFk"
name: 'Einundzwanzig Basel',
url: 'https://t.me/+LWtqciNZDiNmNTFk'
},
{
name: "Einundzwanzig Thurgau",
url: "https://t.me/Einundzwanzig_Thurgau"
name: 'Einundzwanzig Thurgau',
url: 'https://t.me/Einundzwanzig_Thurgau',
id: '-1001817663515'
},
{
name: "Bitcoin Weesen SG",
url: "https://www.bitcoinweesen.ch"
name: 'Bitcoin Weesen SG',
url: 'https://www.bitcoinweesen.ch'
}
],
'Info Gruppen': [
Expand Down Expand Up @@ -100,6 +108,10 @@ const communityLinks = {
name: 'Berglinde Newsletter',
url: 'https://news.berglinde.com/'
},
{
name: 'Berglinde Podcast',
url: 'https://www.fountain.fm/show/aed4vKr0mXzHSbXxOOmB'
},
{
name: 'Bitpartikel Blog',
url: 'https://bitpartikel.com/cryptonite/'
Expand All @@ -115,16 +127,16 @@ const communityLinks = {
url: 'https://www.bitcoin-mentoring.me'
},
{
name: "Bitcoin Block",
url: "https://bitcoinblock.study/"
name: '21Lectures',
url: 'https://21lectures.com/partner/dezentralschweiz/'
},
{
name: "21 Lessons",
url: "https://21lessons.com/"
name: 'Bitcoin Block',
url: 'https://bitcoinblock.study/'
},
{
name: "House of Satoshi",
url: "https://www.house-of-satoshi.ch/"
name: 'House of Satoshi',
url: 'https://www.house-of-satoshi.ch/'
}
],
'Vereine': [
Expand All @@ -150,6 +162,10 @@ const communityLinks = {
name: 'Pocket',
url: 'https://pocketbitcoin.com/'
},
{
name: 'BitBox',
url: 'https://bitbox.swiss/dezentralschweiz'
},
{
name: 'Bitagent',
url: 'http://bitagent.ch/'
Expand All @@ -161,6 +177,10 @@ const communityLinks = {
{
name: 'Bittr',
url: 'https://getbittr.com/'
},
{
name: 'ZeusATM',
url: 'https://zeusatm.ch/'
}
],
'Shops': [
Expand All @@ -175,7 +195,11 @@ const communityLinks = {
{
name: 'Funtoshi ♟️',
url: 'https://funtoshi.com/'
}
},
{
name: 'Yourdevice',
url: 'https://yourdevice.ch/'
},
]
};

Expand Down
2 changes: 1 addition & 1 deletion datasets/shitcoinLists.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const ethereumTriggerWords = [
"ethereum", "ether", "vitalik", "buterin", "solidity", "etherium", "ethirium", "ithirium", "ethreum", "etherum", "etherium", "etheruem"
"ethereum", "ether", "vitalik", "buterin", "solidity", "etherium", "ethirium", "ithirium", "ethreum", "etherum", "etherium", "etheruem", "eth"
];

const ethereumResponses = [
Expand Down
6 changes: 5 additions & 1 deletion handlers/adminApprovalHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ import {
import {
handleAdminMeetupSuggestionApproval
} from './meetupHandlers/meetupSuggestionHandler.js'
import {
postWeeklyMeetups
} from '../scheduledTasks.js'

const handleAdminApproval = async (bot, callbackQuery, action) => {
if (action.startsWith('approve_delete_') || action.startsWith('reject_delete_')) {
handleAdminMeetupDeletionApproval(bot, callbackQuery);
await handleAdminMeetupDeletionApproval(bot, callbackQuery);
} else if (action.startsWith('approve_meetup_') || action.startsWith('reject_meetup_')) {
await handleAdminMeetupSuggestionApproval(bot, callbackQuery);
}
postWeeklyMeetups(bot);
};

export {
Expand Down
29 changes: 14 additions & 15 deletions handlers/linkHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ const handleLinks = async (bot, msg, communityLinks) => {
bot,
chatId,
'Wähle eine Kategorie:', {
reply_markup: JSON.stringify(keyboard),
disable_notification: true
},
reply_markup: JSON.stringify(keyboard),
disable_notification: true
},
'lastLinksMessageId'
);

Expand All @@ -50,16 +50,11 @@ const handleLinksCallback = async (bot, callbackQuery) => {
const chatId = msg.chat.id;

if (action === 'links_cancel') {
// Handle cancel action
await bot.answerCallbackQuery(callbackQuery.id, {
text: 'Aktion abgebrochen'
});
await bot.answerCallbackQuery(callbackQuery.id, { text: 'Aktion abgebrochen' });
try {
// Delete the selection message
deleteMessage(bot, chatId, msg.message_id);
delete userStates[chatId].lastLinksMessageId;

// Delete the last category message if it exists
if (userStates[chatId]?.lastLinksCategoryMessageId) {
deleteMessage(bot, chatId, userStates[chatId].lastLinksCategoryMessageId);
delete userStates[chatId].lastLinksCategoryMessageId;
Expand All @@ -71,13 +66,17 @@ const handleLinksCallback = async (bot, callbackQuery) => {
const category = action.split('_')[1];
const links = communityLinks[category];
let message = `<b>${category}:\n\n</b>`;

links.forEach(link => {
message += `${link.name}\n${link.url}\n\n`;
let groupName = link.name;
if (link.id && link.id === chatId.toString()) {
groupName += ' (diese Gruppe)';
}
message += `${groupName}\n${link.url}\n\n`;
});

await bot.answerCallbackQuery(callbackQuery.id);

// Delete the previous category message if it exists
if (userStates[chatId]?.lastLinksCategoryMessageId) {
deleteMessage(bot, chatId, userStates[chatId].lastLinksCategoryMessageId);
}
Expand All @@ -86,10 +85,10 @@ const handleLinksCallback = async (bot, callbackQuery) => {
bot,
chatId,
message, {
parse_mode: 'HTML',
disable_web_page_preview: true,
disable_notification: true
},
parse_mode: 'HTML',
disable_web_page_preview: true,
disable_notification: true
},
'lastLinksCategoryMessageId'
);

Expand Down
Loading

0 comments on commit 104e4c3

Please sign in to comment.