# Path: baobab/socialnetwork/base.py
# class SocialNetworkBase(object):
# 
#     """
#     interface for all social network, each social network have to
#     inherited from this class
#     """
# 
#     name = None
# 
#     @classmethod
#     def is_configured(cls):
#         raise NotImplementedError()
# 
#     @classmethod
#     def get_max_char(cls, default):
#         raise NotImplementedError()
# 
#     def publish(self, msg, url):
#         """
#         should raise if it failed
#         """
#         raise NotImplementedError()
# 
#     def  __enter__(self):
#         raise NotImplementedError()
# 
#     def __exit__(self, exc_type, exc_val, exc_tb):
#         raise NotImplementedError()
# 
# class UnPublishedException(Exception):
#     pass


import logging
import os
import select
import signal
import socket
import ssl
from time import sleep
from irc import connection
from irc.client import (IRC as IRCClient,
                        ServerNotConnectedError,
                        ServerConnectionError,
                        is_channel)
from django.conf import settings
from .base import SocialNetworkBase, UnPublishedException
                    return False
        return True

    @classmethod
    def get_max_char(cls, default):
        if cls.is_configured():
            return settings.IRC_ALLOWED_CHAR
        return default

    def __init__(self):
        if not self.is_configured():
            raise RuntimeError('IRC is not configured')
        self.send_msg = None

    def __enter__(self):
        self.send_msg = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
        self.send_msg.connect(settings.IRC_SOCKET_PATH)
        return self

    def __exit__(self, exc_type, exc_val, exc_tb):
        self.send_msg.close()
        self.send_msg = None

    def publish(self, msg, url):
        if not self.send_msg:
            raise UnPublishedException(
                'msg: %s is not send to IRC not connected' % msg)
        try:
            self.send_msg.send('%s\0%s' % (msg, url))
        except Exception as err:

# Path: baobab/socialnetwork/base.py
# class SocialNetworkBase(object):
# 
#     """
#     interface for all social network, each social network have to
#     inherited from this class
#     """
# 
#     name = None
# 
#     @classmethod
#     def is_configured(cls):
#         raise NotImplementedError()
# 
#     @classmethod
#     def get_max_char(cls, default):
#         raise NotImplementedError()
# 
#     def publish(self, msg, url):
#         """
#         should raise if it failed
#         """
#         raise NotImplementedError()
# 
#     def  __enter__(self):
#         raise NotImplementedError()
# 
#     def __exit__(self, exc_type, exc_val, exc_tb):
#         raise NotImplementedError()
# 
# class UnPublishedException(Exception):
#     pass


# Path: baobab/socialnetwork/irc.py
import logging
import os
import select
import signal
import socket
import ssl
from time import sleep
from irc import connection
from irc.client import (IRC as IRCClient,
                        ServerNotConnectedError,
                        ServerConnectionError,
                        is_channel)
from django.conf import settings
from .base import SocialNetworkBase, UnPublishedException

                    return False
        return True

    @classmethod
    def get_max_char(cls, default):
        if cls.is_configured():
            return settings.IRC_ALLOWED_CHAR
        return default

    def __init__(self):
        if not self.is_configured():
            raise RuntimeError('IRC is not configured')
        self.send_msg = None

    def __enter__(self):
        self.send_msg = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
        self.send_msg.connect(settings.IRC_SOCKET_PATH)
        return self

    def __exit__(self, exc_type, exc_val, exc_tb):
        self.send_msg.close()
        self.send_msg = None

    def publish(self, msg, url):
        if not self.send_msg:
            raise UnPublishedException(
                'msg: %s is not send to IRC not connected' % msg)
        try:
            self.send_msg.send('%s\0%s' % (msg, url))
        except Exception as err:

            raise UnPublishedException('Cannot send to msg through irc: %s' %