Skip to main content

Custom tweepy wrapper for posting on X. Used by @grindSunday and @popPunkpoets Bots

Project description

lukhed_x

A custom tweepy wrapper for posting on X (formerly Twitter) with built-in key management and enhanced functionality. Used by @grindSunday and @popPunkPoets bots.

Features

  • Easy X API Integration: Simplified interface for X API v1 and v2 endpoints
  • Flexible Key Management: Store API credentials locally or in GitHub repositories
  • Post Management: Create, delete, and manage posts with media support
  • Image Upload Support: Easy media attachment for posts

Installation

pip install lukhed-x

Quick Start

Initial Setup

from lukhed_x import X

# First-time setup - this will prompt for your X API credentials
x_client = X(handle="your_handle", x_api_setup=True)

Basic Usage

from lukhed_x import X

# Initialize client (after initial setup)
x_client = X(handle="your_handle")

# Create a simple tweet
result = x_client.create_tweet("Hello, world!")
if not result["error"]:
    print(f"Tweet posted: {result['url']}")
    print(f"Tweet ID: {result['tweetID']}")

# Create tweet with image
result = x_client.create_tweet(
    "Check out this image!", 
    image_data="path/to/image.jpg"
)

# Reply to a tweet
result = x_client.create_tweet(
    ".@username Thanks for the great post!",
    reply_to_tweet_id="1234567890"
)

# Quote tweet
result = x_client.create_tweet(
    "Great point!",
    quote_tweet_id="1234567890"
)

# Delete a tweet
result = x_client.delete_tweet("your_tweet_id")

X API Setup

Before using lukhed_x, you need to set up an X Developer account:

  1. Create a free developer account at developer.x.com
  2. Create a new app and generate your API credentials
  3. You'll need:
    • API Key
    • API Secret
    • Access Token
    • Access Token Secret

For detailed instructions, visit: X API Getting Started Guide

Key Management Options

lukhed_x supports two key management strategies:

Local Storage

x_client = X(handle="your_handle", key_management="local")

Stores API credentials in your local file system.

GitHub Storage (Default)

x_client = X(handle="your_handle", key_management="github")

Stores API credentials in a private GitHub repository, allowing access across different devices. You will need a github access token: Managing your personal access tokens

Error Handling

All API methods return a consistent error structure:

result = x_client.create_tweet("Hello!")
if result["error"]:
    print("Function Error:", result["errorData"]["functionError"])
    print("Tweepy Error:", result["errorData"]["tweepyError"])
else:
    print("Success:", result["url"])

License

This project is licensed under the MIT License.

Support

For issues and questions, please open an issue on the GitHub repository.


Note: This wrapper is designed for legitimate bot usage and follows X's Terms of Service. Please ensure your bot complies with X's automation rules and rate limits.

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

lukhed_x-0.1.2.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

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

lukhed_x-0.1.2-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lukhed_x-0.1.2.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.9

File hashes

Hashes for lukhed_x-0.1.2.tar.gz
Algorithm Hash digest
SHA256 53bd80c389ca2fd0f4524cdac3b78414cb63e92ef8582e9e2617359a0290d394
MD5 dc2b76ee0012f08b22a5b425880feb40
BLAKE2b-256 bf30f6dfa0053ea2ce5c036af78963c789d8f701841021266f2bebb430b09791

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lukhed_x-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.9

File hashes

Hashes for lukhed_x-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 83dfe6fa21bf8218cd55a768e11f0011042e4762b5a25d66dcb3c49028ebd7fd
MD5 328b79d19e30e08fbcebafc434df2bb7
BLAKE2b-256 51a7914c131a4a9559c944831ddea2e15d55dc7e99682df111f41fe03cc5612d

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