Skip to content

Commit

Permalink
ALPHA v0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
BeardedTek committed May 31, 2023
1 parent bfecd75 commit dac7bd5
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 16 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Project Specific
*.db
*.db-shm
*.db-wal
config.yaml

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
6 changes: 4 additions & 2 deletions PRE_ALPHA.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ The bot will admonish the offending user with one of your provided quips when th

Careful with blacklisted words because it's just a very basic filter. It only checks that the provided text exists in the message, not the context.

# Install PRE-ALPHA Releases
- Download [dev.beardedtek.scoldbot-v001.mbp](https://github.com/BeardedTek-com/scoldbot/raw/main/dev.beardedtek.scoldbot-v0.0.1.mbp)
# Install ALPHA Releases
- Download one of these:
- [dev.beardedtek.scoldbot-v0.0.1.mbp](https://github.com/BeardedTek-com/scoldbot/raw/main/dev.beardedtek.scoldbot-v0.0.1.mbp)
- [dev.beardedtek.scoldbot-v0.0.2.mbp](https://github.com/BeardedTek-com/scoldbot/raw/main/dev.beardedtek.scoldbot-v0.0.2.mbp) - Only scolds, reworked base
- Open Maubot Manager
- Click the `+` next to Plugins in the sidebar
- Drag the .mbp to the upload area or click on the upload area and select .mbp file
Expand Down
Binary file added dev.beardedtek.scoldbot-v0.0.2.mbp
Binary file not shown.
35 changes: 21 additions & 14 deletions scoldbot/scoldbot.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Dict, List, Type
import random
import tracemalloc

from maubot import MessageEvent, Plugin
from maubot.handlers import event
Expand All @@ -14,6 +15,8 @@ class Config(BaseProxyConfig):
BaseProxyConfig [mautrix.util.config.BaseProxyConfig]
"""
def do_update(self,helper: ConfigUpdateHelper) -> None:
"""Update the config from base-config.yaml
"""
helper.copy("word_lists")
helper.copy("rep-start")
helper.copy("rep-kick")
Expand All @@ -24,12 +27,15 @@ class ScoldBot(Plugin):
Monitors a room to watch for bad / abusive language or behaviour and gives the room members
and admins the tools to deal with it.
"""
def __init__(self):
self.hits = {}

async def start(self) -> None:
"""Kick off the plugin
"""
tracemalloc.start()
self.config.load_and_update()
self.log.info(str(self.config))
self.log.info(self.config)

async def stop(self) -> None:
tracemalloc.stop()


@classmethod
Expand All @@ -52,7 +58,10 @@ async def check_word_lists(self,body):
if item.lower() in body.lower():
self.log.info(f" {item} FOUND in '{body}'")
self.hits[word_list][item] = body
self.hits['count'] += 1
if "count" in self.hits:
self.hits['count'] += 1
else:
self.hits['count'] = 1
return self.hits

async def send_scold(self,evt):
Expand Down Expand Up @@ -80,37 +89,35 @@ async def handle_message(self, evt: MessageEvent) -> None:
# run word_list() for each list we want to check against

#Reset self.hits for each run
self.hits = {
"count" : 0
}
self.hits = {}
for item in self.config['word_lists']:
# Create a dict insode self.hits for each word_list
self.hits[item] = {}
self.check_msg(evt.content.body)
if self.hits['count'] > 0:
self.log.info(str(self.hits))
await self.check_word_lists(evt.content.body)
if "count" in self.hits:
self.log.info(self.hits)
if self.hits['watchword']:
# Send Message to admin
pass

if self.hits['scoldword']:
# Send Message to admin
# Scold User with a reply
self.send_scold(evt)
await self.send_scold(evt)
# -1 from User's Rep

if self.hits['kickword']:
# Send message to admin
# Scold User with a reply
self.send_scold(evt)
await self.send_scold(evt)
# Wait 30 seconds so they can see the reply
# Kick the user
# -5 from User's Rep

if self.hits['autokickword']:
# Send message to admin
# Scold User with a reply
self.send_scold(evt)
await self.send_scold(evt)
# Wait 30 seconds so they can see the reply
# Kick the user
# -10 from User's Rep
Expand Down

0 comments on commit dac7bd5

Please sign in to comment.