#!/usr/bin/env python import logging import random import string from communicator import Communicator """ Message sender component """ __author__ = "@kovacsbence" __copyright__ = "Copyright 2020, GoldenPogácsa Team" __module_name__ = "messagesender" __version__text__ = "1" logging.basicConfig(level=logging.INFO) LOGGER = logging.getLogger(__name__) class MessageSender: """ Üzenetek küldéséért felelős komponens. """ def __init__(self, communicator: Communicator): """ Inicializálja az osztályt. """ self.communicator = communicator def randomstring(self, stringLength) -> str: """Generate a random string of fixed length """ 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 """ if not message: data = self.randomstring(32) else: data = message self.communicator.sendmessage(data)