Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Commit

Permalink
feat(core): add more streamelements listeners (#197)
Browse files Browse the repository at this point in the history
* feat(core): add more streamelements listeners

- now supports tips/cheers/resubscription notices
  • Loading branch information
mmattbtw authored May 3, 2022
1 parent 890a565 commit 3820d0d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [v3.1.0](https://github.com/mmattDonk/AI-TTS-Donations/releases/tag/v3.1.0)
- [minor]: feat(limits): added `BLACKLISTED_VOICES` limit (https://github.com/mmattDonk/AI-TTS-Donations/pull/196)
- [minor]: feat(core): add more streamelements listeners (https://github.com/mmattDonk/AI-TTS-Donations/pull/197)
- [patch]: fix(core): fix some config errors and streamelements errors

## [v3.0.1](https://github.com/mmattDonk/AI-TTS-Donations/releases/tag/v3.0.1)
Expand Down
24 changes: 21 additions & 3 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,9 +518,7 @@ def connect():
def on_streamelements_event(data, *args):
log.debug(data)

if data["listener"] == "tip-latest" and data["event"]["amount"] >= int(
config["MIN_TIP_AMOUNT"]
):
def check_message(data) -> None:
message: str = data["event"]["message"]

if len(message) > config["MAX_MSG_LENGTH"]:
Expand All @@ -532,8 +530,28 @@ def on_streamelements_event(data, *args):
log.info("Blacklisted word found")
return

if data["listener"] == "cheer-latest":
message = re.sub(
CHEER_REGEX,
"",
message,
)

request_tts(message=message, failed=False)

if data["listener"] == "tip-latest" and data["event"]["amount"] >= int(
config["MIN_TIP_AMOUNT"]
):
check_message(data)

elif data["listener"] == "cheer-latest" and data["event"]["amount"] >= int(
config["MIN_BIT_AMOUNT"]
):
check_message(data)

elif data["listener"] == "subscriber-latest" and data["event"]["amount"] >= 2:
check_message(data)


def on_streamelements_authenticated(data):
log.debug(data)
Expand Down

0 comments on commit 3820d0d

Please sign in to comment.