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

feat(core): add more streamelements listeners #197

Merged
merged 2 commits into from
May 3, 2022
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
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