mezoAgent 0.6.5__tar.gz → 0.7.0__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {mezoagent-0.6.5 → mezoagent-0.7.0}/PKG-INFO +1 -1
- {mezoagent-0.6.5 → mezoagent-0.7.0}/mezoAgent.egg-info/PKG-INFO +1 -1
- {mezoagent-0.6.5 → mezoagent-0.7.0}/mezoAgent.egg-info/SOURCES.txt +2 -0
- {mezoagent-0.6.5 → mezoagent-0.7.0}/mezo_agent/__init__.py +3 -1
- mezoagent-0.7.0/mezo_agent/twitter_client.py +78 -0
- mezoagent-0.7.0/mezo_agent/twitter_manager.py +0 -0
- {mezoagent-0.6.5 → mezoagent-0.7.0}/setup.py +1 -1
- {mezoagent-0.6.5 → mezoagent-0.7.0}/MANIFEST.in +0 -0
- {mezoagent-0.6.5 → mezoagent-0.7.0}/README.md +0 -0
- {mezoagent-0.6.5 → mezoagent-0.7.0}/mezoAgent.egg-info/dependency_links.txt +0 -0
- {mezoagent-0.6.5 → mezoagent-0.7.0}/mezoAgent.egg-info/requires.txt +0 -0
- {mezoagent-0.6.5 → mezoagent-0.7.0}/mezoAgent.egg-info/top_level.txt +0 -0
- {mezoagent-0.6.5 → mezoagent-0.7.0}/mezo_agent/characters.py +0 -0
- {mezoagent-0.6.5 → mezoagent-0.7.0}/mezo_agent/chat.py +0 -0
- {mezoagent-0.6.5 → mezoagent-0.7.0}/mezo_agent/config.py +0 -0
- {mezoagent-0.6.5 → mezoagent-0.7.0}/mezo_agent/data/new_router.json +0 -0
- {mezoagent-0.6.5 → mezoagent-0.7.0}/mezo_agent/parsing.py +0 -0
- {mezoagent-0.6.5 → mezoagent-0.7.0}/mezo_agent/swap_musd_btc.py +0 -0
- {mezoagent-0.6.5 → mezoagent-0.7.0}/mezo_agent/token_balance_tool.py +0 -0
- {mezoagent-0.6.5 → mezoagent-0.7.0}/mezo_agent/token_price_tool.py +0 -0
- {mezoagent-0.6.5 → mezoagent-0.7.0}/mezo_agent/token_utils.py +0 -0
- {mezoagent-0.6.5 → mezoagent-0.7.0}/mezo_agent/transaction.py +0 -0
- {mezoagent-0.6.5 → mezoagent-0.7.0}/mezo_agent/utils.py +0 -0
- {mezoagent-0.6.5 → mezoagent-0.7.0}/setup.cfg +0 -0
@@ -4,7 +4,8 @@ from .chat import mezo_character_chat
|
|
4
4
|
from .characters import get_character_prompt
|
5
5
|
from .token_balance_tool import mezo_agent_token_balance_tool
|
6
6
|
from .token_price_tool import mezo_agent_token_price_tool
|
7
|
-
from .token_utils import get_token_address_by_symbol
|
7
|
+
from .token_utils import get_token_address_by_symbol
|
8
|
+
from .twitter_manager import TwitterManager
|
8
9
|
|
9
10
|
__all__ = [
|
10
11
|
"mezo_agent_transaction_btc",
|
@@ -14,5 +15,6 @@ __all__ = [
|
|
14
15
|
"mezo_agent_token_balance_tool",
|
15
16
|
"mezo_agent_token_price_tool",
|
16
17
|
"get_token_address_by_symbol",
|
18
|
+
"TwitterManager",
|
17
19
|
"get_character_prompt"
|
18
20
|
]
|
@@ -0,0 +1,78 @@
|
|
1
|
+
import tweepy
|
2
|
+
import time
|
3
|
+
import random
|
4
|
+
from datetime import datetime, timedelta
|
5
|
+
from threading import Thread
|
6
|
+
from mezo_agent.config import load_dotenv
|
7
|
+
import os
|
8
|
+
|
9
|
+
# Load environment variables
|
10
|
+
load_dotenv()
|
11
|
+
|
12
|
+
class TwitterClient:
|
13
|
+
"""
|
14
|
+
A modular Twitter client for MezoAgent that allows characters to tweet automatically.
|
15
|
+
"""
|
16
|
+
|
17
|
+
def __init__(self, character_name: str, api_key: str, api_secret: str, access_token: str, access_secret: str):
|
18
|
+
"""
|
19
|
+
Initializes the Twitter client for a given character.
|
20
|
+
|
21
|
+
:param character_name: Name of the AI character.
|
22
|
+
:param api_key: Twitter API Key.
|
23
|
+
:param api_secret: Twitter API Secret Key.
|
24
|
+
:param access_token: Twitter Access Token.
|
25
|
+
:param access_secret: Twitter Access Token Secret.
|
26
|
+
"""
|
27
|
+
self.character_name = character_name
|
28
|
+
|
29
|
+
# Authenticate with Twitter API
|
30
|
+
auth = tweepy.OAuthHandler(api_key, api_secret)
|
31
|
+
auth.set_access_token(access_token, access_secret)
|
32
|
+
self.api = tweepy.API(auth, wait_on_rate_limit=True)
|
33
|
+
|
34
|
+
# Schedule tweets
|
35
|
+
self.schedule_tweets()
|
36
|
+
|
37
|
+
def generate_tweet(self) -> str:
|
38
|
+
"""
|
39
|
+
Generates a tweet using AI for the character.
|
40
|
+
This function can be modified to pull from AI-generated content.
|
41
|
+
|
42
|
+
:return: A string containing the tweet.
|
43
|
+
"""
|
44
|
+
tweet_templates = [
|
45
|
+
f"{self.character_name} is thinking about the future of DeFi... 🚀",
|
46
|
+
f"GM! {self.character_name} says stay bullish today. 🌞",
|
47
|
+
f"On-chain or it didn't happen! - {self.character_name} ⛓️",
|
48
|
+
f"{self.character_name} is stacking sats and stacking wisdom. 💡",
|
49
|
+
f"Wen moon? {self.character_name} says HODL tight! 🌙"
|
50
|
+
]
|
51
|
+
return random.choice(tweet_templates)
|
52
|
+
|
53
|
+
def post_tweet(self):
|
54
|
+
"""
|
55
|
+
Posts a tweet for the character.
|
56
|
+
"""
|
57
|
+
try:
|
58
|
+
tweet_content = self.generate_tweet()
|
59
|
+
self.api.update_status(tweet_content)
|
60
|
+
print(f"✅ {self.character_name} tweeted: {tweet_content}")
|
61
|
+
except Exception as e:
|
62
|
+
print(f"❌ Failed to post tweet for {self.character_name}: {e}")
|
63
|
+
|
64
|
+
def schedule_tweets(self):
|
65
|
+
"""
|
66
|
+
Schedules tweets to be sent 5 times per 24-hour period.
|
67
|
+
Runs in a separate thread to avoid blocking the main agent process.
|
68
|
+
"""
|
69
|
+
def tweet_scheduler():
|
70
|
+
while True:
|
71
|
+
for _ in range(5): # Post 5 tweets per day
|
72
|
+
self.post_tweet()
|
73
|
+
sleep_time = (24 * 60 * 60) // 5 # Spread tweets across 24 hours
|
74
|
+
print(f"⏳ Next tweet in {sleep_time // 60} minutes...")
|
75
|
+
time.sleep(sleep_time)
|
76
|
+
|
77
|
+
thread = Thread(target=tweet_scheduler, daemon=True)
|
78
|
+
thread.start()
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|