diff --git a/plugins/acp/acp_plugin_gamesdk/acp_plugin.py b/plugins/acp/acp_plugin_gamesdk/acp_plugin.py index 77facf26..4d407068 100644 --- a/plugins/acp/acp_plugin_gamesdk/acp_plugin.py +++ b/plugins/acp/acp_plugin_gamesdk/acp_plugin.py @@ -57,7 +57,10 @@ def __init__(self, options: AcpPluginOptions): """ self.cluster = options.cluster self.evaluator_cluster = options.evaluator_cluster - self.twitter_plugin = options.twitter_plugin + self.twitter_plugin = None + if (options.twitter_plugin is not None): + self.twitter_plugin = options.twitter_plugin + self.produced_inventory: List[IInventory] = [] self.acp_base_url = self.acp_token_client.acp_base_url if self.acp_token_client.acp_base_url is None else "https://acpx-staging.virtuals.io/api" if (options.on_evaluate is not None): @@ -72,7 +75,6 @@ def initializeSocket(self) -> Tuple[bool, str]: Returns a tuple of (success, message). """ try: - print("Initializing socket after") self.socket = socketio.Client() # Set up authentication before connecting @@ -252,7 +254,7 @@ def initiate_job(self) -> Function: args = [seller_wallet_address_arg, price_arg, reasoning_arg, service_requirements_arg, require_evaluation_arg, evaluator_keyword_arg] - if self.twitter_plugin is not None: + if hasattr(self, 'twitter_plugin') and self.twitter_plugin is not None: tweet_content_arg = Argument( name="tweetContent", type="string", @@ -304,7 +306,7 @@ def _initiate_job_executable(self, sellerWalletAddress: str, price: str, reasoni evaluatorAddress ) - if (self.twitter_plugin is not None and tweetContent is not None): + if (hasattr(self, 'twitter_plugin') and self.twitter_plugin is not None and tweetContent is not None): post_tweet_fn = self.twitter_plugin.get_function('post_tweet') tweet_id = post_tweet_fn(tweetContent, None).get('data', {}).get('id') if (tweet_id is not None): @@ -343,7 +345,7 @@ def respond_job(self) -> Function: args = [job_id_arg, decision_arg, reasoning_arg] - if self.twitter_plugin is not None: + if hasattr(self, 'twitter_plugin') and self.twitter_plugin is not None: tweet_content_arg = Argument( name="tweetContent", type="string", @@ -389,7 +391,7 @@ def _respond_job_executable(self, jobId: int, decision: str, reasoning: str, twe reasoning ) - if (self.twitter_plugin is not None and tweetContent is not None): + if (hasattr(self, 'twitter_plugin') and self.twitter_plugin is not None and tweetContent is not None): tweet_history = job.get("tweetHistory", []) tweet_id = tweet_history[-1].get("tweetId") if tweet_history else None if (tweet_id is not None): @@ -429,7 +431,7 @@ def pay_job(self) -> Function: args = [job_id_arg, amount_arg, reasoning_arg] - if self.twitter_plugin is not None: + if hasattr(self, 'twitter_plugin') and self.twitter_plugin is not None: tweet_content_arg = Argument( name="tweetContent", type="string", @@ -476,7 +478,7 @@ def _pay_job_executable(self, jobId: int, amount: float, reasoning: str, tweetCo reasoning ) - if (self.twitter_plugin is not None and tweetContent is not None): + if (hasattr(self, 'twitter_plugin') and self.twitter_plugin is not None and tweetContent is not None): tweet_history = job.get("tweetHistory", []) tweet_id = tweet_history[-1].get("tweetId") if tweet_history else None if (tweet_id is not None): @@ -522,7 +524,7 @@ def deliver_job(self) -> Function: args = [job_id_arg, deliverable_type_arg, deliverable_arg, reasoning_arg] - if self.twitter_plugin is not None: + if hasattr(self, 'twitter_plugin') and self.twitter_plugin is not None: tweet_content_arg = Argument( name="tweetContent", type="string", @@ -579,7 +581,8 @@ def _deliver_job_executable(self, jobId: int, deliverableType: str, deliverable: json.dumps(deliverable), ) - if (self.twitter_plugin is not None and tweetContent is not None): + if (hasattr(self, 'twitter_plugin') and self.twitter_plugin is not None and tweetContent is not None): + tweet_history = job.get("tweetHistory", []) tweet_id = tweet_history[-1].get("tweetId") if tweet_history else None if (tweet_id is not None):