def _get_room_text(self):
     last_update_time = self._get_last_update_time()
     self.last_room_update = last_update_time
     messages = get_room_messages(self.session, get_base_url(), self.room_id)
     self.messages_callback(messages)
     users = get_users(self.session, get_base_url(), self.room_id)
     self.users_callback(users)
Example #2
0
 def run(self):
     while not self.stopped.wait(0.1):
         try:
             message = self.queue.get(block=True, timeout=1)
             send_message(self.session, get_base_url(), self.get_room_func(), message)
             self.queue.task_done()
         except Empty:
             # This exception is part of the normal flow is the user has not
             # sent a message in the last timeout period. Simply passing.
             pass
Example #3
0
 def run(self):
     first = True
     # TODO, replace time with a configurable option.
     while first or not self.stopped.wait(10):
         first = False
         response = get_available_rooms(self.session, get_base_url())
         if self.last_response != response:
             self.last_response = response
             self.rooms = self._build_rooms(self.last_response)
             self.callback_func(self.rooms)
 def run(self):
     while not self.stopped.wait(1):
         last_room_id = self.room_id
         self.room_id = self.get_room_func()
         if self.room_id is not None:
             if last_room_id == self.room_id:
                 self._get_updated_text()
             else:
                 # New Room
                 user_id = get_my_user_id(self.session, get_base_url())
                 if last_room_id is not None:
                     self._leave_room(last_room_id, user_id)
                 self._join_room(user_id)
                 self._get_room_text()
         else:
             # Do nothing when a room isn't selected
             pass
 def run(self):
     username = None
     password = None
     while not self.stopped.wait(0.1):
         try:
             username, password = self.queue.get(block=True, timeout=1)
             domain = get_domain()
             if domain:
                 self.session = get_session(domain + '\\' + username,
                                            password)
             else:
                 self.session = get_session(username, password)
             self.queue.task_done()
             get_available_rooms(self.session, get_base_url())
             self.login_success_callback()
             self.stopped.set()
         except Empty:
             # This exception is part of the normal flow is the user has not
             # sent a message in the last timeout period. Simply passing.
             pass
         except TFS_Chat_Exception:
             self.login_failure_callback("Login failed.")
 def _leave_room(self, room_id, user_id):
     try:
         leave_room(self.session, get_base_url(), room_id, user_id)
     except TFS_Chat_Exception:
         print("Failed to leave room!")
 def _join_room(self, user_id):
     try:
         join_room(self.session, get_base_url(), self.room_id, user_id)
     except TFS_Chat_Exception:
         print("Failed to join room!")
 def _get_last_update_time(self):
     latest_update = get_room_info(self.session, get_base_url(), self.room_id)['lastActivity']
     last_update_time = (
         datetime.datetime.strptime(latest_update,'%Y-%m-%dT%H:%M:%S.%fZ'))
     return last_update_time
 def _get_updated_text(self):
     last_update_time = self._get_last_update_time()
     if self.last_room_update != last_update_time:
         self.last_room_update = last_update_time
         messages = get_room_messages(self.session, get_base_url(), self.room_id)
         self.messages_callback(messages)