h-message-bus 0.0.40__py3-none-any.whl → 0.0.41__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- h_message_bus/infrastructure/nats_client_repository.py +2 -2
- h_message_bus/infrastructure/nats_config.py +1 -1
- {h_message_bus-0.0.40.dist-info → h_message_bus-0.0.41.dist-info}/METADATA +106 -85
- h_message_bus-0.0.41.dist-info/RECORD +20 -0
- {h_message_bus-0.0.40.dist-info → h_message_bus-0.0.41.dist-info}/WHEEL +1 -1
- h_message_bus/domain/event_messages/__init__.py +0 -0
- h_message_bus/domain/models/event_message_topic.py +0 -20
- h_message_bus/domain/models/request_message_topic.py +0 -100
- h_message_bus/domain/models/twitter_message_metadata.py +0 -31
- h_message_bus/domain/models/twitter_user_metadata.py +0 -76
- h_message_bus/domain/models/vector_collection_metadata.py +0 -30
- h_message_bus/domain/models/vector_query_answer.py +0 -22
- h_message_bus/domain/request_messages/__init__.py +0 -0
- h_message_bus/domain/request_messages/graph_clear_request_message.py +0 -26
- h_message_bus/domain/request_messages/graph_get_all_request_message.py +0 -27
- h_message_bus/domain/request_messages/graph_get_all_result_response_message.py +0 -45
- h_message_bus/domain/request_messages/graph_node_add_request_message.py +0 -64
- h_message_bus/domain/request_messages/graph_node_added_response_message.py +0 -69
- h_message_bus/domain/request_messages/graph_node_get_request_message.py +0 -39
- h_message_bus/domain/request_messages/graph_node_get_result_response_message.py +0 -70
- h_message_bus/domain/request_messages/graph_node_update_request_message.py +0 -56
- h_message_bus/domain/request_messages/graph_node_update_response_message.py +0 -69
- h_message_bus/domain/request_messages/graph_nodes_by_property_request_message.py +0 -45
- h_message_bus/domain/request_messages/graph_nodes_by_property_response_message.py +0 -80
- h_message_bus/domain/request_messages/graph_query_operation_request_message.py +0 -114
- h_message_bus/domain/request_messages/graph_query_operation_response_message.py +0 -85
- h_message_bus/domain/request_messages/graph_query_request_message.py +0 -48
- h_message_bus/domain/request_messages/graph_relationship_added_request_message.py +0 -63
- h_message_bus/domain/request_messages/init_knowledgebase_request.py +0 -26
- h_message_bus/domain/request_messages/tg_message_request_message.py +0 -48
- h_message_bus/domain/request_messages/tg_user_message_reply_request_message.py +0 -56
- h_message_bus/domain/request_messages/tg_user_message_request_message.py +0 -93
- h_message_bus/domain/request_messages/twitter_follow_user_request_message.py +0 -40
- h_message_bus/domain/request_messages/twitter_follow_user_response_message.py +0 -43
- h_message_bus/domain/request_messages/twitter_get_tweet_request_message.py +0 -40
- h_message_bus/domain/request_messages/twitter_get_tweet_response_message.py +0 -54
- h_message_bus/domain/request_messages/twitter_get_user_request_message.py +0 -35
- h_message_bus/domain/request_messages/twitter_get_user_response_message.py +0 -96
- h_message_bus/domain/request_messages/twitter_get_users_request_message.py +0 -42
- h_message_bus/domain/request_messages/twitter_get_users_response_message.py +0 -44
- h_message_bus/domain/request_messages/twitter_home_timeline_request_message.py +0 -56
- h_message_bus/domain/request_messages/twitter_home_timeline_response_message.py +0 -74
- h_message_bus/domain/request_messages/twitter_post_tweet_request_message.py +0 -40
- h_message_bus/domain/request_messages/twitter_post_tweet_response_message.py +0 -47
- h_message_bus/domain/request_messages/twitter_quote_retweet_request_message.py +0 -48
- h_message_bus/domain/request_messages/twitter_quote_retweet_response_message.py +0 -55
- h_message_bus/domain/request_messages/twitter_reply_request_message.py +0 -48
- h_message_bus/domain/request_messages/twitter_reply_response_message.py +0 -54
- h_message_bus/domain/request_messages/twitter_retweet_request_message.py +0 -40
- h_message_bus/domain/request_messages/twitter_retweet_response_message.py +0 -43
- h_message_bus/domain/request_messages/twitter_search_request_message.py +0 -73
- h_message_bus/domain/request_messages/twitter_search_response_message.py +0 -73
- h_message_bus/domain/request_messages/twitter_user_tweets_request_message.py +0 -63
- h_message_bus/domain/request_messages/twitter_user_tweets_response_message.py +0 -89
- h_message_bus/domain/request_messages/vector_query_collection_request_message.py +0 -51
- h_message_bus/domain/request_messages/vector_query_collection_response_message.py +0 -47
- h_message_bus/domain/request_messages/vector_read_metadata_request_message.py +0 -25
- h_message_bus/domain/request_messages/vector_read_metadata_response_message.py +0 -45
- h_message_bus/domain/request_messages/vector_save_request_message.py +0 -66
- h_message_bus/domain/request_messages/web_get_docs_request_message.py +0 -46
- h_message_bus/domain/request_messages/web_search_request_message.py +0 -32
- h_message_bus-0.0.40.dist-info/RECORD +0 -76
- {h_message_bus-0.0.40.dist-info → h_message_bus-0.0.41.dist-info}/top_level.txt +0 -0
@@ -1,54 +0,0 @@
|
|
1
|
-
from dataclasses import dataclass
|
2
|
-
from typing import Type, Dict, Any, TypeVar, Optional
|
3
|
-
|
4
|
-
from ..models.request_message_topic import RequestMessageTopic
|
5
|
-
from ...domain.models.hai_message import HaiMessage
|
6
|
-
|
7
|
-
T = TypeVar('T', bound='TwitterGetTweetResponseMessage')
|
8
|
-
|
9
|
-
|
10
|
-
@dataclass
|
11
|
-
class TwitterGetTweetResponseMessage(HaiMessage):
|
12
|
-
"""Message to respond to a request to get a tweet by its ID"""
|
13
|
-
|
14
|
-
@classmethod
|
15
|
-
def create(cls: Type[T], topic: str, payload: Dict[Any, Any]) -> T:
|
16
|
-
"""Create a message - inherited from HaiMessage"""
|
17
|
-
return super().create(topic=topic, payload=payload)
|
18
|
-
|
19
|
-
@classmethod
|
20
|
-
def create_message(cls,
|
21
|
-
tweet_id: str,
|
22
|
-
success: bool,
|
23
|
-
tweet: Optional[Dict[str, Any]] = None,
|
24
|
-
error_message: str = "") -> 'TwitterGetTweetResponseMessage':
|
25
|
-
"""Create a response message for a request to get a tweet"""
|
26
|
-
return cls.create(
|
27
|
-
topic=RequestMessageTopic.TWITTER_GET_TWEET_RESPONSE, # You'll need to add this to ResponseMessageTopic
|
28
|
-
payload={
|
29
|
-
"tweet_id": tweet_id,
|
30
|
-
"success": success,
|
31
|
-
"tweet": tweet,
|
32
|
-
"error_message": error_message
|
33
|
-
},
|
34
|
-
)
|
35
|
-
|
36
|
-
@property
|
37
|
-
def tweet_id(self) -> str:
|
38
|
-
"""Get the tweet ID that was requested"""
|
39
|
-
return self.payload.get("tweet_id", "")
|
40
|
-
|
41
|
-
@property
|
42
|
-
def success(self) -> bool:
|
43
|
-
"""Get whether the get tweet operation was successful"""
|
44
|
-
return self.payload.get("success", False)
|
45
|
-
|
46
|
-
@property
|
47
|
-
def tweet(self) -> Optional[Dict[str, Any]]:
|
48
|
-
"""Get the tweet data if the operation was successful"""
|
49
|
-
return self.payload.get("tweet", None)
|
50
|
-
|
51
|
-
@property
|
52
|
-
def error_message(self) -> str:
|
53
|
-
"""Get the error message if the get tweet operation failed"""
|
54
|
-
return self.payload.get("error_message", "")
|
@@ -1,35 +0,0 @@
|
|
1
|
-
from typing import Type, TypeVar, Dict, Any
|
2
|
-
|
3
|
-
from ..models.request_message_topic import RequestMessageTopic
|
4
|
-
from ...domain.models.hai_message import HaiMessage
|
5
|
-
|
6
|
-
T = TypeVar('T', bound='HaiMessage')
|
7
|
-
|
8
|
-
class TwitterGetUserRequestMessage(HaiMessage):
|
9
|
-
"""Message to request Twitter user information"""
|
10
|
-
|
11
|
-
@classmethod
|
12
|
-
def create(cls: Type[T], topic: str, payload: Dict[Any, Any]) -> T:
|
13
|
-
"""Create a message - inherited from HaiMessage"""
|
14
|
-
return super().create(topic=topic, payload=payload)
|
15
|
-
|
16
|
-
@classmethod
|
17
|
-
def create_message(cls, username: str) -> 'TwitterGetUserRequestMessage':
|
18
|
-
"""Create a message requesting Twitter user data"""
|
19
|
-
return cls.create(
|
20
|
-
topic=RequestMessageTopic.TWITTER_GET_USER,
|
21
|
-
payload={"username": username},
|
22
|
-
)
|
23
|
-
|
24
|
-
@property
|
25
|
-
def username(self) -> str:
|
26
|
-
"""Get the username from the payload"""
|
27
|
-
return self.payload.get("username", "")
|
28
|
-
|
29
|
-
@classmethod
|
30
|
-
def from_hai_message(cls, message: HaiMessage) -> 'TwitterGetUserRequestMessage':
|
31
|
-
payload = message.payload
|
32
|
-
|
33
|
-
return cls.create_message(
|
34
|
-
username=payload.get("username", "")
|
35
|
-
)
|
@@ -1,96 +0,0 @@
|
|
1
|
-
from typing import Type, TypeVar, Dict, Any, List
|
2
|
-
|
3
|
-
from ..models.request_message_topic import RequestMessageTopic
|
4
|
-
from ...domain.models.hai_message import HaiMessage
|
5
|
-
|
6
|
-
T = TypeVar('T', bound='HaiMessage')
|
7
|
-
|
8
|
-
class TwitterGetUserResponseMessage(HaiMessage):
|
9
|
-
"""Response of Twitter user information request"""
|
10
|
-
|
11
|
-
@classmethod
|
12
|
-
def create(cls: Type[T], topic: str, payload: Dict[Any, Any]) -> T:
|
13
|
-
"""Create a message - inherited from HaiMessage"""
|
14
|
-
return super().create(topic=topic, payload=payload)
|
15
|
-
|
16
|
-
@classmethod
|
17
|
-
def create_message(cls, user_id: str, screen_name: str, description: str, followers_count: str, like_count: str, is_verified: str, url: str, bio_urls: [str]) -> 'TwitterGetUserResponseMessage':
|
18
|
-
"""Create a response message from Twitter user information"""
|
19
|
-
return cls.create(
|
20
|
-
topic=RequestMessageTopic.TWITTER_GET_USER_RESPONSE,
|
21
|
-
payload={
|
22
|
-
'id': user_id,
|
23
|
-
'screen_name': screen_name,
|
24
|
-
'description': description,
|
25
|
-
'followers_count': followers_count,
|
26
|
-
'like_count': like_count,
|
27
|
-
'is_verified': is_verified,
|
28
|
-
'url': url,
|
29
|
-
'bio_urls': bio_urls
|
30
|
-
})
|
31
|
-
|
32
|
-
@property
|
33
|
-
def user_id(self) -> str:
|
34
|
-
"""Get user ID"""
|
35
|
-
return self.payload.get('id', '')
|
36
|
-
|
37
|
-
@property
|
38
|
-
def screen_name(self) -> str:
|
39
|
-
"""Get screen name"""
|
40
|
-
return self.payload.get('screen_name', '')
|
41
|
-
|
42
|
-
@property
|
43
|
-
def description(self) -> str:
|
44
|
-
"""Get user description"""
|
45
|
-
return self.payload.get('description', '')
|
46
|
-
|
47
|
-
@property
|
48
|
-
def followers_count(self) -> str:
|
49
|
-
"""Get followers count"""
|
50
|
-
return self.payload.get('followers_count', '')
|
51
|
-
|
52
|
-
@property
|
53
|
-
def like_count(self) -> str:
|
54
|
-
"""Get like count"""
|
55
|
-
return self.payload.get('like_count', '')
|
56
|
-
|
57
|
-
@property
|
58
|
-
def is_verified(self) -> str:
|
59
|
-
"""Get verification status"""
|
60
|
-
return self.payload.get('is_verified', '')
|
61
|
-
|
62
|
-
@property
|
63
|
-
def url(self) -> str:
|
64
|
-
"""Get user URL"""
|
65
|
-
return self.payload.get('url', '')
|
66
|
-
|
67
|
-
@property
|
68
|
-
def bio_urls(self) -> List[str]:
|
69
|
-
"""Get URLs from user bio"""
|
70
|
-
return self.payload.get('bio_urls', [])
|
71
|
-
|
72
|
-
@classmethod
|
73
|
-
def from_hai_message(cls, message: HaiMessage) -> 'TwitterGetUserResponseMessage':
|
74
|
-
"""
|
75
|
-
Convert a HaiMessage to TwitterGetUserResponseMessage
|
76
|
-
|
77
|
-
Args:
|
78
|
-
message: The source HaiMessage object
|
79
|
-
|
80
|
-
Returns:
|
81
|
-
A new TwitterGetUserResponseMessage with data from the source message
|
82
|
-
"""
|
83
|
-
# Extract necessary fields from the message payload
|
84
|
-
payload = message.payload
|
85
|
-
|
86
|
-
return cls.create_message(
|
87
|
-
user_id=payload.get('id', ''),
|
88
|
-
screen_name=payload.get('screen_name', ''),
|
89
|
-
description=payload.get('description', ''),
|
90
|
-
followers_count=payload.get('followers_count', ''),
|
91
|
-
like_count=payload.get('like_count', ''),
|
92
|
-
is_verified=payload.get('is_verified', ''),
|
93
|
-
url=payload.get('url', ''),
|
94
|
-
bio_urls=payload.get('bio_urls', [])
|
95
|
-
)
|
96
|
-
|
@@ -1,42 +0,0 @@
|
|
1
|
-
import json
|
2
|
-
from typing import Type, TypeVar, Dict, Any, List
|
3
|
-
|
4
|
-
from ..models.request_message_topic import RequestMessageTopic
|
5
|
-
from ...domain.models.hai_message import HaiMessage
|
6
|
-
|
7
|
-
T = TypeVar('T', bound='HaiMessage')
|
8
|
-
|
9
|
-
class TwitterGetUsersRequestMessage(HaiMessage):
|
10
|
-
"""Message to request Twitter user information"""
|
11
|
-
|
12
|
-
@classmethod
|
13
|
-
def create(cls: Type[T], topic: str, payload: Dict[Any, Any]) -> T:
|
14
|
-
"""Create a message - inherited from HaiMessage"""
|
15
|
-
return super().create(topic=topic, payload=payload)
|
16
|
-
|
17
|
-
@classmethod
|
18
|
-
def create_message(cls, usernames: List[str]) -> 'TwitterGetUsersRequestMessage':
|
19
|
-
"""Create a message requesting Twitter user data"""
|
20
|
-
return cls.create(
|
21
|
-
topic=RequestMessageTopic.TWITTER_GET_USERS,
|
22
|
-
payload={"usernames": json.dumps(usernames)},
|
23
|
-
)
|
24
|
-
|
25
|
-
@property
|
26
|
-
def usernames(self) -> List[str]:
|
27
|
-
"""Get the username from the payload"""
|
28
|
-
usernames_payload = self.payload.get("usernames", "")
|
29
|
-
usernames = json.loads(usernames_payload)
|
30
|
-
response_list = []
|
31
|
-
for username in usernames:
|
32
|
-
response_list.append(username)
|
33
|
-
return response_list
|
34
|
-
|
35
|
-
@classmethod
|
36
|
-
def from_hai_message(cls, message: HaiMessage) -> 'TwitterGetUsersRequestMessage':
|
37
|
-
payload = message.payload
|
38
|
-
usernames = payload.get("usernames", "")
|
39
|
-
usernames_list = json.loads(usernames)
|
40
|
-
return cls.create_message(
|
41
|
-
usernames=usernames_list
|
42
|
-
)
|
@@ -1,44 +0,0 @@
|
|
1
|
-
import json
|
2
|
-
from typing import Type, TypeVar, Dict, Any, List
|
3
|
-
|
4
|
-
from ..models.request_message_topic import RequestMessageTopic
|
5
|
-
from ..models.twitter_user_metadata import TwitterUserMetadata
|
6
|
-
from ...domain.models.hai_message import HaiMessage
|
7
|
-
|
8
|
-
T = TypeVar('T', bound='HaiMessage')
|
9
|
-
|
10
|
-
class TwitterGetUsersResponseMessage(HaiMessage):
|
11
|
-
|
12
|
-
@classmethod
|
13
|
-
def create(cls: Type[T], topic: str, payload: Dict[Any, Any]) -> T:
|
14
|
-
"""Create a message - inherited from HaiMessage"""
|
15
|
-
return super().create(topic=topic, payload=payload)
|
16
|
-
|
17
|
-
@classmethod
|
18
|
-
def create_message(cls, users: List[dict[str, str]]) -> 'TwitterGetUsersResponseMessage':
|
19
|
-
user_result = json.dumps(users)
|
20
|
-
return cls.create(
|
21
|
-
topic=RequestMessageTopic.TWITTER_GET_USERS_RESPONSE,
|
22
|
-
payload={
|
23
|
-
"users": user_result,
|
24
|
-
},
|
25
|
-
)
|
26
|
-
|
27
|
-
@property
|
28
|
-
def users(self) -> List[TwitterUserMetadata]:
|
29
|
-
"""Get the collection name from the message payload"""
|
30
|
-
users = self.payload.get("users", "")
|
31
|
-
users_dict = json.loads(users)
|
32
|
-
response_list = []
|
33
|
-
for user in users_dict:
|
34
|
-
response_list.append(TwitterUserMetadata.from_dict(user))
|
35
|
-
return response_list
|
36
|
-
|
37
|
-
@classmethod
|
38
|
-
def from_hai_message(cls, message: HaiMessage) -> 'TwitterGetUsersResponseMessage':
|
39
|
-
payload = message.payload
|
40
|
-
metadata = payload.get("users", "")
|
41
|
-
meta_list = json.loads(metadata)
|
42
|
-
return cls.create_message(
|
43
|
-
users=meta_list
|
44
|
-
)
|
@@ -1,56 +0,0 @@
|
|
1
|
-
from dataclasses import dataclass
|
2
|
-
from typing import Type, Dict, Any, TypeVar
|
3
|
-
|
4
|
-
from ..models.request_message_topic import RequestMessageTopic
|
5
|
-
from ...domain.models.hai_message import HaiMessage
|
6
|
-
|
7
|
-
T = TypeVar('T', bound='TwitterHomeTimelineRequestMessage')
|
8
|
-
|
9
|
-
@dataclass
|
10
|
-
class TwitterHomeTimelineRequestMessage(HaiMessage):
|
11
|
-
"""Message to request the home timeline for the authenticated Twitter user"""
|
12
|
-
|
13
|
-
@classmethod
|
14
|
-
def create(cls: Type[T], topic: str, payload: Dict[Any, Any]) -> T:
|
15
|
-
"""Create a message - inherited from HaiMessage"""
|
16
|
-
return super().create(topic=topic, payload=payload)
|
17
|
-
|
18
|
-
@classmethod
|
19
|
-
def create_message(cls, max_results: int = 100,
|
20
|
-
include_replies: bool = True,
|
21
|
-
include_retweets: bool = True) -> 'TwitterHomeTimelineRequestMessage':
|
22
|
-
"""Create a message requesting the Twitter home timeline"""
|
23
|
-
return cls.create(
|
24
|
-
topic=RequestMessageTopic.TWITTER_GET_HOME_TIMELINE, # You'll need to add this to RequestMessageTopic
|
25
|
-
payload={
|
26
|
-
"max_results": max_results,
|
27
|
-
"include_replies": include_replies,
|
28
|
-
"include_retweets": include_retweets
|
29
|
-
},
|
30
|
-
)
|
31
|
-
|
32
|
-
@property
|
33
|
-
def max_results(self) -> int:
|
34
|
-
"""Get the maximum number of results from the payload"""
|
35
|
-
return self.payload.get("max_results", 100)
|
36
|
-
|
37
|
-
@property
|
38
|
-
def include_replies(self) -> bool:
|
39
|
-
"""Get whether to include replies from the payload"""
|
40
|
-
return self.payload.get("include_replies", True)
|
41
|
-
|
42
|
-
@property
|
43
|
-
def include_retweets(self) -> bool:
|
44
|
-
"""Get whether to include retweets from the payload"""
|
45
|
-
return self.payload.get("include_retweets", True)
|
46
|
-
|
47
|
-
@classmethod
|
48
|
-
def from_hai_message(cls, message: HaiMessage) -> 'TwitterHomeTimelineRequestMessage':
|
49
|
-
"""Create a TwitterHomeTimelineRequestMessage from a HaiMessage"""
|
50
|
-
payload = message.payload
|
51
|
-
|
52
|
-
return cls.create_message(
|
53
|
-
max_results=payload.get("max_results", 100),
|
54
|
-
include_replies=payload.get("include_replies", True),
|
55
|
-
include_retweets=payload.get("include_retweets", True)
|
56
|
-
)
|
@@ -1,74 +0,0 @@
|
|
1
|
-
from dataclasses import dataclass
|
2
|
-
from typing import Type, Dict, Any, TypeVar, List
|
3
|
-
|
4
|
-
from ..models.request_message_topic import RequestMessageTopic
|
5
|
-
from ...domain.models.hai_message import HaiMessage
|
6
|
-
|
7
|
-
T = TypeVar('T', bound='TwitterHomeTimelineResponseMessage')
|
8
|
-
|
9
|
-
|
10
|
-
@dataclass
|
11
|
-
class TwitterMessageMetaData:
|
12
|
-
"""Metadata about a Twitter message"""
|
13
|
-
tweet_id: str
|
14
|
-
user: Dict[str, Any]
|
15
|
-
message: str
|
16
|
-
created_at: str
|
17
|
-
view_count: int
|
18
|
-
retweet_count: int
|
19
|
-
reply_count: int
|
20
|
-
|
21
|
-
|
22
|
-
@dataclass
|
23
|
-
class TwitterHomeTimelineResponseMessage(HaiMessage):
|
24
|
-
"""Message containing the home timeline for the authenticated Twitter user"""
|
25
|
-
|
26
|
-
@classmethod
|
27
|
-
def create(cls: Type[T], topic: str, payload: Dict[Any, Any]) -> T:
|
28
|
-
"""Create a message - inherited from HaiMessage"""
|
29
|
-
return super().create(topic=topic, payload=payload)
|
30
|
-
|
31
|
-
@classmethod
|
32
|
-
def create_message(cls, tweets: List[Dict[str, Any]]) -> 'TwitterHomeTimelineResponseMessage':
|
33
|
-
"""Create a response message with the user's home timeline tweets"""
|
34
|
-
return cls.create(
|
35
|
-
topic=RequestMessageTopic.TWITTER_GET_HOME_TIMELINE_RESPONSE,
|
36
|
-
# You'll need to add this to ResponseMessageTopic
|
37
|
-
payload={
|
38
|
-
"tweets": tweets
|
39
|
-
},
|
40
|
-
)
|
41
|
-
|
42
|
-
@property
|
43
|
-
def tweets(self) -> List[Dict[str, Any]]:
|
44
|
-
"""Get the tweets from the payload"""
|
45
|
-
return self.payload.get("tweets", [])
|
46
|
-
|
47
|
-
@classmethod
|
48
|
-
def from_twitter_messages(cls,
|
49
|
-
twitter_messages: List[TwitterMessageMetaData]) -> 'TwitterHomeTimelineResponseMessage':
|
50
|
-
"""Create a TwitterHomeTimelineResponseMessage from a list of TwitterMessageMetaData"""
|
51
|
-
tweet_list = []
|
52
|
-
|
53
|
-
for message in twitter_messages:
|
54
|
-
tweet_data = {
|
55
|
-
"tweet_id": message.tweet_id,
|
56
|
-
"message": message.message,
|
57
|
-
"created_at": message.created_at,
|
58
|
-
"view_count": message.view_count,
|
59
|
-
"retweet_count": message.retweet_count,
|
60
|
-
"reply_count": message.reply_count,
|
61
|
-
"user": message.user
|
62
|
-
}
|
63
|
-
tweet_list.append(tweet_data)
|
64
|
-
|
65
|
-
return cls.create_message(tweets=tweet_list)
|
66
|
-
|
67
|
-
@classmethod
|
68
|
-
def from_hai_message(cls, message: HaiMessage) -> 'TwitterHomeTimelineResponseMessage':
|
69
|
-
"""Create a TwitterHomeTimelineResponseMessage from a HaiMessage"""
|
70
|
-
payload = message.payload
|
71
|
-
|
72
|
-
return cls.create_message(
|
73
|
-
tweets=payload.get("tweets", [])
|
74
|
-
)
|
@@ -1,40 +0,0 @@
|
|
1
|
-
from dataclasses import dataclass
|
2
|
-
from typing import Type, Dict, Any, TypeVar
|
3
|
-
|
4
|
-
from ..models.request_message_topic import RequestMessageTopic
|
5
|
-
from ...domain.models.hai_message import HaiMessage
|
6
|
-
|
7
|
-
T = TypeVar('T', bound='TwitterPostTweetRequestMessage')
|
8
|
-
|
9
|
-
@dataclass
|
10
|
-
class TwitterPostTweetRequestMessage(HaiMessage):
|
11
|
-
"""Message to request posting a new tweet"""
|
12
|
-
|
13
|
-
@classmethod
|
14
|
-
def create(cls: Type[T], topic: str, payload: Dict[Any, Any]) -> T:
|
15
|
-
"""Create a message - inherited from HaiMessage"""
|
16
|
-
return super().create(topic=topic, payload=payload)
|
17
|
-
|
18
|
-
@classmethod
|
19
|
-
def create_message(cls, text: str) -> 'TwitterPostTweetRequestMessage':
|
20
|
-
"""Create a message requesting to post a new tweet"""
|
21
|
-
return cls.create(
|
22
|
-
topic=RequestMessageTopic.TWITTER_POST_TWEET, # You'll need to add this to RequestMessageTopic
|
23
|
-
payload={
|
24
|
-
"text": text
|
25
|
-
},
|
26
|
-
)
|
27
|
-
|
28
|
-
@property
|
29
|
-
def text(self) -> str:
|
30
|
-
"""Get the text content of the tweet from the payload"""
|
31
|
-
return self.payload.get("text", "")
|
32
|
-
|
33
|
-
@classmethod
|
34
|
-
def from_hai_message(cls, message: HaiMessage) -> 'TwitterPostTweetRequestMessage':
|
35
|
-
"""Create a TwitterPostTweetRequestMessage from a HaiMessage"""
|
36
|
-
payload = message.payload
|
37
|
-
|
38
|
-
return cls.create_message(
|
39
|
-
text=payload.get("text", "")
|
40
|
-
)
|
@@ -1,47 +0,0 @@
|
|
1
|
-
from dataclasses import dataclass
|
2
|
-
from typing import Type, Dict, Any, TypeVar, Optional
|
3
|
-
|
4
|
-
from ..models.request_message_topic import RequestMessageTopic
|
5
|
-
from ...domain.models.hai_message import HaiMessage
|
6
|
-
|
7
|
-
T = TypeVar('T', bound='TwitterPostTweetResponseMessage')
|
8
|
-
|
9
|
-
|
10
|
-
@dataclass
|
11
|
-
class TwitterPostTweetResponseMessage(HaiMessage):
|
12
|
-
"""Message to respond to a request to post a new tweet"""
|
13
|
-
|
14
|
-
@classmethod
|
15
|
-
def create(cls: Type[T], topic: str, payload: Dict[Any, Any]) -> T:
|
16
|
-
"""Create a message - inherited from HaiMessage"""
|
17
|
-
return super().create(topic=topic, payload=payload)
|
18
|
-
|
19
|
-
@classmethod
|
20
|
-
def create_message(cls,
|
21
|
-
success: bool,
|
22
|
-
tweet: Optional[Dict[str, Any]] = None,
|
23
|
-
error_message: str = "") -> 'TwitterPostTweetResponseMessage':
|
24
|
-
"""Create a response message for a request to post a new tweet"""
|
25
|
-
return cls.create(
|
26
|
-
topic=RequestMessageTopic.TWITTER_POST_TWEET_RESPONSE, # You'll need to add this to ResponseMessageTopic
|
27
|
-
payload={
|
28
|
-
"success": success,
|
29
|
-
"tweet": tweet,
|
30
|
-
"error_message": error_message
|
31
|
-
},
|
32
|
-
)
|
33
|
-
|
34
|
-
@property
|
35
|
-
def success(self) -> bool:
|
36
|
-
"""Get whether the post tweet operation was successful"""
|
37
|
-
return self.payload.get("success", False)
|
38
|
-
|
39
|
-
@property
|
40
|
-
def tweet(self) -> Optional[Dict[str, Any]]:
|
41
|
-
"""Get the posted tweet data if the operation was successful"""
|
42
|
-
return self.payload.get("tweet", None)
|
43
|
-
|
44
|
-
@property
|
45
|
-
def error_message(self) -> str:
|
46
|
-
"""Get the error message if the post tweet operation failed"""
|
47
|
-
return self.payload.get("error_message", "")
|
@@ -1,48 +0,0 @@
|
|
1
|
-
from dataclasses import dataclass
|
2
|
-
from typing import Type, Dict, Any, TypeVar
|
3
|
-
|
4
|
-
from ..models.request_message_topic import RequestMessageTopic
|
5
|
-
from ...domain.models.hai_message import HaiMessage
|
6
|
-
|
7
|
-
T = TypeVar('T', bound='TwitterQuoteRetweetRequestMessage')
|
8
|
-
|
9
|
-
|
10
|
-
@dataclass
|
11
|
-
class TwitterQuoteRetweetRequestMessage(HaiMessage):
|
12
|
-
"""Message to request creating a quote retweet"""
|
13
|
-
|
14
|
-
@classmethod
|
15
|
-
def create(cls: Type[T], topic: str, payload: Dict[Any, Any]) -> T:
|
16
|
-
"""Create a message - inherited from HaiMessage"""
|
17
|
-
return super().create(topic=topic, payload=payload)
|
18
|
-
|
19
|
-
@classmethod
|
20
|
-
def create_message(cls, tweet_id: str, text: str) -> 'TwitterQuoteRetweetRequestMessage':
|
21
|
-
"""Create a message requesting to quote retweet a tweet"""
|
22
|
-
return cls.create(
|
23
|
-
topic=RequestMessageTopic.TWITTER_QUOTE_RETWEET, # You'll need to add this to RequestMessageTopic
|
24
|
-
payload={
|
25
|
-
"tweet_id": tweet_id,
|
26
|
-
"text": text
|
27
|
-
},
|
28
|
-
)
|
29
|
-
|
30
|
-
@property
|
31
|
-
def tweet_id(self) -> str:
|
32
|
-
"""Get the tweet ID to quote retweet from the payload"""
|
33
|
-
return self.payload.get("tweet_id", "")
|
34
|
-
|
35
|
-
@property
|
36
|
-
def text(self) -> str:
|
37
|
-
"""Get the text content to add to the quote retweet from the payload"""
|
38
|
-
return self.payload.get("text", "")
|
39
|
-
|
40
|
-
@classmethod
|
41
|
-
def from_hai_message(cls, message: HaiMessage) -> 'TwitterQuoteRetweetRequestMessage':
|
42
|
-
"""Create a TwitterQuoteRetweetRequestMessage from a HaiMessage"""
|
43
|
-
payload = message.payload
|
44
|
-
|
45
|
-
return cls.create_message(
|
46
|
-
tweet_id=payload.get("tweet_id", ""),
|
47
|
-
text=payload.get("text", "")
|
48
|
-
)
|
@@ -1,55 +0,0 @@
|
|
1
|
-
from dataclasses import dataclass
|
2
|
-
from typing import Type, Dict, Any, TypeVar, Optional
|
3
|
-
|
4
|
-
from ..models.request_message_topic import RequestMessageTopic
|
5
|
-
from ...domain.models.hai_message import HaiMessage
|
6
|
-
|
7
|
-
T = TypeVar('T', bound='TwitterQuoteRetweetResponseMessage')
|
8
|
-
|
9
|
-
|
10
|
-
@dataclass
|
11
|
-
class TwitterQuoteRetweetResponseMessage(HaiMessage):
|
12
|
-
"""Message to respond to a request to quote retweet a tweet"""
|
13
|
-
|
14
|
-
@classmethod
|
15
|
-
def create(cls: Type[T], topic: str, payload: Dict[Any, Any]) -> T:
|
16
|
-
"""Create a message - inherited from HaiMessage"""
|
17
|
-
return super().create(topic=topic, payload=payload)
|
18
|
-
|
19
|
-
@classmethod
|
20
|
-
def create_message(cls,
|
21
|
-
original_tweet_id: str,
|
22
|
-
success: bool,
|
23
|
-
quote_tweet: Optional[Dict[str, Any]] = None,
|
24
|
-
error_message: str = "") -> 'TwitterQuoteRetweetResponseMessage':
|
25
|
-
"""Create a response message for a request to quote retweet a tweet"""
|
26
|
-
return cls.create(
|
27
|
-
topic=RequestMessageTopic.TWITTER_QUOTE_RETWEET_RESPONSE,
|
28
|
-
# You'll need to add this to ResponseMessageTopic
|
29
|
-
payload={
|
30
|
-
"original_tweet_id": original_tweet_id,
|
31
|
-
"success": success,
|
32
|
-
"quote_tweet": quote_tweet,
|
33
|
-
"error_message": error_message
|
34
|
-
},
|
35
|
-
)
|
36
|
-
|
37
|
-
@property
|
38
|
-
def original_tweet_id(self) -> str:
|
39
|
-
"""Get the original tweet ID that was quote retweeted"""
|
40
|
-
return self.payload.get("original_tweet_id", "")
|
41
|
-
|
42
|
-
@property
|
43
|
-
def success(self) -> bool:
|
44
|
-
"""Get whether the quote retweet operation was successful"""
|
45
|
-
return self.payload.get("success", False)
|
46
|
-
|
47
|
-
@property
|
48
|
-
def quote_tweet(self) -> Optional[Dict[str, Any]]:
|
49
|
-
"""Get the quote tweet data if the operation was successful"""
|
50
|
-
return self.payload.get("quote_tweet", None)
|
51
|
-
|
52
|
-
@property
|
53
|
-
def error_message(self) -> str:
|
54
|
-
"""Get the error message if the quote retweet operation failed"""
|
55
|
-
return self.payload.get("error_message", "")
|
@@ -1,48 +0,0 @@
|
|
1
|
-
from dataclasses import dataclass
|
2
|
-
from typing import Type, Dict, Any, TypeVar
|
3
|
-
|
4
|
-
from ..models.request_message_topic import RequestMessageTopic
|
5
|
-
from ...domain.models.hai_message import HaiMessage
|
6
|
-
|
7
|
-
T = TypeVar('T', bound='TwitterReplyRequestMessage')
|
8
|
-
|
9
|
-
|
10
|
-
@dataclass
|
11
|
-
class TwitterReplyRequestMessage(HaiMessage):
|
12
|
-
"""Message to request replying to a tweet"""
|
13
|
-
|
14
|
-
@classmethod
|
15
|
-
def create(cls: Type[T], topic: str, payload: Dict[Any, Any]) -> T:
|
16
|
-
"""Create a message - inherited from HaiMessage"""
|
17
|
-
return super().create(topic=topic, payload=payload)
|
18
|
-
|
19
|
-
@classmethod
|
20
|
-
def create_message(cls, tweet_id: str, text: str) -> 'TwitterReplyRequestMessage':
|
21
|
-
"""Create a message requesting to reply to a tweet"""
|
22
|
-
return cls.create(
|
23
|
-
topic=RequestMessageTopic.TWITTER_REPLY, # You'll need to add this to RequestMessageTopic
|
24
|
-
payload={
|
25
|
-
"tweet_id": tweet_id,
|
26
|
-
"text": text
|
27
|
-
},
|
28
|
-
)
|
29
|
-
|
30
|
-
@property
|
31
|
-
def tweet_id(self) -> str:
|
32
|
-
"""Get the tweet ID to reply to from the payload"""
|
33
|
-
return self.payload.get("tweet_id", "")
|
34
|
-
|
35
|
-
@property
|
36
|
-
def text(self) -> str:
|
37
|
-
"""Get the text content of the reply from the payload"""
|
38
|
-
return self.payload.get("text", "")
|
39
|
-
|
40
|
-
@classmethod
|
41
|
-
def from_hai_message(cls, message: HaiMessage) -> 'TwitterReplyRequestMessage':
|
42
|
-
"""Create a TwitterReplyRequestMessage from a HaiMessage"""
|
43
|
-
payload = message.payload
|
44
|
-
|
45
|
-
return cls.create_message(
|
46
|
-
tweet_id=payload.get("tweet_id", ""),
|
47
|
-
text=payload.get("text", "")
|
48
|
-
)
|