示例#1
0
 def loadDefaultMessages(self):
     if messagebox.askokcancel("Restore Default Messages", "Are you sure you want to restore the default messages for StreamTicker?", parent=self):
         self.messages = [Message("StreamTicker", 1, [MessagePart("Pixel Gap", 1, "8"),
                                                      MessagePart("Image", 2, "imagefiles/stLogo28.png"),
                                                      MessagePart("Pixel Gap", 3, "8"),
                                                      MessagePart("Text", 4, "StreamTicker")]),
                          Message("StreamTicker", 2, [MessagePart("Pixel Gap", 1, "8"),
                                                      MessagePart("Image", 2, "imagefiles/stLogo28.png"),
                                                      MessagePart("Pixel Gap", 3, "8"),
                                                      MessagePart("Text", 4, "Made by Go1den")])]
示例#2
0
def _rec_superdense(packet):
    """
    Receives a superdense qubit and decodes it.

    Args:
       packet (Packet): The packet in which to receive.

    Returns:
        dict: A dictionary consisting of decoded superdense message and sequence number
    """
    receiver = packet.receiver
    sender = packet.sender
    payload = packet.payload

    host_receiver = network.get_host(receiver)

    q1 = host_receiver.get_data_qubit(sender, payload.id, wait=WAIT_TIME)
    # the shared EPR id is the DATA id without the first letter.
    q2 = host_receiver.get_epr(sender, payload.id[1:], wait=WAIT_TIME)

    assert q1 is not None and q2 is not None

    # Send ACK if seq_num is not -1
    if packet.seq_num != -1:
        _send_ack(packet.sender, packet.receiver, packet.seq_num)

    return Message(packet.sender, _decode_superdense(q1, q2), packet.seq_num)
示例#3
0
def _rec_classical(packet):
    """
    Receives a classical message packet , parses it into sequence number and message and sends an
    ACK message to receiver.

    Args:
        packet (Packet): The packet in which to receive.

    Returns:
        dict : A dictionary consisting of 'message' and 'sequence number'
    """
    message = packet.payload
    if packet.payload.content == ACK:
        message = Message(sender=packet.sender,
                          content=ACK,
                          seq_num=packet.seq_num)
        Logger.get_instance().log(packet.receiver + " received ACK from " +
                                  packet.sender + " with sequence number " +
                                  str(packet.seq_num))
    else:
        # Send an ACK msg if seq_num is not -1, as long as not an ACK msg!
        if packet.seq_num != -1:
            _send_ack(packet.sender, packet.receiver, packet.seq_num)

    return message
示例#4
0
    def getMessages(self, path) -> list[Message]:
        messagesAsJSON = readJSON(path)
        messages = []
        for message in messagesAsJSON:
            sortOrder = message["sortOrder"]
            nickname = message["nickname"]
            parts = []
            for part in message["parts"]:
                partType = part["partType"]
                partSortOrder = part["sortOrder"]
                partValue = part["value"]
                parts.append(MessagePart(partType, partSortOrder, partValue))

            overrides = message.get("overrides", {})
            override = Override(overrides.get("duration", ""),
                                overrides.get("intermission", ""),
                                overrides.get("scrollSpeed", ""),
                                overrides.get("font", ""),
                                overrides.get("fontSize", ""),
                                overrides.get("fontColor", ""),
                                overrides.get("arrival", ""),
                                overrides.get("departure", ""),
                                overrides.get("bold", False),
                                overrides.get("italic", False),
                                overrides.get("overstrike", False))
            messages.append(Message(nickname, sortOrder, parts, override))
        return messages
 def create_message(self,
                    username,
                    path,
                    tile_directory=None,
                    enlargement=1,
                    tile_size=8,
                    tile_rescale=1.0,
                    threads=3,
                    img_type='L',
                    max_repeats=0,
                    method='euclid',
                    frame_duration=0.1,
                    mode='I'):
     tile_directory = self.set_tile_directory(tile_directory)
     path_pairs, total_frames, cleanup_kwargs = self.setup_image(
         path, frame_duration, mode, username)
     save_intermediates = not path.lower().endswith('gif')
     kwargs = {
         'enlargement': enlargement,
         'tile_size': tile_size,
         'tile_rescale': tile_rescale,
         'threads': threads,
         'img_type': img_type,
         'max_repeats': max_repeats,
         'method': method,
         'save_intermediates': save_intermediates
     }
     jobs = self.build_jobs(path_pairs, tile_directory, kwargs)
     poll_args = [cleanup, jobs, cleanup_kwargs, self.DEFAULT_TIMEOUT]
     self.redis_accessor.submit_job(poll_jobs, args=poll_args)
     message = Message(path, total_frames, self.DEFAULT_TIMEOUT)
     return message
