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 get_events
from meetup_notifier.meetup import MeetupEvent
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.2.tar.gz (70.6 kB view details)

Uploaded Source

Built Distribution

meetup_notifier-0.1.2-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: meetup_notifier-0.1.2.tar.gz
  • Upload date:
  • Size: 70.6 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.2.tar.gz
Algorithm Hash digest
SHA256 b353fe8016e12cd227f674940c7bc0e3c013c6a8ddcb5a5de5d7f0a45ffab5d7
MD5 80963d19a67955d4108277d1bc3c5933
BLAKE2b-256 a70320738415284615a86e85fe50193849f4f08d70daf6175fc62a66b3aca7dd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for meetup_notifier-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cc9e6307c267ba783b0353d2cf8adb45755cb8c91f74c974a058fb564c508416
MD5 0104b938cd4c682fa5133a8bff067797
BLAKE2b-256 f9865b13b62372f866ff503631e77bc08567c10c229fdbcbe91bd5cf3a0749e3

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