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.0.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.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lukhed_x-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 a25e69faf5dc045bbb236d00504f20f8d13997f103c4a97e78fb2b312003e553
MD5 5b0dcd6f172e80d8165563d0d426c053
BLAKE2b-256 9747572a3ee8e116a5d17b602327bd24bd1d10fce374f78a373421070e0451f3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lukhed_x-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 919a70e06605fa6536341c3c47816f4005bf8c950b5b0d19d9e8cc754bf2ca95
MD5 c390c046ab2889ca14155ec5891464e4
BLAKE2b-256 8d4f8f6dd5210fe321310bb4bfc198a9e33d936833b8c6373a8e033e2ad356d6

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