Skip to main content

Tweet Catcher API Python Wrapper

Project description

TweetCatcherPy

TweetCatcherPy is a Python wrapper for the Tweet Catcher API, providing an easy way to monitor Twitter activities such as posts, retweets, replies, and more. This library supports asynchronous operations and provides seamless integration with Discord, Telegram, Webhooks, and WebSocket notifications.


Installation

To install TweetCatcherPy, simply add it to your project dependencies using pip:

pip install TweetCatcherPy

Features

  • Create tasks to monitor Twitter users.
  • Receive notifications via Discord, Telegram, Webhooks, or WebSocket.
  • Support for advanced filtering using positive/negative keywords or regular expressions.
  • Manage tasks (start, edit, stop, delete).
  • Retrieve user and task information.

Getting Started

Importing the Library

from TweetCatcherPy import TweetCatcher, CreateTaskArgs, PingRegex, PingKeywords

Authentication

To use the Tweet Catcher API, you need an API token. Initialize the TweetCatcher client with your token:

api_token = "your_api_token_here"
tweet_catcher = TweetCatcher(api_token)

Creating a Task

Define the parameters for the task using CreateTaskArgs. For example:

from TweetCatcherPy import CreateTaskArgs, PingKeywords

args = CreateTaskArgs(
    username="elonmusk",
    options=["posts", "retweets"],
    notification="discord",
    webhook="https://discordapp.com/api/webhooks/...",
    ping="role",
    roleId="1234567890",
    pingKeywords=PingKeywords(positive=["Tesla", "SpaceX"], negative=["delay", "issue"]),
    start=True
)

Create the task:

import asyncio

async def create_task():
    response = await tweet_catcher.create_task(args)
    print("Task created successfully:", response)

asyncio.run(create_task())

Managing Tasks

Get All Tasks

async def get_tasks():
    tasks = await tweet_catcher.get_tasks()
    print("Tasks:", tasks)

asyncio.run(get_tasks())

Start a Task

async def start_task(task_id):
    response = await tweet_catcher.start_task(task_id)
    print("Task started successfully:", response)

asyncio.run(start_task(123))

Edit a Task

async def edit_task(task_id):
    updated_args = CreateTaskArgs(
        username="elonmusk",
        options=["posts", "replies"],
        notification="telegram",
        chatId="@your_telegram_chat_id",
        start=False
    )

    response = await tweet_catcher.edit_task(task_id, updated_args)
    print("Task edited successfully:", response)

asyncio.run(edit_task(123))

Stop or Delete a Task

async def stop_task(task_id):
    response = await tweet_catcher.stop_task(task_id)
    print("Task stopped successfully:", response)

async def delete_task(task_id):
    response = await tweet_catcher.delete_task(task_id)
    print("Task deleted successfully:", response)

asyncio.run(stop_task(123))
asyncio.run(delete_task(123))

WebSocket Integration

Connect to the WebSocket to receive real-time updates:

async def run_websocket():
    await tweet_catcher.start()

    try:
        while True:
            message = await tweet_catcher.get_message()
            print("New WebSocket Message:", message)
    except KeyboardInterrupt:
        await tweet_catcher.stop()

asyncio.run(run_websocket())

Error Handling

All API interactions raise exceptions if an error occurs. Make sure to handle them appropriately:

try:
    response = await tweet_catcher.create_task(args)
except Exception as e:
    print("Error:", e)

License

This project is licensed under a proprietary license. See the LICENSE.md file for details.

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

tweetcatcherpy-0.0.1.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

TweetCatcherPy-0.0.1-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file tweetcatcherpy-0.0.1.tar.gz.

File metadata

  • Download URL: tweetcatcherpy-0.0.1.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.9

File hashes

Hashes for tweetcatcherpy-0.0.1.tar.gz
Algorithm Hash digest
SHA256 7d8e810d044189fad6191f38642668eb0db3dce52f3e715b45ee864cbe7cc0dc
MD5 e0cd341f635bdb015bbcb5dd84c6b256
BLAKE2b-256 fce490fa9063bf5b6073316e4cd5666270524c6b132255348488769d856825d2

See more details on using hashes here.

File details

Details for the file TweetCatcherPy-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: TweetCatcherPy-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.9

File hashes

Hashes for TweetCatcherPy-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6e399ad54ee546f79fc82cd03f90c9097afd48123ba25e8fd97149a69a0b2f4b
MD5 e3f5b7c70a1114d6441100c01caca286
BLAKE2b-256 5f4905b2c05c44fcff0dc2da7a9f0ab69b133bde0f752b83295fb8f22030e5e7

See more details on using hashes here.

Supported by

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