Exemple #1
0
def build_sweetiebot(config=None):
    if config is None: import config
    resource = config.nickname + randomstr()
    if config.fake_redis:
        log.debug('faking out redis')
        redis_conn = FakeRedis()
    else:
        redis_conn = redis.from_url(config.redis_url)

    jid = config.username + '/' + resource
    nick = config.nickname
    room = config.chatroom
    password = config.password
    if config.hostname is not None:
        address = (config.hostname, config.port)
    else:
        address = ()

    bot = MUCJabberBot(jid, password, room, nick, address)
    crest = SweetieCrest(config.crest_base_url, config.crest_client_id,
                         config.crest_client_secret,
                         config.crest_refresh_token)
    lookup = SweetieLookup(bot, crest)
    admin = SweetieAdmin(bot, config.chatroom)
    mq = SweetieMQ(config)
    de = SweetieDe(bot, admin, mq, ResponsesFile('data/deowl_fails.txt'))
    actions = ResponsesFile('data/actions.txt')
    sass = ResponsesFile('data/sass.txt')
    cadmusic = ResponsesFile('data/cadmusic.txt')
    tell = SweetieTell(bot, redis_conn)
    dictionary = SweetieDictionary(bot)
    chat = SweetieChat(bot, actions, sass, config.chatroom, cadmusic, tell,
                       dictionary)
    roulette = SweetieRoulette(bot, admin)
    pings = SweetiePings(bot, redis_conn)
    moon = SweetieMoon(bot)
    if config.twitter_key is not None:
        twitter = TwitterClient.get_client(config.twitter_key,
                                           config.twitter_secret)
        watchers = list(map(twitter.get_timeline_watcher, ['EVE_Status']))
    else:
        watchers = []
    watchers.append(
        AtomWatcher.get_watcher(
            'http://eveion.blogspot.com/feeds/posts/default'))
    seen = SweetieSeen(bot, redis_conn)

    sweet = Sweetiebot(config.nickname, bot, lookup, mq, admin, chat, roulette,
                       de, pings, watchers, moon)
    return sweet
Exemple #2
0
    def setUp(self):
        self.bot = MagicMock()
        self.bot.get_jid_from_nick.side_effect = self.get_jid
        self.store = FakeRedis()

        self.tell = SweetieTell(self.bot, self.store)