Skip to content

Commit

Permalink
fix: remove urls, filter tweets
Browse files Browse the repository at this point in the history
  • Loading branch information
dvilelaf committed Jun 15, 2024
1 parent 13cbd31 commit 3e50da0
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
4 changes: 2 additions & 2 deletions packages/dvilela/agents/tsunami/aea-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ skills:
- valory/transaction_settlement_abci:0.1.0:bafybeic3tccdjypuge2lewtlgprwkbb53lhgsgn7oiwzyrcrrptrbeyote
- valory/registration_abci:0.1.0:bafybeieu7vq3pyns4t5ty6u3sbmpkd7yznpg3rmqifoz3jhy7pmqyg3w6q
- valory/reset_pause_abci:0.1.0:bafybeiameewywqigpupy3u2iwnkfczeiiucue74x2l5lbge74rmw6bgaie
- dvilela/tsunami_abci:0.1.0:bafybeifn6dz7h52fftiphyz2sulhvq6qq7qzzbyynsu5h5vsj5mabsip6a
- dvilela/tsunami_chained_abci:0.1.0:bafybeie6abwbltsjhd47tw545jk3gkoig6t2cwdwtqlz3s5eposkavpssu
- dvilela/tsunami_abci:0.1.0:bafybeidfryx4juivcatexh3hvf4tnz47xkjq4zdqbr3zpfib5pyxj2nkim
- dvilela/tsunami_chained_abci:0.1.0:bafybeia3esvpbzoisefosshyarpo2fpqxjiwwjt7apoad6pdn4c6o72uoe
default_ledger: ethereum
required_ledgers:
- ethereum
Expand Down
2 changes: 1 addition & 1 deletion packages/dvilela/services/tsunami/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license: Apache-2.0
fingerprint:
README.md: bafybeibh5bgshii5oqjfuhwmiivfvfqy7fw5pzvarxkpe4qrgivxtc3xym
fingerprint_ignore_patterns: []
agent: dvilela/tsunami:0.1.0:bafybeic6kbjroomqas4jlvq5m4bsvcbvew3mczcdts576acj63pytprdhy
agent: dvilela/tsunami:0.1.0:bafybeiavcu5fy3g75gpgvweu5nw2x3eyrvwq3z6alsvsrl7tkaykviepaa
number_of_agents: 1
deployment:
agent:
Expand Down
16 changes: 12 additions & 4 deletions packages/dvilela/skills/tsunami_abci/behaviours.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import json
import random
import re
import secrets
from abc import ABC
from collections import Counter
Expand Down Expand Up @@ -115,6 +116,7 @@
OMEN_RUN_HOUR = 15
SUNO_RUN_HOUR = 10
SUNO_RUN_DAY = 4
TWITTER_PIC_URL = r"pic\.twitter\.com\S+"