示例#6
0
 def _get_messages(self):
     messages = [
         Message(random.choice(MESSAGES), candidate, voter)
         for candidate in self.candidates for voter in self._voters
     ]
     random.shuffle(messages)
     return messages[:6]
示例#7
0
    def __init__(self, listFrame, message: Message, index: int):
        self.master = Toplevel(listFrame.window.master)
        self.master.withdraw()
        self.listFrame = listFrame
        self.parent = listFrame.window.master
        self.parentWindow = listFrame.window
        self.message = deepcopy(message)
        if not self.message:
            self.isNewMessage = True
            self.message = Message()
        else:
            self.isNewMessage = False
        self.message.sortParts()
        self.index = index
        self.master.geometry('+{x}+{y}'.format(x=self.parent.winfo_x() + 10, y=self.parent.winfo_y() + 10))
        self.master.wm_attributes("-topmost", 1)
        self.master.focus_force()
        self.master.wm_title("StreamTicker Message Maker")
        self.master.iconbitmap("imagefiles/stIcon.ico")
        self.master.resizable(False, False)
        self.master.grab_set()
        self.master.protocol("WM_DELETE_WINDOW", self.deleteWindow)

        self.fields = GlobalMessageSettings()
        self.setGlobalMessageSettings()

        self.mmFrame = MessageMakerFrame(self.master, self.message)
        self.mmFrame.frame.grid(row=0, column=0, sticky=NSEW, columnspan=2, padx=4, pady=4)

        self.partsFrame = MessageMakerPartFrame(self)
        self.partsFrame.frame.grid(row=1, column=0, sticky=NSEW, columnspan=2, padx=4, pady=4)

        self.globalMessageSettingsFrame = SettingsMessageFrame(self.master, self.fields)
        self.globalMessageSettingsFrame.frame.grid(row=2, column=1, sticky=NSEW, padx=(0, 4), pady=4)

        self.overrideFrame = OverrideFrame(self.master, self.globalMessageSettingsFrame, self.listFrame.window.window.settings)
        self.overrideFrame.frame.grid(row=2, column=0, sticky=NSEW, padx=4, pady=4)

        self.disableGlobalMessageFields()

        self.okCancelFrame = MessageMakerOkCancelFrame(self)
        self.okCancelFrame.frame.grid(row=3, column=0, columnspan=2, padx=4, pady=4, sticky=E)

        self.applyOverrides()
        self.master.deiconify()
        self.master.mainloop()
示例#8
0
def send():
    """
    Request endpoint to send a message to the bot
    """
    data = request.get_json()
    
    try:
        # Retrieves the sentiment of the sent message
        prediction = model.predict(data['message'])
        sentiment = None
        for annotation_payload in prediction:
                sentiment = annotation_payload.text_sentiment.sentiment

        # Creates a new message object to the AI
        messageClient = Message(data['message'], data['sessionID'], data['clientID'], AI_ID, sentiment)
        # If successful it counts as completed
        completed0 = sql.message(vars(messageClient))
        
        # Based on multiple factors (below) the bot will return a predefined appropriate response
        # Factor 1 -> Start conversation containing 'hi', 'hello', 'hey', or 'yo'
        # Factor 2 -> End conversation containing 'thanks' or 'thank you'
        # Factor 3 -> Bad sentiment response of 0 must send reassuring message back
        # Factor 4 -> Good sentiment response of 1 must send message back that will aid in happiness continuation
        # Randomization of predetermined messages are used to pick a message
        messageToClient = ""
        if any([start_convo in data['message'].lower().split() for start_convo in ['hi', 'hello', 'yo', 'hey']]):
            messageToClient = start_conversation_responses[randint(0, 4)]
        elif (('thanks' in data['message'].lower()) or ('thank you' in data['message'].lower())):
            messageToClient = 'No problem! I\'m always here to help!'
        else:
            if sentiment == 1:
                messageToClient = good_responses[randint(0, 4)]
            else:
                messageToClient = bad_responses[randint(0, 4)]

        # Creates a message from the AI object and sends to SQL to input in DB for session
        messageAI = Message(messageToClient, data['sessionID'], AI_ID, data['clientID'], sentiment)
        completed1 = sql.message(vars(messageAI))

        # If both messages sent successfully then success is imminent
        if completed0 and completed1:
            return {'success': True}, 200
        else:
            return {'success': False}, 400
    except:
        return {'success': False}, 400
