Cleanup event base definitions

This commit is contained in:
Derek Schmidt 2021-12-14 18:11:19 -07:00
parent 3256b145f9
commit 9289ec4006
6 changed files with 34 additions and 27 deletions
chats/Twitch/sources
events
plugins

View file

@ -9,7 +9,7 @@ from miniirc import ircv3_message_parser
from PIL import Image
from events.Message import Message, USER_TYPE
from events.Subscription import Subscription
from events import Subscription
from .NonBlockingWebsocket import NonBlockingWebsocket
from ..Events import Raid

13
events/Delete.py Normal file
View file

@ -0,0 +1,13 @@
from dataclasses import dataclass, asdict
from . import Event
@dataclass
class Delete(Event):
target_id: int
show_masked: bool = False
reason: str = None
def to_dict(self):
return asdict(self)

14
events/EventBase.py Normal file
View file

@ -0,0 +1,14 @@
import random
from dataclasses import dataclass, field, asdict
@dataclass
class Event:
via: str
timestamp: float
id: int = field(default_factory=lambda: random.getrandbits(32), init=False)
# TODO: Needs a raw data field and timestamp to default to time.time().
# This depends on the kw_only feature coming in python 3.10
def to_dict(self):
return asdict(self)

View file

@ -1,24 +1,4 @@
import random
from dataclasses import dataclass, field, asdict
@dataclass
class Delete:
id: int
show_masked: bool = False
reason: str = None
def to_dict(self):
return asdict(self)
@dataclass
class Event:
via: str
timestamp: float
id: int = field(default_factory=lambda: random.getrandbits(32), init=False)
# TODO: Needs a raw data field and timestamp to default to time.time().
# This depends on the kw_only feature coming in python 3.10
def to_dict(self):
return asdict(self)
from .EventBase import Event
from .Message import Message
from .Delete import Delete
from .Subscription import Subscription

View file

@ -1,5 +1,5 @@
from plugins import PluginBase, TriggerInterface
from events.Message import Message
from events import Message
class InfoPlugin(PluginBase, TriggerInterface):

View file

@ -1,5 +1,5 @@
from plugins import PluginBase
from events.Message import Message
from events import Message
from .Formatter import PhraseCountFormatter