Beispiel #1
0
 def handle_message(self, conv_event, user, set_unread, insert_mode="bottom"):
     message = get_message_html(conv_event.segments)
     pyotherside.send('add-conversation-message',
                      self.conv.id_,
                      {
                          "text": message,
                          "attachments": [{'url': cache.get_image_cached(a) if settings.get('cache_images') else a}
                                          for a in conv_event.attachments],
                          "user_is_self": user.is_self,
                          "username": user.full_name,
                          "time": get_message_timestr(conv_event.timestamp)
                      },
                      insert_mode)
Beispiel #2
0
    def __init__(self, conv):
        self.conv = conv
        self.title = ""

        self.loading = False
        self.first_loaded = False
        self.typing_statuses = {}
        self.status_message = ""

        conv.on_event.add_observer(self.on_event)
        conv.on_watermark_notification.add_observer(self.on_watermark_notification)
        conv.on_typing.add_observer(self.on_typing)
        print(conv.events)
        for event in conv.events:
            self.on_event(event)

        # Start timer routine
        threading.Timer(settings.get("check_routine_timeout"), self.check_routine).start()
Beispiel #3
0
    def handle_message(self, conv_event, user, set_unread, insert_mode="bottom"):
        html = get_message_html(conv_event.segments)
        text = get_message_plain_text(conv_event.segments)
        pyotherside.send('add-conversation-message',
                         self.conv.id_,
                         model.get_message_model_data(
                             type="chat/message",
                             html=html,
                             text=text,
                             attachments=[{'url': cache.get_image_cached(a) if settings.get('cache_images') else a}
                                          for a in conv_event.attachments],
                             user_is_self=user.is_self,
                             username=user.full_name,
                             user_photo="https:" + user.photo_url if user.photo_url else None,
                             time=get_message_timestr(conv_event.timestamp)
                         ),
                         insert_mode)

        self.set_title()
Beispiel #4
0
 def handle_message(self,
                    conv_event,
                    user,
                    set_unread,
                    insert_mode="bottom"):
     message = get_message_html(conv_event.segments)
     pyotherside.send(
         'add-conversation-message', self.conv.id_, {
             "text":
             message,
             "attachments": [{
                 'url':
                 cache.get_image_cached(a)
                 if settings.get('cache_images') else a
             } for a in conv_event.attachments],
             "user_is_self":
             user.is_self,
             "username":
             user.full_name,
             "time":
             get_message_timestr(conv_event.timestamp)
         }, insert_mode)
Beispiel #5
0
    def __init__(self, conv):
        self.conv = conv
        self.title = ''

        self.initial_messages_loaded = False
        self.loading = False
        self.first_loaded = False
        self.typing_statuses = {}
        self.status_message = ""

        self.current_local_id = 0

        conv.on_event.add_observer(self.on_event)
        conv.on_watermark_notification.add_observer(self.on_watermark_notification)
        conv.on_typing.add_observer(self.on_typing)
        for event in conv.events:
            self.on_event(event)

        # Load some more messages on start:
        asyncio.async(self._load_more(max_events=5))

        # Start timer routine
        threading.Timer(settings.get('check_routine_timeout'), self.check_routine).start()
Beispiel #6
0
def settings_get(key):
    return settings.get(key)
Beispiel #7
0
def settings_get(key):
    return settings.get(key)
Beispiel #8
0
 def check_routine(self):
     print("Running check routine of ", self.conv.id_)
     call_threadsafe(self.update_online_status)
     # Start new timer
     threading.Timer(settings.get("check_routine_timeout"), self.check_routine).start()