Added/update docstring

This commit is contained in:
2020-04-06 20:48:36 +02:00
parent 64f7d9b83e
commit 9040cf898b
5 changed files with 115 additions and 43 deletions

View File

@ -19,25 +19,31 @@ LOGGER = logging.getLogger(__name__)
class MessageSender:
"""
Üzenetek küldéséért felelős komponens.
Component responsible for sending the messages. Requires an instance of :class:'communicator.Communicator'
"""
def __init__(self, communicator: Communicator):
"""
Inicializálja az osztályt.
"""Initializes the object.
:param: communicator: an instance of :class:'communicator.Communicator'
"""
self.communicator = communicator
def randomstring(self, stringlength: int) -> str:
"""Generate a random string of fixed length """
"""
Generate a random string of fixed length
:param stringlength: the length of the string
:return: the generated string
"""
letters = string.ascii_lowercase
return ''.join(random.choice(letters) for i in range(stringlength))
def sendmessage(self, message: str = "") -> None:
"""
Uzenet letrehozasa
:param message:
:return: str tipus
"""Sends the given message.
If the message is omitted (empty), then a random message will be generated with length 23 (with
:func:'~messagesender.MessageSender.randomstring'. Calls :func:'~communicator.Communicator.sendmessage'
to send the message.
:param message: the message of type string that will be sent
:return: None
"""
if not message:
data = self.randomstring(32)