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

detect spammy messages instead #321

Merged
merged 1 commit into from
Sep 8, 2024
Merged
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
9 changes: 4 additions & 5 deletions bot/skills/towel_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,9 @@ def is_worthy(text: str) -> bool:
return False

prompt = """You are a spam-fighting bot, guarding chat room from bad actors and advertisement.
All new chat members are asked to say a few words about themselves (e.g. who are you, where are you from and what do you do for a living?).
Can the text sent by the user be considered a worthy short bio?
Any other text that is not meant to make an introduction is considered unworthy.
Answer with a single word: worthy or unworthy."""
Next message is the first message of the user in the chat. If it is an advertisement, user should be banned.
Can the text sent by the user be considered an advertisement or spam?
Answer with a single word: spam or legit."""

response = openai.chat.completions.create(
model="gpt-4o-mini",
Expand All @@ -227,7 +226,7 @@ def is_worthy(text: str) -> bool:

logger.info("text: %s is %s", text, response.choices[0].message.content)

return response.choices[0].message.content == "worthy"
return response.choices[0].message.content != "spam"


def quarantine_filter(update: Update, context: CallbackContext):
Expand Down
Loading