示例#9
0
 def _get_inadequate_messages(self):
     """returns 2 messages which makes the condition ">= 3" False"""
     return [
         Message(content, sender, recepient)
         for (content, sender, recepient) in (
             ('test2 emblem', self.conquerer, self.universe.kingdoms[1]),
             ('test3 emblem', self.conquerer, self.universe.kingdoms[2]),
         )
     ]
示例#10
0
    def get_all_messages_in_chat(self, chat, include_me=False):
        message_objs = self.wapi_functions.getAllMessagesInChat(
            chat.id, include_me)

        messages = []
        for message in message_objs:
            messages.append(Message(message))

        return messages
示例#11
0
 def _get_messages_stub(self):
     return [Message(content, sender, recepient)
         for (content, sender, recepient)
         in (
             ('test3 emblem', self.candidates[0], self.universe.kingdoms[2]),
             ('test4 emblem', self.candidates[0], self.universe.kingdoms[3]),
             ('test5 emblem', self.candidates[0], self.universe.kingdoms[4]),
             ('test6 emblem', self.candidates[1], self.universe.kingdoms[5])
         )
     ]
示例#12
0
文件: host.py 项目: h-oll/QuNetSim
    def _process_packet(self, packet):
        """
        Processes the received packet.

        Args:
            packet (Packet): The received packet
        """
        def check_task(q, sender, seq_num, timeout, start_time):
            if timeout is not None and time.time() - timeout > start_time:
                q.put(False)
                return True
            if sender not in self._seq_number_sender_ack.keys():
                return False
            if seq_num < self._seq_number_sender_ack[sender][1]:
                q.put(True)
                return True
            if seq_num in self._seq_number_sender_ack[sender][0]:
                q.put(True)
                return True
            return False

        sender = packet.sender
        result = protocols.process(packet)
        if result is not None:
            msg = Message(sender, result['message'], result['sequence_number'])
            self._classical_messages.add_msg_to_storage(msg)
            if msg.content != protocols.ACK:
                self.logger.log(self.host_id + ' received ' +
                                str(result['message']) +
                                ' with sequence number ' +
                                str(result['sequence_number']))
            else:
                # Is ack msg
                sender = msg.sender
                if sender not in self._seq_number_sender_ack.keys():
                    self._seq_number_sender_ack[sender] = [[], 0]
                seq_num = msg.seq_num
                expected_seq = self._seq_number_sender_ack[sender][1]
                if seq_num == expected_seq:
                    self._seq_number_sender_ack[sender][1] += 1
                    expected_seq = self._seq_number_sender_ack[sender][1]
                    while len(self._seq_number_sender_ack[sender][0]) > 0 \
                            and expected_seq in self._seq_number_sender_ack[sender][0]:
                        self._seq_number_sender_ack[sender][0].remove(
                            expected_seq)
                        self._seq_number_sender_ack[sender][1] += 1
                        expected_seq += 1
                elif seq_num > expected_seq:
                    self._seq_number_sender_ack[sender][0].append(seq_num)
                else:
                    raise Exception("Should never happen!")
                for t in self._ack_receiver_queue:
                    res = check_task(*t)
                    if res is True:
                        self._ack_receiver_queue.remove(t)
示例#13
0
 def _get_adequate_but_invalid_messages(self):
     """returns 3 messages in which 1 is invalid making the condition ">= 3" False"""
     return [
         Message(content, sender, recepient)
         for (content, sender, recepient) in (
             ('test2 emblem', self.conquerer, self.universe.kingdoms[1]),
             ('test3 emblem', self.conquerer, self.universe.kingdoms[2]),
             ('test3 emblem', self.conquerer, self.universe.kingdoms[3]
              )  # Should have had 'test4 emblem' in content
         )
     ]
def test_next_message():
    storage = ClassicalStorage()
    print("Start next message test...")
    assert len(storage.get_all()) == 0

    for c in range(15):
        msg = Message("Alice", str(c), c)
        storage.add_msg_to_storage(msg)

    for c in range(15):
        msg = storage.get_next_from_sender("Alice")
        assert msg.content == str(c)
    print("Test was successfull!")
