Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/twikit disable flag #136

Merged
merged 4 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/dvilela/agents/memeooorr/aea-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ connections:
- valory/http_client:0.23.0:bafybeihi772xgzpqeipp3fhmvpct4y6e6tpjp4sogwqrnf3wqspgeilg4u
- valory/ledger:0.19.0:bafybeigntoericenpzvwejqfuc3kqzo2pscs76qoygg5dbj6f4zxusru5e
- valory/p2p_libp2p_client:0.1.0:bafybeid3xg5k2ol5adflqloy75ibgljmol6xsvzvezebsg7oudxeeolz7e
- dvilela/twikit:0.1.0:bafybeidhswexx3x2r3isnr4346i2q5sesdjzaapcajboxlp64fjz5gq4dm
- dvilela/twikit:0.1.0:bafybeidct6ct7jodxpdyhndb3ruxxcqurrh7742v5qjwf6w46g63znakna
- dvilela/mirror_db:0.1.0:bafybeiapsp6k5l2qxzvyosie4dpnfywrwdcwzqxtoi6x6g3xfmdviov2he
- dvilela/kv_store:0.1.0:bafybeiekugvb2kan4342hliluxl3h5och3fjwqoafdyttpcn57evvyztq4
- valory/http_server:0.22.0:bafybeihpgu56ovmq4npazdbh6y6ru5i7zuv6wvdglpxavsckyih56smu7m
Expand Down Expand Up @@ -42,8 +42,8 @@ skills:
- valory/transaction_settlement_abci:0.1.0:bafybeigh2vkt74jrad5gtsczrgqcuhcqe7jkgjy7jdw56yamlzwwnaymjy
- valory/registration_abci:0.1.0:bafybeib3n6vqkfbrcubcbliebjnuwyywdinxkbzt76n6gbn2kg7ace47dq
- valory/reset_pause_abci:0.1.0:bafybeihkj6lmaypspyxe5qqrjgnolyck62pyvqoylr24ab6ue4steqcw7e
- dvilela/memeooorr_abci:0.1.0:bafybeiffr2uyofrv5xupczpgx6tdlggz7ttxfoo7bqhddiz6ioj2tem3oa
- dvilela/memeooorr_chained_abci:0.1.0:bafybeihj6q7bwzlw53r46bjtvn5madadevfy3dobj7tk6ok2ovf2yredci
- dvilela/memeooorr_abci:0.1.0:bafybeie57n6k6rh6xclojtgbkes7urfjfvp4ti36apkemgubeuknxt4esy
- dvilela/memeooorr_chained_abci:0.1.0:bafybeihcyzelyljdntelerodosdyeup7tp76mungfnzj5fknnumt2s2pni
default_ledger: ethereum
required_ledgers:
- ethereum
Expand Down
17 changes: 15 additions & 2 deletions packages/dvilela/connections/twikit/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,12 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # pragma: no cover
)
self.cookies = json.loads(cookies_str) if cookies_str else None
self.disable_tweets = self.configuration.config.get("twikit_disable_tweets")
self.client = twikit.Client(language="en-US")
self.skip_connection = self.configuration.config.get("twikit_skip_connection")
if not self.skip_connection:
self.client = twikit.Client(language="en-US")
else:
self.logger.info("Twikit connecion is disabled.")
self.client = None
self.last_call = datetime.now(timezone.utc)

self.dialogues = SrrDialogues(connection_id=PUBLIC_ID)
Expand All @@ -133,7 +138,8 @@ def response_envelopes(self) -> asyncio.Queue:
async def connect(self) -> None:
"""Connect to a HTTP server."""
self._response_envelopes = asyncio.Queue()
await self.twikit_login()
if not self.skip_connection:
await self.twikit_login()
self.state = ConnectionStates.connected

async def disconnect(self) -> None:
Expand Down Expand Up @@ -223,6 +229,13 @@ async def _get_response(
f"Performative `{srr_message.performative.value}` is not supported.",
)

if self.skip_connection:
return self.prepare_error_message(
srr_message,
dialogue,
"Connection is disabled. Set TWIKIT_SKIP_CONNECTION=false to enable it.",
)

