コード例 #1
0
ファイル: slack.py プロジェクト: elopio/errbot
def slack_markdown_converter(compact_output=False):
    """
    This is a Markdown converter for use with Slack.
    """
    enable_format('imtext', IMTEXT_CHRS, borders=not compact_output)
    md = Markdown(output_format='imtext', extensions=[ExtraExtension(), AnsiExtension()])
    md.preprocessors['LinkPreProcessor'] = LinkPreProcessor(md)
    md.stripTopLevelTags = False
    return md
コード例 #2
0
ファイル: slack.py プロジェクト: withnale/errbot
def slack_markdown_converter(compact_output=False):
    """
    This is a Markdown converter for use with Slack.
    """
    enable_format('imtext', IMTEXT_CHRS, borders=not compact_output)
    md = Markdown(output_format='imtext', extensions=[ExtraExtension(), AnsiExtension()])
    md.preprocessors['LinkPreProcessor'] = LinkPreProcessor(md)
    md.stripTopLevelTags = False
    return md
コード例 #3
0
ファイル: irc.py プロジェクト: vtpp2014/errbot
    def __init__(self, config):
        if hasattr(config, 'IRC_ACL_PATTERN'):
            IRCBackend.aclpattern = config.IRC_ACL_PATTERN

        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()
        config.MESSAGE_SIZE_LIMIT = IRC_MESSAGE_SIZE_LIMIT
コード例 #4
0
    def __init__(self, config):
        if hasattr(config, "IRC_ACL_PATTERN"):
            IRCBackend.aclpattern = config.IRC_ACL_PATTERN

        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()
コード例 #5
0
    def __init__(self, config):
        super().__init__(config)
        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()
コード例 #6
0
    def __init__(self, config):
        super().__init__(config)
        config.MESSAGE_SIZE_LIMIT = ZULIP_MESSAGE_SIZE_LIMIT

        self.identity = config.BOT_IDENTITY
        for key in ('email', 'key', 'site'):
            if key not in self.identity:
                log.fatal(
                    "You need to supply the key `{}` for me to use. `{key}` and its value "
                    "can be found in your bot's `zuliprc` config file.".format(
                        key))
                sys.exit(1)

        compact = config.COMPACT_OUTPUT if hasattr(config,
                                                   'COMPACT_OUTPUT') else False
        enable_format('text', TEXT_CHRS, borders=not compact)
        self.client = Client(email=self.identity['email'],
                             api_key=self.identity['key'],
                             site=self.identity['site'])
コード例 #7
0
ファイル: telegram_messenger.py プロジェクト: Adman/errbot
    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()
コード例 #8
0
ファイル: irc.py プロジェクト: elopio/errbot
    def __init__(self, config):
        if hasattr(config, 'IRC_ACL_PATTERN'):
            IRCBackend.aclpattern = config.IRC_ACL_PATTERN

        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()
        config.MESSAGE_SIZE_LIMIT = IRC_MESSAGE_SIZE_LIMIT
コード例 #9
0
ファイル: vkbackend.py プロジェクト: genisaretskiy/errbot-vk
    def __init__(self, config):
        super().__init__(config)
        config.MESSAGE_SIZE_LIMIT = MESSAGE_SIZE_LIMIT
        logging.getLogger('VK.bot').addFilter(VKBotFilter())

        identity = config.BOT_IDENTITY
        if identity.get('token', None):
            self.token = identity.get('token')
        else:

            self.login = identity.get('login', None)
            self.password = identity.get('password', None)
            self.token = None

        self.vk = 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()
コード例 #10
0
from errbot.rendering.ansiext import enable_format, ANSI_CHRS, AnsiExtension
from errbot.backends.base import Message, Presence, ONLINE, OFFLINE, Room
from errbot.backends.test import TestPerson
from errbot.core import ErrBot
from errbot.logs import console_hdlr

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
コード例 #11
0
ファイル: text.py プロジェクト: apophys/errbot
from errbot.rendering.ansiext import enable_format, ANSI_CHRS, AnsiExtension
from errbot.backends.base import Message, Person, Presence, ONLINE, OFFLINE, Room, RoomOccupant
from errbot.core import ErrBot
from errbot.logs import console_hdlr

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

コード例 #12
0
    Presence,
    Room,
    RoomOccupant,
    Stream,
)
from errbot.core import ErrBot
from errbot.logs import console_hdlr
from errbot.rendering import ansi, imtext, text, xhtml
from errbot.rendering.ansiext import ANSI_CHRS, AnsiExtension, enable_format

log = logging.getLogger(__name__)

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