示例#15
0
 def _get_messages(self):
     messages = []
     while True:
         recepient_name = input(
             "\nWhom do you want to send the message to? ")
         try:
             recepient = self._possible_allies[recepient_name.lower()]
             content = input("Enter the content: ")
             messages.append(Message(content, self.conquerer, recepient))
             choice = input("Input 1 to send another message ")
             if choice != "1":
                 return messages
         except KeyError:
             print("Invalid recepient. Valid options are: {0}".format(
                 self._possible_allies_names))
def test_deleting_ACK_messages():
    storage = ClassicalStorage()
    print("Test deleting ACK messages...")
    assert len(storage.get_all()) == 0

    ack_msg = Message("Alice", protocols.ACK, 1)
    storage.add_msg_to_storage(ack_msg)

    assert len(storage.get_all()) == 1

    storage.remove_all_ack("Bob")

    assert len(storage.get_all()) == 1
    storage.remove_all_ack()

    assert len(storage.get_all()) == 0
    print("Test was successfull!")
示例#17
0
    def get_unread(self):
        """
        Fetches unread messages

        :return: List of unread messages grouped by chats
        :rtype: list[MessageGroup]
        """
        raw_message_groups = self.wapi_functions.getUnreadMessages()

        unread_messages = []
        for raw_message_group in raw_message_groups:
            chat = Chat(raw_message_group)
            pp.pprint(raw_message_group)
            messages = [
                Message(message) for message in raw_message_group["messages"]
            ]
            unread_messages.append(MessageGroup(chat, messages))

        return unread_messages
示例#18
0
    def get_all_messages_in_chat(self,
                                 chat,
                                 include_me=False,
                                 include_notifications=False):
        # type: (Chat ,bool, bool) -> list(Message)
        """
        Fetches messages in chat

        :return: List of messages in chat
        :rtype: list[Message]
        """
        message_objs = self.wapi_functions.getAllMessagesInChat(
            chat.id, include_me, include_notifications)

        messages = []
        for message in message_objs:
            messages.append(Message(message, driver=self))

        return messages
示例#19
0
    def get_unread(self, include_me=False, include_notifications=False):
        """
        Fetches unread messages

        :return: List of unread messages grouped by chats
        :rtype: list[MessageGroup]
        """
        raw_message_groups = self.wapi_functions.getUnreadMessages(
            include_me, include_notifications)

        unread_messages = []
        for raw_message_group in raw_message_groups:
            chat = Chat(raw_message_group)
            messages = [
                Message(message) for message in raw_message_group["messages"]
            ]
            unread_messages.append(MessageGroup(chat, messages))

        for message in unread_messages:
            message.chat.driver = self

        return unread_messages
示例#20
0
    def getMessages(self, username, channel):
        messages = []
        try:
            db = self.sqlHelper.getConnection()

            with closing(db.cursor()) as cur:
                channel_id = self.queryHelper.getChannelID(channel)
                user_id = self.queryHelper.getUserID(username)

                cur.execute(
                    """SELECT * FROM `logs` WHERE `channel_id` = %s AND `user_id` = %s""",
                    (channel_id, user_id))
                rows = cur.fetchall()

                for row in rows:
                    messages.append(Message(row))

        except Exception as e:
            print(traceback.format_exc())
        finally:
            db.close()
            return messages
