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

Uploaded Python 3

File details

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

File metadata

  • Download URL: lukhed_x-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 8b516c20cc01a73a0e85569cfb484aa392dcf3dafcacf4cb66dc962588bf3dd7
MD5 2930618f3cbc696913b2b1f4aef3d172
BLAKE2b-256 eb75090b1186b107ed9fdcf3a761ebf2f468b63fe3f7718989a4834f13f725d4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lukhed_x-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 051a50bcb1851e030046285e6dc3dcc1ed5d284e0c82cf097906a340784a7a04
MD5 e5de99a8880bedd6d882013b402b3e5f
BLAKE2b-256 181b93ba368244255b160588941ca06b988dd49ae3135f1cd338741d307ed14d

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