Beispiel #1
0
    def __init__(self, config):

        identity = config.BOT_IDENTITY
        nickname = identity['nickname']
        server = identity['server']
        port = identity.get('port', 6667)
        password = identity.get('password', None)
        ssl = identity.get('ssl', False)
        bind_address = identity.get('bind_address', None)
        ipv6 = identity.get('ipv6', False)
        username = identity.get('username', None)
        nickserv_password = identity.get('nickserv_password', None)

        compact = config.COMPACT_OUTPUT if hasattr(config,
                                                   'COMPACT_OUTPUT') else True
        enable_format('irc', IRC_CHRS, borders=not compact)

        private_rate = config.__dict__.get('IRC_PRIVATE_RATE', 1)
        channel_rate = config.__dict__.get('IRC_CHANNEL_RATE', 1)
        reconnect_on_kick = config.__dict__.get('IRC_RECONNECT_ON_KICK', 5)
        reconnect_on_disconnect = config.__dict__.get(
            'IRC_RECONNECT_ON_DISCONNECT', 5)

        self.bot_identifier = IRCIdentifier(nickname + '!' + nickname + '@' +
                                            server)
        super().__init__(config)
        self.conn = IRCConnection(self, nickname, server, port, ssl,
                                  bind_address, ipv6, password, username,
                                  nickserv_password, private_rate,
                                  channel_rate, reconnect_on_kick,
                                  reconnect_on_disconnect)
        self.md = irc_md()
Beispiel #2
0
    def __init__(self, config):

        identity = config.BOT_IDENTITY
        nickname = identity['nickname']
        server = identity['server']
        port = identity.get('port', 6667)
        password = identity.get('password', None)
        ssl = identity.get('ssl', False)
        username = identity.get('username', None)
        nickserv_password = identity.get('nickserv_password', None)

        compact = config.COMPACT_OUTPUT if hasattr(config, 'COMPACT_OUTPUT') else True
        enable_format('irc', IRC_CHRS, borders=not compact)

        private_rate = config.__dict__.get('IRC_PRIVATE_RATE', 1)
        channel_rate = config.__dict__.get('IRC_CHANNEL_RATE', 1)
        reconnect_on_kick = config.__dict__.get('IRC_RECONNECT_ON_KICK', 5)
        reconnect_on_disconnect = config.__dict__.get('IRC_RECONNECT_ON_DISCONNECT', 5)

        self.bot_identifier = IRCIdentifier(nickname, server)
        super().__init__(config)
        self.conn = IRCConnection(self,
                                  nickname,
                                  server,
                                  port,
                                  ssl,
                                  password,
                                  username,
                                  nickserv_password,
                                  private_rate,
                                  channel_rate,
                                  reconnect_on_kick,
                                  reconnect_on_disconnect)
        self.md = irc_md()
Beispiel #3
0
    def __init__(self, config):
        super().__init__(config)
        config.MESSAGE_SIZE_LIMIT = TELEGRAM_MESSAGE_SIZE_LIMIT
        logging.getLogger('telegram.bot').addFilter(TelegramBotFilter())

        identity = config.BOT_IDENTITY
        self.token = identity.get('token', None)
        if not self.token:
            log.fatal(
                "You need to supply a token for me to use. You can obtain "
                "a token by registering your bot with the Bot Father (@BotFather)"
            )
            sys.exit(1)
        self.telegram = None  # Will be initialized in serve_once
        self.bot_instance = None  # Will be set in serve_once

        compact = config.COMPACT_OUTPUT if hasattr(config, 'COMPACT_OUTPUT') else False
        enable_format('text', TEXT_CHRS, borders=not compact)
        self.md_converter = text()