TRACKED_REPOS = [
"dvilelaf/tsunami",
Expand Down Expand Up @@ -564,6 +566,12 @@ def build_thread(
if footer:
tweet_attempt = tweet_attempt + footer

# Remove hallucinated pic.twitter.com urls
tweet_attempt = re.sub(TWITTER_PIC_URL, "", tweet_attempt)
tweet_attempt = re.sub(
r"\s\s", " ", tweet_attempt
) # replace double spaces with single space

# Create a single-tweet thread
if tweet_len(tweet_attempt) < MAX_TWEET_CHARS:
self.context.logger.info("Tweet is OK!")
Expand Down Expand Up @@ -1672,13 +1680,13 @@ def async_act(self) -> Generator:
response = yield from self.publish_telegram(tweet["text"])
tweet["telegram_published"] = response["success"]

# Remove published tweets
# Keep pending tweets only
tweets = [
t
for t in tweets
if not t["twitter_published"]
or not t["farcaster_published"]
or not t["telegram_published"]
if (self.params.publish_twitter and not t["twitter_published"])
or (self.params.publish_farcaster and not t["farcaster_published"])
or (self.params.publish_telegram and not t["telegram_published"])
]

# Save tweets to the db
Expand Down
2 changes: 1 addition & 1 deletion packages/dvilela/skills/tsunami_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license: Apache-2.0
aea_version: '>=1.0.0, <2.0.0'
fingerprint:
__init__.py: bafybeiaicsttkv5xapta2eqove7si2pyv3zmshkqolluxpnrh3hkulqsqu
behaviours.py: bafybeihnc7ibmhdxkvgaueb2obnefbnynpbcxqb3u2k7mmimqa6tuscxhe
behaviours.py: bafybeiew6hw4jwc6bdcmqbqanxiisoqaj6e4ek5lvjblf36qj6kibhwdbq
dialogues.py: bafybeidmgjji6zw6wcvhijrxb74batj2kc2lskfuqxv76duv2j7azcqwra
fsm_specification.yaml: bafybeidlfuabsldhezjaovupkvzrtydpcimzz6r56phsi2psrtdzougu4u
handlers.py: bafybeigjy73h3uaroovfuuo3ugffrm3oq6pntz5me7nrbsbiwwjceztj5m
Expand Down
2 changes: 1 addition & 1 deletion packages/dvilela/skills/tsunami_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:bafybeiameewywqigpupy3u2iwnkfczeiiucue74x2l5lbge74rmw6bgaie
- valory/transaction_settlement_abci:0.1.0:bafybeic3tccdjypuge2lewtlgprwkbb53lhgsgn7oiwzyrcrrptrbeyote
- valory/termination_abci:0.1.0:bafybeif2zim2de356eo3sipkmoev5emwadpqqzk3huwqarywh4tmqt3vzq
- dvilela/tsunami_abci:0.1.0:bafybeifn6dz7h52fftiphyz2sulhvq6qq7qzzbyynsu5h5vsj5mabsip6a
- dvilela/tsunami_abci:0.1.0:bafybeidfryx4juivcatexh3hvf4tnz47xkjq4zdqbr3zpfib5pyxj2nkim
behaviours:
main:
args: {}
Expand Down
8 changes: 4 additions & 4 deletions packages/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"connection/dvilela/llama/0.1.0": "bafybeiauzzq2pxmn4brdqgdyxrrikbc5ywjpmetlajyohute5qtnn37aqq",
"connection/valory/twitter/0.1.0": "bafybeif6g5sulx4hpm75vt776r6d7obfawsrjom3xq2fsgzdb4d3dssoy4",
"connection/dvilela/suno/0.1.0": "bafybeihy2phtjwbz27ntv55wxfk754kp5tjceujzsdbppjafljoydjflhi",
"skill/dvilela/tsunami_abci/0.1.0": "bafybeifn6dz7h52fftiphyz2sulhvq6qq7qzzbyynsu5h5vsj5mabsip6a",
"skill/dvilela/tsunami_chained_abci/0.1.0": "bafybeie6abwbltsjhd47tw545jk3gkoig6t2cwdwtqlz3s5eposkavpssu",
"agent/dvilela/tsunami/0.1.0": "bafybeic6kbjroomqas4jlvq5m4bsvcbvew3mczcdts576acj63pytprdhy",
"service/dvilela/tsunami/0.1.0": "bafybeifrdlmqlxtwve53cscyxhjpteiirei6qm2ulf2svoltaxphw5p7r4"
"skill/dvilela/tsunami_abci/0.1.0": "bafybeidfryx4juivcatexh3hvf4tnz47xkjq4zdqbr3zpfib5pyxj2nkim",
"skill/dvilela/tsunami_chained_abci/0.1.0": "bafybeia3esvpbzoisefosshyarpo2fpqxjiwwjt7apoad6pdn4c6o72uoe",
"agent/dvilela/tsunami/0.1.0": "bafybeiavcu5fy3g75gpgvweu5nw2x3eyrvwq3z6alsvsrl7tkaykviepaa",
"service/dvilela/tsunami/0.1.0": "bafybeib5kcxyoflseym7qppalo6kgarttashsnhw5h662ovqaoct7iycvu"
},
"third_party": {
"protocol/open_aea/signing/1.0.0": "bafybeihv62fim3wl2bayavfcg3u5e5cxu3b7brtu4cn5xoxd6lqwachasi",
Expand Down

0 comments on commit 3e50da0

Please sign in to comment.