payload = json.loads(srr_message.payload)

REQUIRED_PROPERTIES = ["method", "kwargs"]
Expand Down
3 changes: 2 additions & 1 deletion packages/dvilela/connections/twikit/connection.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license: Apache-2.0
aea_version: '>=1.0.0, <2.0.0'
fingerprint:
__init__.py: bafybeiaism4qxp36o6dflr3emtu4hk37dw7evimcoqkvlvt5s42af5lr5m
connection.py: bafybeig4rtpvlrjnupiwsyk7phhr3lnc3kh4gtnmokb57befetmu4ouioa
connection.py: bafybeib3azbngtrm5yf2mztwhxvbb6l363cdjy3l4h4hvetyooqxiemgti
readme.md: bafybeihl7k3yi3twtvlkjntaknmib6hnhmyjurn25c4nksffcagrwkx5t4
fingerprint_ignore_patterns: []
connections: []
Expand All @@ -21,6 +21,7 @@ config:
twikit_cookies: null
twikit_cookies_path: /tmp/twikit_cookies.json
twikit_disable_tweets: false
twikit_skip_connection: false
excluded_protocols: []
restricted_to_protocols: []
dependencies:
Expand Down
4 changes: 3 additions & 1 deletion packages/dvilela/services/memeooorr/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license: Apache-2.0
fingerprint:
README.md: bafybeiaekcmielp6mb4qvmo2twwkpmoun36bqajrh7wnnkcpdnia45ycl4
fingerprint_ignore_patterns: []
agent: dvilela/memeooorr:0.1.0:bafybeicxj3fr52cfgreis6qmt6uje4nrzrxia7eqpxwpd52nxlbryna65u
agent: dvilela/memeooorr:0.1.0:bafybeifh5cmfi4f44xzbzkzwtg7pzvru22bxwk3dzwidkadxmfwtpd5u34
number_of_agents: 1
deployment:
agent:
Expand Down Expand Up @@ -158,6 +158,8 @@ config:
twikit_password: ${TWIKIT_PASSWORD:str:null}
twikit_cookies: ${TWIKIT_COOKIES:str:null}
twikit_cookies_path: ${TWIKIT_COOKIES_PATH:str:/tmp/twikit_cookies.json}
twikit_disable_tweets: ${TWIKIT_DISABLE_TWEETS:bool:false}
twikit_skip_connection: ${TWIKIT_SKIP_CONNECTION:bool:false}
---
public_id: dvilela/kv_store:0.1.0
type: connection
Expand Down
2 changes: 1 addition & 1 deletion packages/dvilela/skills/memeooorr_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fingerprint:
fingerprint_ignore_patterns: []
connections:
- dvilela/kv_store:0.1.0:bafybeiekugvb2kan4342hliluxl3h5och3fjwqoafdyttpcn57evvyztq4
- dvilela/twikit:0.1.0:bafybeidhswexx3x2r3isnr4346i2q5sesdjzaapcajboxlp64fjz5gq4dm
- dvilela/twikit:0.1.0:bafybeidct6ct7jodxpdyhndb3ruxxcqurrh7742v5qjwf6w46g63znakna
- dvilela/mirror_db:0.1.0:bafybeiapsp6k5l2qxzvyosie4dpnfywrwdcwzqxtoi6x6g3xfmdviov2he
- dvilela/genai:0.1.0:bafybeidkxxlonrxirznivkmzc34wmby4e4s57rfg2b7k6xyos23g3y6cdy
- valory/http_server:0.22.0:bafybeihpgu56ovmq4npazdbh6y6ru5i7zuv6wvdglpxavsckyih56smu7m
Expand Down
2 changes: 1 addition & 1 deletion packages/dvilela/skills/memeooorr_chained_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ skills:
- valory/reset_pause_abci:0.1.0:bafybeihkj6lmaypspyxe5qqrjgnolyck62pyvqoylr24ab6ue4steqcw7e
- valory/transaction_settlement_abci:0.1.0:bafybeigh2vkt74jrad5gtsczrgqcuhcqe7jkgjy7jdw56yamlzwwnaymjy
- valory/termination_abci:0.1.0:bafybeifi2uodnrjsrivj53g3sjutocmyusbx6mlsb6oanqdyt2mfbyvusy
- dvilela/memeooorr_abci:0.1.0:bafybeiffr2uyofrv5xupczpgx6tdlggz7ttxfoo7bqhddiz6ioj2tem3oa
- dvilela/memeooorr_abci:0.1.0:bafybeie57n6k6rh6xclojtgbkes7urfjfvp4ti36apkemgubeuknxt4esy
behaviours:
main:
args: {}
Expand Down
10 changes: 5 additions & 5 deletions packages/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"dev": {
"contract/dvilela/meme_factory/0.1.0": "bafybeiawl5cqtlbm7vrh7ah3iubzjh7ycjhem27xz24ssyhnwnmqaunwee",
"contract/dvilela/service_registry/0.1.0": "bafybeie2rrgzcjehlp2feff6bhkuindxzrnuwxe2jcrsy2thcdtrsp2o24",
"connection/dvilela/twikit/0.1.0": "bafybeidhswexx3x2r3isnr4346i2q5sesdjzaapcajboxlp64fjz5gq4dm",
"connection/dvilela/twikit/0.1.0": "bafybeidct6ct7jodxpdyhndb3ruxxcqurrh7742v5qjwf6w46g63znakna",
"connection/dvilela/mirror_db/0.1.0": "bafybeiapsp6k5l2qxzvyosie4dpnfywrwdcwzqxtoi6x6g3xfmdviov2he",
"connection/dvilela/genai/0.1.0": "bafybeidkxxlonrxirznivkmzc34wmby4e4s57rfg2b7k6xyos23g3y6cdy",
"skill/dvilela/memeooorr_abci/0.1.0": "bafybeiffr2uyofrv5xupczpgx6tdlggz7ttxfoo7bqhddiz6ioj2tem3oa",
"skill/dvilela/memeooorr_chained_abci/0.1.0": "bafybeihj6q7bwzlw53r46bjtvn5madadevfy3dobj7tk6ok2ovf2yredci",
"agent/dvilela/memeooorr/0.1.0": "bafybeicxj3fr52cfgreis6qmt6uje4nrzrxia7eqpxwpd52nxlbryna65u",
"service/dvilela/memeooorr/0.1.0": "bafybeig5h3el4kz3o7epnwtuvzhlojlgcpw3rlkmnqt5xjc6dnyio2afqi"
"skill/dvilela/memeooorr_abci/0.1.0": "bafybeie57n6k6rh6xclojtgbkes7urfjfvp4ti36apkemgubeuknxt4esy",
"skill/dvilela/memeooorr_chained_abci/0.1.0": "bafybeihcyzelyljdntelerodosdyeup7tp76mungfnzj5fknnumt2s2pni",
"agent/dvilela/memeooorr/0.1.0": "bafybeifh5cmfi4f44xzbzkzwtg7pzvru22bxwk3dzwidkadxmfwtpd5u34",
"service/dvilela/memeooorr/0.1.0": "bafybeihwue2xtpvzjc6refapyxgm552rwfhzmtaelgu3cv4lxwecd2g6le"
},
"third_party": {
"protocol/open_aea/signing/1.0.0": "bafybeihv62fim3wl2bayavfcg3u5e5cxu3b7brtu4cn5xoxd6lqwachasi",
Expand Down
3 changes: 2 additions & 1 deletion scripts/aea-config-replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
"config/twikit_password": "TWIKIT_PASSWORD",
"config/twikit_cookies": "TWIKIT_COOKIES",
"config/twikit_cookies_path": "TWIKIT_COOKIES_PATH",
"config/twikit_disable_tweets": "DISABLE_TWEETS",
"config/twikit_disable_tweets": "TWIKIT_DISABLE_TWEETS",
"config/twikit_skip_connection": "TWIKIT_SKIP_CONNECTION",
# Genai connection
"config/genai_api_key": "GENAI_API_KEY",
# DB
Expand Down
Loading