repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources15d ago| #1 | """Test script for Twitter integration""" |
| #2 | |
| #3 | import asyncio |
| #4 | from config import load_config |
| #5 | from clients.twitter_client import TwitterClient |
| #6 | |
| #7 | |
| #8 | async def test_twitter(): |
| #9 | """Test Twitter client initialization and posting.""" |
| #10 | |
| #11 | print("🐦 Testing Twitter Integration\n") |
| #12 | print("=" * 60) |
| #13 | |
| #14 | # Load config |
| #15 | print("\n1. Loading configuration...") |
| #16 | config = load_config() |
| #17 | |
| #18 | # Check if Twitter credentials are configured |
| #19 | if not all([ |
| #20 | config.twitter_consumer_key, |
| #21 | config.twitter_consumer_secret, |
| #22 | config.twitter_access_token, |
| #23 | config.twitter_access_token_secret, |
| #24 | ]): |
| #25 | print("❌ Twitter credentials not configured in .env.local") |
| #26 | return |
| #27 | |
| #28 | print("✓ Twitter credentials found") |
| #29 | |
| #30 | # Initialize Twitter client |
| #31 | print("\n2. Initializing Twitter client...") |
| #32 | twitter = TwitterClient( |
| #33 | consumer_key=config.twitter_consumer_key, |
| #34 | consumer_secret=config.twitter_consumer_secret, |
| #35 | access_token=config.twitter_access_token, |
| #36 | access_token_secret=config.twitter_access_token_secret, |
| #37 | bearer_token=config.twitter_bearer_token, |
| #38 | ) |
| #39 | print("✓ Twitter client initialized") |
| #40 | |
| #41 | # Get authenticated user info |
| #42 | print("\n3. Testing authentication...") |
| #43 | try: |
| #44 | user_info = await twitter.get_authenticated_user() |
| #45 | print(f"✓ Authenticated as: @{user_info['username']} ({user_info['name']})") |
| #46 | print(f" User ID: {user_info['id']}") |
| #47 | except Exception as e: |
| #48 | print(f"❌ Authentication failed: {e}") |
| #49 | return |
| #50 | |
| #51 | # Test posting a tweet |
| #52 | print("\n4. Testing tweet posting...") |
| #53 | test_tweet = "🧪 Testing MAWD Twitter integration! The AI Solana trading agent is now connected. 🌊 #Solana #AI" |
| #54 | |
| #55 | print(f" Tweet text: {test_tweet}") |
| #56 | print(f" Length: {len(test_tweet)} characters") |
| #57 | |
| #58 | response = input("\n Post this test tweet? (y/n): ") |
| #59 | if response.lower() == 'y': |
| #60 | try: |
| #61 | result = await twitter.post_tweet(test_tweet) |
| #62 | if result.success: |
| #63 | print(f"✓ Tweet posted successfully!") |
| #64 | print(f" Tweet ID: {result.tweet_id}") |
| #65 | print(f" URL: {result.url}") |
| #66 | else: |
| #67 | print(f"❌ Failed to post tweet: {result.error}") |
| #68 | except Exception as e: |
| #69 | print(f"❌ Error posting tweet: {e}") |
| #70 | else: |
| #71 | print(" Skipped posting test tweet") |
| #72 | |
| #73 | print("\n" + "=" * 60) |
| #74 | print("✓ Twitter integration test complete!") |
| #75 | |
| #76 | |
| #77 | if __name__ == "__main__": |
| #78 | asyncio.run(test_twitter()) |
| #79 |