Beispiel #4
0
    def __init__(self, config):
        super().__init__(config)
        config.MESSAGE_SIZE_LIMIT = TELEGRAM_MESSAGE_SIZE_LIMIT
        logging.getLogger('telegram.bot').addFilter(TelegramBotFilter())

        identity = config.BOT_IDENTITY
        self.token = identity.get('token', None)
        if not self.token:
            log.fatal(
                "You need to supply a token for me to use. You can obtain "
                "a token by registering your bot with the Bot Father (@BotFather)"
            )
            sys.exit(1)
        self.telegram = None  # Will be initialized in serve_once
        self.bot_instance = None  # Will be set in serve_once

        compact = config.COMPACT_OUTPUT if hasattr(config, 'COMPACT_OUTPUT') else False
        enable_format('text', TEXT_CHRS, borders=not compact)
        self.md_converter = text()
Beispiel #5
0
    def __init__(self, config):
        global aclpattern
        aclpattern = getattr(config, 'IRC_ACL_PATTERN', '{nick}!{user}@{host}')

        identity = config.BOT_IDENTITY
        nickname = identity['nickname']
        server = identity['server']
        port = identity.get('port', 6667)
        password = identity.get('password', None)
        ssl = identity.get('ssl', False)
        bind_address = identity.get('bind_address', None)
        ipv6 = identity.get('ipv6', False)
        username = identity.get('username', None)
        nickserv_password = identity.get('nickserv_password', None)

        compact = config.COMPACT_OUTPUT if hasattr(config, 'COMPACT_OUTPUT') else True
        enable_format('irc', IRC_CHRS, borders=not compact)

        private_rate = getattr(config, 'IRC_PRIVATE_RATE', 1)
        channel_rate = getattr(config, 'IRC_CHANNEL_RATE', 1)
        reconnect_on_kick = getattr(config, 'IRC_RECONNECT_ON_KICK', 5)
        reconnect_on_disconnect = getattr(config, 'IRC_RECONNECT_ON_DISCONNECT', 5)

        self.bot_identifier = IRCPerson(nickname + '!' + nickname + '@' + server)
        super().__init__(config)
        self.conn = IRCConnection(bot=self,
                                  nickname=nickname,
                                  server=server,
                                  port=port,
                                  ssl=ssl,
                                  bind_address=bind_address,
                                  ipv6=ipv6,
                                  password=password,
                                  username=username,
                                  nickserv_password=nickserv_password,
                                  private_rate=private_rate,
                                  channel_rate=channel_rate,
                                  reconnect_on_kick=reconnect_on_kick,
                                  reconnect_on_disconnect=reconnect_on_disconnect,
                                  )
        self.md = irc_md()
Beispiel #6
0
                          bg_blue=NSC('\x03,02'),
                          bg_magenta=NSC('\x03,06'),
                          bg_cyan=NSC('\x03,10'),
                          bg_white=NSC('\x03,00'),
                          bg_default=NSC('\x03,'),
                          fx_reset=NSC('\x03'),
                          fx_bold=NSC('\x02'),
                          fx_italic=NSC('\x1D'),
                          fx_underline=NSC('\x1F'),
                          fx_not_italic=NSC('\x0F'),
                          fx_not_underline=NSC('\x0F'),
                          fx_normal=NSC('\x0F'),
                          fixed_width='',
                          end_fixed_width='')

enable_format('irc', IRC_CHRS)

try:
    import irc.connection
    from irc.client import ServerNotConnectedError
    from irc.bot import SingleServerIRCBot
