Skip to content

Commit

Permalink
Created new utils module
Browse files Browse the repository at this point in the history
  • Loading branch information
thelabcat committed Aug 12, 2024
1 parent e674d0e commit 885693c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/rumchat_actor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def eat_some_cheese(message, actor):
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from . import actions, commands, misc
from . import actions, commands, misc, utils
from .localvars import *

class RumbleChatActor():
Expand Down Expand Up @@ -212,7 +212,7 @@ def __init__(self, init_message = "Hello, Rumble!", ignore_users = ["TheRumbleBo
while (m := self.ssechat.get_message()).user.username != self.username:
pass

assert misc.is_staff(m.user), \
assert utils.is_staff(m.user), \
"Actor cannot function without being channel staff"

#Functions that are to be called on each message,
Expand Down
8 changes: 4 additions & 4 deletions src/rumchat_actor/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from selenium.webdriver.common.by import By
import talkey
from .localvars import *
from . import misc
from . import misc, utils

class ChatCommand():
"""Chat command abstract class"""
Expand Down Expand Up @@ -797,7 +797,7 @@ def remove_entry(self, message):
removal = segs[2].removesuffix("@")

#Non-staff is trying to remove someone besides themselves
if not misc.is_staff(message.user) and removal != message.user.username:
if not utils.is_staff(message.user) and removal != message.user.username:
#self.actor.send_message(f"@{message.user.username} You cannot remove another user from the raffle since you are not staff.")
print(f"{message.user.username} Tried to remove {removal} from the raffle without the authority to do so.")
return
Expand All @@ -816,7 +816,7 @@ def count_entries(self, message):

def draw_entry(self, message):
"""Draw a winner"""
if not misc.is_staff(message.user):
if not utils.is_staff(message.user):
print(f"{message.user.username} tried to draw a raffle winner without the authority to do so.")
return

Expand All @@ -837,7 +837,7 @@ def report_winner(self, message):

def reset(self, message):
"""Reset the raffle"""
if not misc.is_staff(message.user):
if not utils.is_staff(message.user):
print(f"{message.user.username} tried to reset the raffle without the authority to do so.")
return

Expand Down
4 changes: 0 additions & 4 deletions src/rumchat_actor/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,3 @@ def run(self):

#Wait a bit, either the Rumble API refresh rate or the message sending cooldown
time.sleep(max((self.rum_api.refresh_rate, SEND_MESSAGE_COOLDOWN)))

def is_staff(user):
"""Check if a user is channel staff"""
return True in [badge in user.badges for badge in STAFF_BADGES]

0 comments on commit 885693c

Please sign in to comment.