class Messanger:
def __init__(self, options):
self.runtime_config = options
+ self.events = {}
def send_message(self, recipient, message, sender=None):
pass
- def register_callbacks(self, callback_functions):
- pass
def lookup_user(self, username):
- pass
-
+ return None
def connect(self, server=None):
pass
def is_user_online(self, user):
pass
+ def get_contacts(self):
+ return []
+
+ def broadcast(self, message, contacts=None):
+ recipients = []
+ if not contacts:
+ recipients = self.get_contacts()
+ else:
+ for contact in contacts:
+ recipient = self.lookup_user(contact)
+ if recipient:
+ recipients.append(recipient)
+
+ for recipient in recipients:
+ self.send_message(recipient, message)