except ImportError as _:
    log.exception("Could not start the IRC backend")
    log.fatal("""
    If you intend to use the IRC backend please install the python irc package:
    -> On debian-like systems
    sudo apt-get install python-software-properties
    sudo apt-get update
    sudo apt-get install python-irc
    -> On Gentoo
    sudo emerge -av dev-python/irc
Beispiel #7
0
from errbot.rendering.ansi import enable_format, ANSI_CHRS, AnsiExtension
from errbot.backends.base import Message, Presence, ONLINE, OFFLINE, Room
from errbot.backends.test import TestPerson
from errbot.errBot import ErrBot

from markdown import Markdown
from markdown.extensions.extra import ExtraExtension

# Can't use __name__ because of Yapsy
log = logging.getLogger('errbot.backends.text')

ENCODING_INPUT = sys.stdin.encoding
ANSI = hasattr(sys.stderr, 'isatty') and sys.stderr.isatty()


enable_format('borderless', ANSI_CHRS, borders=False)


def borderless_ansi():
    """This makes a converter from markdown to ansi (console) format.
    It can be called like this:
    from errbot.rendering import ansi
    md_converter = ansi()  # you need to cache the converter

    ansi_txt = md_converter.convert(md_txt)
    """
    md = Markdown(output_format='borderless', extensions=[ExtraExtension(), AnsiExtension()])
    md.stripTopLevelTags = False
    return md

Beispiel #8
0
from errbot.rendering.ansi import enable_format, ANSI_CHRS, AnsiExtension
from errbot.backends import SimpleIdentifier
from errbot.backends.base import Message, Presence, ONLINE, OFFLINE, MUCRoom
from errbot.errBot import ErrBot
from errbot.utils import deprecated

from markdown import Markdown
from markdown.extensions.extra import ExtraExtension

# Can't use __name__ because of Yapsy
log = logging.getLogger('errbot.backends.text')

ENCODING_INPUT = sys.stdin.encoding
ANSI = hasattr(sys.stderr, 'isatty') and sys.stderr.isatty()

enable_format('borderless', ANSI_CHRS, borders=False)


def borderless_ansi():
    """This makes a converter from markdown to ansi (console) format.
    It can be called like this:
    from errbot.rendering import ansi
    md_converter = ansi()  # you need to cache the converter

    ansi_txt = md_converter.convert(md_txt)
    """
    md = Markdown(output_format='borderless',
                  extensions=[ExtraExtension(),
                              AnsiExtension()])
    md.stripTopLevelTags = False
    return md
Beispiel #9
0
                          bg_cyan=NSC('\x03,10'),
                          bg_white=NSC('\x03,00'),
                          bg_default=NSC('\x03,'),
                          fx_reset=NSC('\x03'),
                          fx_bold=NSC('\x02'),
                          fx_italic=NSC('\x1D'),
                          fx_underline=NSC('\x1F'),
                          fx_not_italic=NSC('\x0F'),
                          fx_not_underline=NSC('\x0F'),
                          fx_normal=NSC('\x0F'),
                          fixed_width='',
                          end_fixed_width='',
                          inline_code='',
                          end_inline_code='')

enable_format('irc', IRC_CHRS)

try:
    import irc.connection
    from irc.client import ServerNotConnectedError
    from irc.bot import SingleServerIRCBot
except ImportError as _:
    log.exception("Could not start the IRC backend")
    log.fatal("""
    If you intend to use the IRC backend please install the python irc package:
    -> On debian-like systems
    sudo apt-get install python-software-properties
    sudo apt-get update
    sudo apt-get install python-irc
    -> On Gentoo
    sudo emerge -av dev-python/irc
Beispiel #10
0
from errbot.rendering.ansi import enable_format, ANSI_CHRS, AnsiExtension
from errbot.backends.base import Message, Presence, ONLINE, OFFLINE, Room
from errbot.backends.test import TestPerson
from errbot.errBot import ErrBot

from markdown import Markdown
from markdown.extensions.extra import ExtraExtension

# Can't use __name__ because of Yapsy
log = logging.getLogger("errbot.backends.text")

ENCODING_INPUT = sys.stdin.encoding
ANSI = hasattr(sys.stderr, "isatty") and sys.stderr.isatty()


enable_format("borderless", ANSI_CHRS, borders=False)


def borderless_ansi():
    """This makes a converter from markdown to ansi (console) format.
    It can be called like this:
    from errbot.rendering import ansi
    md_converter = ansi()  # you need to cache the converter

    ansi_txt = md_converter.convert(md_txt)
    """
    md = Markdown(output_format="borderless", extensions=[ExtraExtension(), AnsiExtension()])
    md.stripTopLevelTags = False
    return md