Example #1
0
import unittest
import random

# library imports
import mock


sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))

# local imports
from ekan0ra.bot import LogBot
from ekan0ra.user import IRCUser, InvalidUserError
from config import config_modes


config = config_modes.get("test")


class UserTest(unittest.TestCase):
    def setUp(self):
        ####TODO: Add more valid hostmask patterns to test
        self.validhostmasks = [
            "[email protected]",
            "29cb47b5!29cb47b5@gateway/web/freenode/ip.41.203.71.181",
            "[email protected]",
        ]
        ####TODO: Add more invalid hostmask patterns to test
        self.invalidhostmasks = [
            "[email protected]",
            "29cb47b5@gateway/web/freenode/ip.41.203.71.181",
            "[email protected]",
Example #2
0
import random

# library imports
import mock


sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))

# local imports
from ekan0ra.bot import LogBot
from ekan0ra.user import IRCUser, InvalidUserError
from ekan0ra.commands import commands
from config import config_modes


config = config_modes.get('test')


class BotCommandsTest(unittest.TestCase):

    @mock.patch.object(LogBot, 'load_links', auto_spec=True) # Fake links data load
    @mock.patch('ekan0ra.bot.get_logger_instance') # Fake logger creation
    @mock.patch('ekan0ra.bot.irc.IRCClient')
    def setUp(
            self, mock_irc_IRCClient, mock_get_logger_instance,
            mock_links_reload):
        ####TODO: Add more valid hostmask patterns to test
        self.validhostmasks = [
            '[email protected]',
            '29cb47b5!29cb47b5@gateway/web/freenode/ip.41.203.71.181',
            '[email protected]'
Example #3
0
# third-party imports
from twisted.internet import reactor

# local imports
from config import config_modes
from ekan0ra import setup_app_logger, APP_LOGGER
from ekan0ra.factory import LogBotFactory

# Create an instance* of the configuration mode to use,
# so we can access its __repr__ for logging.
#
# * Note the trailing parentheses: '()'
#
# Valid values for `config_modes()` are:
#   'default', 'dev', 'test', 'deploy'
config = config_modes.get(os.getenv('LOGBOT_CONFIG', 'default'))()


def create_bot(config):
    """Creates an IRC log bot using a factory."""
    log_bot_factory = LogBotFactory(config)
    return log_bot_factory


def run_bot(bot_factory, config):
    """Connects bot to server."""
    server, port = config.IRC_SERVER, config.IRC_SERVER_PORT
    APP_LOGGER.info('Connecting to SERVER(%s) on PORT(%d)', server, port)
    reactor.connectTCP(server, port, bot_factory)
    reactor.run()
Example #4
0
#!/usr/bin/env python
# standard library imports
import logging
import os
import sys

# local imports
from config import config_modes
from slack_shell import setup_logger, LOGGER
from slack_shell.bot.factory import create_bot, run_bot

# Create an instance* of the configuration mode to use,
# so we can access its __repr__ for logging.
#
# * Note the trailing parentheses: '()'
#
# Valid values for `config_modes()` are:
#   'default', 'dev', 'deploy', 'test'
config = config_modes.get(os.getenv('SLACKSHELLBOT_CONFIG', 'default'))()


if __name__ == '__main__':
    setup_logger(config=config)  # initialize application logging
    run_bot(create_bot(config=config))

    if LOGGER:
        LOGGER.info('Shutting down gracefully...')
        logging.shutdown()
    sys.exit(0)
Example #5
0
#!/usr/bin/env python
# standard library imports
import logging
import os
import sys

# local imports
from config import config_modes
from slack_shell import setup_logger, LOGGER
from slack_shell.bot.factory import create_bot, run_bot

# Create an instance* of the configuration mode to use,
# so we can access its __repr__ for logging.
#
# * Note the trailing parentheses: '()'
#
# Valid values for `config_modes()` are:
#   'default', 'dev', 'deploy', 'test'
config = config_modes.get(os.getenv('SLACKSHELLBOT_CONFIG', 'default'))()

if __name__ == '__main__':
    setup_logger(config=config)  # initialize application logging
    run_bot(create_bot(config=config))

    if LOGGER:
        LOGGER.info('Shutting down gracefully...')
        logging.shutdown()
    sys.exit(0)