Example #1
0
    def printSender(self,
                    pad: textpad.Textbox = None,
                    colour: int = None,
                    append: str = None) -> textpad.Textbox:
        """
		Add a Sender to the message.

		Args:
			pad (textpad.Textbox, optional): Defaults to self.pad. The pad to write to.
			colour (int, optional): Defaults to self.senderColour. The colour to write in.
			append (str, optional): Defaults to None. If supplied, appends the string to the pad in the same colour.

		Returns:
			textpad.Textbox: The pad written to.
		"""

        if colour is None: colour = self.senderColour
        if pad is None: pad = self.pad
        try:
            sender = getMember(self.room, self.event['sender']).displayname
        except Exception as e:
            message_logger.error('Exception in printSender: ' + str(e))
            sender = self.event['sender']
        if append is not None: sender += append
        pad.addstr(sender, colour)
        return (pad)
Example #2
0
    def printGeneric(self,
                     text: str,
                     pad: textpad.Textbox = None,
                     colour: int = None) -> textpad.Textbox:
        """
		Print generic text to the message.

		Args:
			text (str): Text to be written
			pad (textpad.Textbox, optional): Defaults to self.pad. The pad to write to.
			colour (int, optional): Defaults to self.contentColour. The colour to write in.

		Returns:
			textpad.Textbox: The pad written to.
		"""

        if colour is None: colour = self.contentColour
        if pad is None: pad = self.pad
        pad.addstr(str(text), colour)
        return (pad)
Example #3
0
    def printOriginTs(self,
                      pad: textpad.Textbox = None,
                      colour: int = None,
                      append: str = None) -> textpad.Textbox:
        """
		Add a timestamp to the message (origin server timestamp).

		Args:
			pad (textpad.Textbox, optional): Defaults to self.pad. The pad to write to.
			colour (int, optional): Defaults to self.tsColour. The colour to write in.
			append (str, optional): Defaults to None. If supplied, appends the string to the pad in the same colour.

		Returns:
			textpad.Textbox: The pad written to.
		"""

        if colour is None: colour = self.tsColour
        if pad is None: pad = self.pad
        ts = tsToDt(str(self.event['origin_server_ts']))
        if append is not None: ts += append
        pad.addstr(ts, colour)
        return (pad)