Skip to main content

Simple package to get information about meetups

Project description

Meetup-Notifier

Meetup-Notifier is a simple Python script that collects events from Meetup.com and sends notifications to several platforms. The package is designed to be used as a CLI tool, but it can also be used as a library. It works by scraping the Meetup.com events page and extracting the relevant information from the HTML.

Installation

uv pip install meetup-notifier

Usage

The CLI tool can be used to get a json list of events from a Meetup.com page.

$ meetup-notifier events https://www.meetup.com/generative-ai-on-aws/events/

[{"link": "https://www.meetup.com/generative-ai-on-aws/events/303452518/", "name": "AWS Loft Event: Building Agentic Workflows on AWS (Hands-On Workshop!) (Repeat)", "description": "Hands-on workshop!...

Library

As a library, you can use the get_events function to get a list of MeetupEvent objects. And then send notification to a platform of your choice. The following example shows how to send notifications to a Telegram chat.

from meetup_notifier import MeetupEvent, get_events
import typer
from typing_extensions import Annotated
from datetime import datetime, timedelta
import requests
from rich.console import Console

app = typer.Typer()
console = Console()


def notify_telegram(event: MeetupEvent, telegram_token: str, telegram_chat_id: str):
    url = f"https://api.telegram.org/bot{telegram_token}/sendPhoto"

    text = (
        f"{time_until_event(event)}\n"
        f"📝 [Apúntate aqui]({event.link})\n"
        f"📍 [{event.venue}]({event.location_link})\n"
        f"🗺️ {event.location}"
    )
    message_payload = {
        "chat_id": telegram_chat_id,
        "caption": text,
        "photo": event.image,
        "parse_mode": "Markdown",
    }

    response = requests.post(url, data=message_payload)
    response.raise_for_status()

    console.print(f"📢 Evento enviado a Telegram: {event.name}")


def time_until_event(event: MeetupEvent):
    now = datetime.now(event.date.tzinfo)  # Use event date timezone
    tomorrow_start = (now + timedelta(days=1)).replace(
        hour=0, minute=0, second=0, microsecond=0
    )
    day_after_tomorrow_start = (now + timedelta(days=2)).replace(
        hour=0, minute=0, second=0, microsecond=0
    )

    time_diff = event.date - now
    event_time_str = event.date.strftime("%H:%M")

    if event.date < now:
        return f"❗️ **El evento ya ocurrió** el {event.date.strftime('%Y-%m-%d')} a las {event_time_str} 🕒"
    elif now < event.date < tomorrow_start:
        return f"🎉 **¡El evento es hoy a las** {event_time_str}**!**"
    elif tomorrow_start <= event.date < day_after_tomorrow_start:
        return f"⏰ **¡El evento es mañana a las** {event_time_str}**!**"
    else:
        return f"📅 **El evento será dentro de {time_diff.days} días**"


@app.command()
def notify(
    events_url: str = typer.Argument(..., help="URL de la página de eventos de Meetup"),
    telegram_token: Annotated[str, "Token de Telegram"] = typer.Option(
        help="Token de Telegram",
        envvar="TELEGRAM_TOKEN",
    ),
    telegram_chat_id: Annotated[str, "Chat ID de Telegram"] = typer.Option(
        help="Chat ID de Telegram",
        envvar="TELEGRAM_CHAT_ID",
    ),
):
    if not telegram_token or not telegram_chat_id:
        console.print(
            "❌ Debes proporcionar un token y un chat ID de Telegram para enviar notificaciones"
        )
    events = get_events(events_url)
    for event in events:
        notify_telegram(event, telegram_token, telegram_chat_id)


if __name__ == "__main__":
    typer.run(notify)

To run the script, you need to provide the Telegram token and chat ID as environment variables.

 uv run --with meetup-notifier example.py "https://www.meetup.com/hiking-valencia/?eventOrigin=event_home_page" --telegram-chat-id TELEGRAM_CHAT_ID --telegram-token TELEGRAM_TOKEN

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

meetup_notifier-0.1.1.tar.gz (69.9 kB view details)

Uploaded Source

Built Distribution

meetup_notifier-0.1.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file meetup_notifier-0.1.1.tar.gz.

File metadata

  • Download URL: meetup_notifier-0.1.1.tar.gz
  • Upload date:
  • Size: 69.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for meetup_notifier-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a5e3d594e740804d9f9c58df708a1080b6aecb8f546cd7c1f90663c98f2ccdea
MD5 779114fd4a2ad2d1d3026db4d9494272
BLAKE2b-256 c80d3ed65e77fae4e77df4588bca02b8592b5e44dbbe572ab25b1886896c9dcf

See more details on using hashes here.

File details

Details for the file meetup_notifier-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for meetup_notifier-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 97fecb7a2ac1305d944b34c12de460993d89386c61ced4d90382f65d40de9c68
MD5 694ed3935cb23506320276e049cf2028
BLAKE2b-256 2a6b6ead0718298b30a050bc74b728d488d0b83c12409fd52654cc30b3190307

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page