示例#21
0
    def updateMessage(self):
        if validateMessageMessageMaker(self.fields, self.master) and validateFontsMessageMaker(self.fields, self.master) and validate(self):
            override = Override()
            if self.overrideFrame.overrideDuration.get():
                override.duration = self.globalMessageSettingsFrame.fields.VAR_ENTRY_MESSAGE_DURATION.get()
            if self.overrideFrame.overrideIntermission.get():
                override.intermission = self.globalMessageSettingsFrame.fields.VAR_ENTRY_MESSAGE_INTERMISSION.get()
            if self.overrideFrame.overrideScrollSpeed.get():
                override.scrollSpeed = self.globalMessageSettingsFrame.fields.VAR_ENTRY_MOVE_ALL_ON_LINE_DELAY.get()
            if self.overrideFrame.overrideFont.get():
                override.font = self.globalMessageSettingsFrame.fields.VAR_FONT_COMBO_BOX.get()
            if self.overrideFrame.overrideFontSize.get():
                override.fontSize = self.globalMessageSettingsFrame.fields.VAR_ENTRY_NORMAL_FONT_SIZE.get()
            if self.overrideFrame.overrideFontColor.get():
                override.fontColor = self.globalMessageSettingsFrame.fields.VAR_LABEL_MESSAGE_COLOR_TEXT.get()
            if self.overrideFrame.overrideArrival.get():
                override.arrival = self.globalMessageSettingsFrame.fields.VAR_ARRIVAL.get()
            if self.overrideFrame.overrideDeparture.get():
                override.departure = self.globalMessageSettingsFrame.fields.VAR_DEPARTURE.get()
            if self.overrideFrame.overrideFontStyle.get():
                override.bold = self.globalMessageSettingsFrame.fields.VAR_FONT_IS_BOLD.get()
                override.italic = self.globalMessageSettingsFrame.fields.VAR_FONT_IS_ITALIC.get()
                override.overstrike = self.globalMessageSettingsFrame.fields.VAR_FONT_IS_OVERSTRIKE.get()
            if self.overrideFrame.overrideAlignment.get():
                override.alignment = self.globalMessageSettingsFrame.fields.VAR_ALIGNMENT.get()

            for part in self.message.parts:
                part.sortOrder = self.message.parts.index(part) + 1

            newMessage = Message(self.mmFrame.nickname.get(), self.index, self.message.parts, override)
            if not self.isNewMessage:
                self.parentWindow.messages[self.index] = newMessage
            else:
                self.parentWindow.messages.append(newMessage)
            self.parentWindow.mlFrame.populateListbox(self.parentWindow.messages)
            self.master.destroy()
