communicator requests api implementation done
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-03-29 20:00:27 +02:00
parent 06671e29b8
commit fe3537ff31
4 changed files with 72 additions and 77 deletions

View File

@ -1,48 +1,46 @@
#!/usr/bin/env python
import logging
import random
import string
from communicator import Communicator
"""
Main Flask RESTful API
Message sender component
"""
__author__ = "@tormakris"
__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):
def __init__(self, communicator: Communicator):
"""
Inicializálja az osztályt.
"""
pass
self.communicator = communicator
def randomString(self, stringLength):
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 createMessage(self, p) -> str:
def sendmessage(self, message: str = "") -> None:
"""
Ez egy metodus
:param szam:
:param szoveg:
Uzenet letrehozasa
:param message:
:return: str tipus
"""
data = self.randomString(p)
return str(data)
pass
if __name__ == "__main__":
temp = MessageSender()
print(temp.createMessage(20))
if not message:
data = self.randomstring(32)
else:
data = message
self.communicator.sendmessage(data)