Skip to content

Commit ec59ed5

Browse files
authored
Merge pull request #132 from stevensf1998/feat/acp
Feat/acp
2 parents ba7fccb + 5f65834 commit ec59ed5

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

plugins/acp/acp_plugin_gamesdk/acp_plugin.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ def __init__(self, options: AcpPluginOptions):
5757
"""
5858
self.cluster = options.cluster
5959
self.evaluator_cluster = options.evaluator_cluster
60-
self.twitter_plugin = options.twitter_plugin
60+
self.twitter_plugin = None
61+
if (options.twitter_plugin is not None):
62+
self.twitter_plugin = options.twitter_plugin
63+
6164
self.produced_inventory: List[IInventory] = []
6265
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"
6366
if (options.on_evaluate is not None):
@@ -72,7 +75,6 @@ def initializeSocket(self) -> Tuple[bool, str]:
7275
Returns a tuple of (success, message).
7376
"""
7477
try:
75-
print("Initializing socket after")
7678
self.socket = socketio.Client()
7779

7880
# Set up authentication before connecting
@@ -252,7 +254,7 @@ def initiate_job(self) -> Function:
252254

253255
args = [seller_wallet_address_arg, price_arg, reasoning_arg, service_requirements_arg, require_evaluation_arg, evaluator_keyword_arg]
254256

255-
if self.twitter_plugin is not None:
257+
if hasattr(self, 'twitter_plugin') and self.twitter_plugin is not None:
256258
tweet_content_arg = Argument(
257259
name="tweetContent",
258260
type="string",
@@ -304,7 +306,7 @@ def _initiate_job_executable(self, sellerWalletAddress: str, price: str, reasoni
304306
evaluatorAddress
305307
)
306308

307-
if (self.twitter_plugin is not None and tweetContent is not None):
309+
if (hasattr(self, 'twitter_plugin') and self.twitter_plugin is not None and tweetContent is not None):
308310
post_tweet_fn = self.twitter_plugin.get_function('post_tweet')
309311
tweet_id = post_tweet_fn(tweetContent, None).get('data', {}).get('id')
310312
if (tweet_id is not None):
@@ -343,7 +345,7 @@ def respond_job(self) -> Function:
343345

344346
args = [job_id_arg, decision_arg, reasoning_arg]
345347

346-
if self.twitter_plugin is not None:
348+
if hasattr(self, 'twitter_plugin') and self.twitter_plugin is not None:
347349
tweet_content_arg = Argument(
348350
name="tweetContent",
349351
type="string",
@@ -389,7 +391,7 @@ def _respond_job_executable(self, jobId: int, decision: str, reasoning: str, twe
389391
reasoning
390392
)
391393

392-
if (self.twitter_plugin is not None and tweetContent is not None):
394+
if (hasattr(self, 'twitter_plugin') and self.twitter_plugin is not None and tweetContent is not None):
393395
tweet_history = job.get("tweetHistory", [])
394396
tweet_id = tweet_history[-1].get("tweetId") if tweet_history else None
395397
if (tweet_id is not None):
@@ -429,7 +431,7 @@ def pay_job(self) -> Function:
429431

430432
args = [job_id_arg, amount_arg, reasoning_arg]
431433

432-
if self.twitter_plugin is not None:
434+
if hasattr(self, 'twitter_plugin') and self.twitter_plugin is not None:
433435
tweet_content_arg = Argument(
434436
name="tweetContent",
435437
type="string",
@@ -476,7 +478,7 @@ def _pay_job_executable(self, jobId: int, amount: float, reasoning: str, tweetCo
476478
reasoning
477479
)
478480

479-
if (self.twitter_plugin is not None and tweetContent is not None):
481+
if (hasattr(self, 'twitter_plugin') and self.twitter_plugin is not None and tweetContent is not None):
480482
tweet_history = job.get("tweetHistory", [])
481483
tweet_id = tweet_history[-1].get("tweetId") if tweet_history else None
482484
if (tweet_id is not None):
@@ -522,7 +524,7 @@ def deliver_job(self) -> Function:
522524

523525
args = [job_id_arg, deliverable_type_arg, deliverable_arg, reasoning_arg]
524526

525-
if self.twitter_plugin is not None:
527+
if hasattr(self, 'twitter_plugin') and self.twitter_plugin is not None:
526528
tweet_content_arg = Argument(
527529
name="tweetContent",
528530
type="string",
@@ -579,7 +581,8 @@ def _deliver_job_executable(self, jobId: int, deliverableType: str, deliverable:
579581
json.dumps(deliverable),
580582
)
581583

582-
if (self.twitter_plugin is not None and tweetContent is not None):
584+
if (hasattr(self, 'twitter_plugin') and self.twitter_plugin is not None and tweetContent is not None):
585+
583586
tweet_history = job.get("tweetHistory", [])
584587
tweet_id = tweet_history[-1].get("tweetId") if tweet_history else None
585588
if (tweet_id is not None):

0 commit comments

Comments
 (0)