Beispiel #1
0
def add_message(text, sender, to_room, user_to, mess_type, comand):
    """ content, author, room, user_to, mess_type, command """

    time_stamp = datetime.now()

    #TODO: Putem renunta la spam:) este inutil.
    difference_in_seconds = 1
    # sau>>
    #diff = time_stamp - sender.last_message_ts
    #difference_in_seconds = (diff.microseconds + (diff.seconds + diff.days * 24 * 3600) * 10**6) / 10**6

    if sender.has_modifier('block-communication'):
        return False
    if difference_in_seconds > 0.5:
        if sender.has_modifier('block-messages'):
            text = change_text(text)
        msg = ChatMessage(content=text,
                          author=sender,
                          dest_room=to_room,
                          time_stamp=time_stamp,
                          dest_user=user_to,
                          mess_type=mess_type,
                          comand=comand)
        msg.save()
    else:
        raise ValueError('Spam')
Beispiel #2
0
    def test_message_send_manual(self):
        room= roomexist('global')
        time_stamp = datetime.now()

        len_now = len(ChatMessage.objects.all())
        msg = ChatMessage(content='sss', author=self.chat_user, dest_room=room, time_stamp=time_stamp, mess_type = "normal", comand = "normal")
        msg.save()
        len_after = len(ChatMessage.objects.all())

        self.assertEqual(len_now, len_after - 1)
Beispiel #3
0
    def test_message_send_manual(self):
        room= roomexist('global')
        timeStamp = datetime.now()

        len_now = len(ChatMessage.objects.all())
        msg = ChatMessage(content='sss', author=self.chat_user, destRoom=room, timeStamp=timeStamp, messType = "normal", comand = "normal")
        msg.save()
        len_after = len(ChatMessage.objects.all())

        self.assertEqual(len_now, len_after - 1)
Beispiel #4
0
def add_message(text, sender, to_room, user_to, mess_type, comand):
    """ content, author, room, user_to, mess_type, command """

    time_stamp = datetime.now()

    difference_in_seconds = 1
    # sau>>
    #diff = time_stamp - sender.last_message_ts
    #difference_in_seconds = (diff.microseconds + (diff.seconds + diff.days * 24 * 3600) * 10**6) / 10**6

    if sender.magic.has_modifier('block-communication'):
        return False
    if difference_in_seconds > 0.5:
        if sender.magic.has_modifier('block-messages'):
            text = change_text(text)
        msg = ChatMessage(content=text, author=sender, dest_room=to_room, time_stamp=time_stamp,
            dest_user = user_to, mess_type=mess_type, comand=comand)
        msg.save()
    else:
        raise ValueError('Spam')
Beispiel #5
0
def add_message(text, sender, toRoom, user_to, messType, comand):
    """ content, author, room, user_to, messType, command """

    timeStamp = datetime.now()

    #TODO: Putem renunta la spam:) este inutil.
    difference_in_seconds = 1
    # sau>>
    #diff = timeStamp - sender.lastMessageTS
    #difference_in_seconds = (diff.microseconds + (diff.seconds + diff.days * 24 * 3600) * 10**6) / 10**6

    if sender.has_modifier('block-communication'):
        return False
    if difference_in_seconds > 0.5:
        if sender.has_modifier('block-messages'):
            text = change_text(text)
        msg = ChatMessage(content=text, author=sender, destRoom=toRoom, timeStamp=timeStamp,
            destUser = user_to, messType=messType, comand=comand)
        msg.save()
    else:
        raise ValueError('Spam')