示例#22
0
class MessageMakerWindow:
    def __init__(self, listFrame, message: Message, index: int):
        self.master = Toplevel(listFrame.window.master)
        self.master.withdraw()
        self.listFrame = listFrame
        self.parent = listFrame.window.master
        self.parentWindow = listFrame.window
        self.message = deepcopy(message)
        if not self.message:
            self.isNewMessage = True
            self.message = Message()
        else:
            self.isNewMessage = False
        self.message.sortParts()
        self.index = index
        self.master.geometry('+{x}+{y}'.format(x=self.parent.winfo_x() + 10, y=self.parent.winfo_y() + 10))
        self.master.wm_attributes("-topmost", 1)
        self.master.focus_force()
        self.master.wm_title("StreamTicker Message Maker")
        self.master.iconbitmap("imagefiles/stIcon.ico")
        self.master.resizable(False, False)
        self.master.grab_set()
        self.master.protocol("WM_DELETE_WINDOW", self.deleteWindow)

        self.fields = GlobalMessageSettings()
        self.setGlobalMessageSettings()

        self.mmFrame = MessageMakerFrame(self.master, self.message)
        self.mmFrame.frame.grid(row=0, column=0, sticky=NSEW, columnspan=2, padx=4, pady=4)

        self.partsFrame = MessageMakerPartFrame(self)
        self.partsFrame.frame.grid(row=1, column=0, sticky=NSEW, columnspan=2, padx=4, pady=4)

        self.globalMessageSettingsFrame = SettingsMessageFrame(self.master, self.fields)
        self.globalMessageSettingsFrame.frame.grid(row=2, column=1, sticky=NSEW, padx=(0, 4), pady=4)

        self.overrideFrame = OverrideFrame(self.master, self.globalMessageSettingsFrame, self.listFrame.window.window.settings)
        self.overrideFrame.frame.grid(row=2, column=0, sticky=NSEW, padx=4, pady=4)

        self.disableGlobalMessageFields()

        self.okCancelFrame = MessageMakerOkCancelFrame(self)
        self.okCancelFrame.frame.grid(row=3, column=0, columnspan=2, padx=4, pady=4, sticky=E)

        self.applyOverrides()
        self.master.deiconify()
        self.master.mainloop()

    def deleteWindow(self):
        self.master.destroy()
        self.parent.lift()
        self.parent.wm_attributes("-topmost", 1)
        self.parent.grab_set()

    def applyOverrides(self):
        overrides = self.message.overrides
        if overrides:
            if overrides.duration:
                self.fields.VAR_ENTRY_MESSAGE_DURATION.set(overrides.duration)
                self.overrideFrame.overrideDuration.set(True)
                self.overrideFrame.gmsFrame.ENTRY_MESSAGE_DURATION.configure(state=NORMAL)
            if overrides.intermission:
                self.fields.VAR_ENTRY_MESSAGE_INTERMISSION.set(overrides.intermission)
                self.overrideFrame.overrideIntermission.set(True)
                self.overrideFrame.gmsFrame.ENTRY_MESSAGE_INTERMISSION.configure(state=NORMAL)
            if overrides.scrollSpeed:
                self.fields.VAR_ENTRY_MOVE_ALL_ON_LINE_DELAY.set(overrides.scrollSpeed)
                self.overrideFrame.overrideScrollSpeed.set(True)
                self.overrideFrame.gmsFrame.entryMoveAllOnLineDelay.configure(state=NORMAL)
            if overrides.font:
                self.fields.VAR_FONT_COMBO_BOX.set(overrides.font)
                self.overrideFrame.overrideFont.set(True)
                self.overrideFrame.gmsFrame.FONT_COMBO_BOX.configure(state="readonly")
            if overrides.fontColor:
                self.fields.VAR_LABEL_MESSAGE_COLOR_FOREGROUND = overrides.fontColor
                self.fields.VAR_LABEL_MESSAGE_COLOR_TEXT.set(overrides.fontColor)
                self.overrideFrame.overrideFontColor.set(True)
                self.overrideFrame.gmsFrame.BUTTON_MESSAGE_COLOR.config(state=NORMAL)
                self.globalMessageSettingsFrame.CANVAS_MESSAGE_COLOR.itemconfig(self.globalMessageSettingsFrame.RECTANGLE_MESSAGE_COLOR,
                                                                                fill=self.fields.VAR_LABEL_MESSAGE_COLOR_FOREGROUND)
            if overrides.fontSize:
                self.fields.VAR_ENTRY_NORMAL_FONT_SIZE.set(overrides.fontSize)
                self.overrideFrame.overrideFontSize.set(True)
                self.overrideFrame.gmsFrame.ENTRY_NORMAL_FONT_SIZE.configure(state=NORMAL)
            if overrides.arrival:
                self.fields.VAR_ARRIVAL.set(overrides.arrival)
                self.overrideFrame.overrideArrival.set(True)
                self.overrideFrame.gmsFrame.ARRIVAL_COMBO_BOX.config(state="readonly")
            if overrides.departure:
                self.fields.VAR_DEPARTURE.set(overrides.departure)
                self.overrideFrame.overrideDeparture.set(True)
                self.overrideFrame.gmsFrame.DEPARTURE_COMBO_BOX.config(state="readonly")
            if overrides.bold:
                self.fields.VAR_FONT_IS_BOLD.set(overrides.bold)
                self.overrideFrame.overrideFontStyle.set(True)
                self.configureFontStyleFields()
            if overrides.italic:
                self.fields.VAR_FONT_IS_ITALIC.set(overrides.italic)
                self.overrideFrame.overrideFontStyle.set(True)
                self.configureFontStyleFields()
            if overrides.overstrike:
                self.fields.VAR_FONT_IS_OVERSTRIKE.set(overrides.overstrike)
                self.overrideFrame.overrideFontStyle.set(True)
                self.configureFontStyleFields()
            if overrides.alignment:
                self.fields.VAR_ALIGNMENT.set(overrides.alignment)
                self.overrideFrame.overrideAlignment.set(True)
                self.overrideFrame.gmsFrame.ALIGNMENT_COMBO_BOX.config(state="readonly")

    def configureFontStyleFields(self):
        self.overrideFrame.gmsFrame.checkButtonBold.config(state=NORMAL)
        self.overrideFrame.gmsFrame.checkButtonItalic.config(state=NORMAL)
        self.overrideFrame.gmsFrame.checkButtonOverstrike.config(state=NORMAL)

    def setGlobalMessageSettings(self):
        gmSettings = self.listFrame.window.window.settings.messageSettings
        wSettings = self.listFrame.window.window.settings.windowSettings
        self.fields.VAR_ENTRY_MESSAGE_DURATION.set(gmSettings.duration)
        self.fields.VAR_ENTRY_MESSAGE_INTERMISSION.set(gmSettings.intermission)
        self.fields.VAR_FONT_COMBO_BOX.set(gmSettings.fontFace)
        self.fields.VAR_LABEL_MESSAGE_COLOR_FOREGROUND = gmSettings.color
        self.fields.VAR_LABEL_MESSAGE_COLOR_TEXT.set(gmSettings.color)
        self.fields.VAR_ENTRY_NORMAL_FONT_SIZE.set(gmSettings.fontSize)
        self.fields.VAR_ENTRY_MOVE_ALL_ON_LINE_DELAY.set(wSettings.moveAllOnLineDelay)
        self.fields.VAR_ARRIVAL.set(gmSettings.arrival)
        self.fields.VAR_DEPARTURE.set(gmSettings.departure)
        self.fields.VAR_FONT_IS_BOLD.set(gmSettings.bold)
        self.fields.VAR_FONT_IS_ITALIC.set(gmSettings.italic)
        self.fields.VAR_FONT_IS_OVERSTRIKE.set(gmSettings.overstrike)
        self.fields.VAR_ALIGNMENT.set(gmSettings.alignment)

    def disableGlobalMessageFields(self):
        for child in self.globalMessageSettingsFrame.frame.winfo_children():
            if child.winfo_class() in ('Entry', 'Button', 'TCombobox', 'Checkbutton'):
                child.configure(state='disable')
            if child.winfo_class() == 'Frame':
                for grandchild in child.winfo_children():
                    if grandchild.winfo_class() in ('Entry', 'Button', 'TCombobox', 'Checkbutton'):
                        grandchild.configure(state='disable')

    def updateMessage(self):
        if validateMessageMessageMaker(self.fields, self.master) and validateFontsMessageMaker(self.fields, self.master) and validate(self):
            override = Override()
            if self.overrideFrame.overrideDuration.get():
                override.duration = self.globalMessageSettingsFrame.fields.VAR_ENTRY_MESSAGE_DURATION.get()
            if self.overrideFrame.overrideIntermission.get():
                override.intermission = self.globalMessageSettingsFrame.fields.VAR_ENTRY_MESSAGE_INTERMISSION.get()
            if self.overrideFrame.overrideScrollSpeed.get():
                override.scrollSpeed = self.globalMessageSettingsFrame.fields.VAR_ENTRY_MOVE_ALL_ON_LINE_DELAY.get()
            if self.overrideFrame.overrideFont.get():
                override.font = self.globalMessageSettingsFrame.fields.VAR_FONT_COMBO_BOX.get()
            if self.overrideFrame.overrideFontSize.get():
                override.fontSize = self.globalMessageSettingsFrame.fields.VAR_ENTRY_NORMAL_FONT_SIZE.get()
            if self.overrideFrame.overrideFontColor.get():
                override.fontColor = self.globalMessageSettingsFrame.fields.VAR_LABEL_MESSAGE_COLOR_TEXT.get()
            if self.overrideFrame.overrideArrival.get():
                override.arrival = self.globalMessageSettingsFrame.fields.VAR_ARRIVAL.get()
            if self.overrideFrame.overrideDeparture.get():
                override.departure = self.globalMessageSettingsFrame.fields.VAR_DEPARTURE.get()
            if self.overrideFrame.overrideFontStyle.get():
                override.bold = self.globalMessageSettingsFrame.fields.VAR_FONT_IS_BOLD.get()
                override.italic = self.globalMessageSettingsFrame.fields.VAR_FONT_IS_ITALIC.get()
                override.overstrike = self.globalMessageSettingsFrame.fields.VAR_FONT_IS_OVERSTRIKE.get()
            if self.overrideFrame.overrideAlignment.get():
                override.alignment = self.globalMessageSettingsFrame.fields.VAR_ALIGNMENT.get()

            for part in self.message.parts:
                part.sortOrder = self.message.parts.index(part) + 1

            newMessage = Message(self.mmFrame.nickname.get(), self.index, self.message.parts, override)
            if not self.isNewMessage:
                self.parentWindow.messages[self.index] = newMessage
            else:
                self.parentWindow.messages.append(newMessage)
            self.parentWindow.mlFrame.populateListbox(self.parentWindow.messages)
            self.master.destroy()
 def refresh_last_message(self, username):
     last_message = self.get_last_message(username)
     message = Message.load_from_document(last_message)
     self.update_message(username, message)
示例#24
0
 def test_ally_addition_on_invalid_content(self):
     content = 'iMiOiN'
     message = Message(content, self.sender, self.recepient)
     self.assertFalse(message.is_valid())