def main():
    conf = configfetcher.ConfigFetcher()
    chanfilter = channelfilter.ChannelFilter()
    bot = Redis2Irc(
        conf=conf,
        builder=messagebuilder.IRCMessageBuilder(),
        chanfilter=chanfilter,
        nick=conf.get('IRC_NICK'),
        autojoins=['#wikimedia-cloud'],
        host=conf.get('IRC_SERVER'),
        port=6697,
        ssl=True,
        password=conf.get('IRC_PASSWORD'),
        realname='wikibugs2',
        userinfo=('Wikibugs v2.1, https://tools.wmflabs.org/wikibugs/ ,' +
                  'running on ' + current_host),
        includes=[
            'irc3.plugins.core',
            'irc3.plugins.ctcp',
            'irc3.plugins.autojoins',
            __name__,  # this register MyPlugin
        ],
        ctcp={
            'finger': '{userinfo}',
            'source': '{userinfo}',
            'version': '{userinfo}',
            'userinfo': '{userinfo}',
            'ping': 'PONG',
        },
    )
    asyncio.Task(redisrunner(bot))
    bot.run()
def test_channelfilter():
    chanfilter = channelfilter.ChannelFilter()
    # An exception would have been raised if that wasn't the case
    print('channels.yaml has valid syntax')

    assert {'#mediawiki-feed', '#wikimedia-releng'} == \
        set(chanfilter.channels_for(['Release-Engineering-Team']))
    assert {'#mediawiki-feed', '#wikimedia-dev', '#wikimedia-releng'} == \
        set(chanfilter.channels_for(['Phabricator']))
    assert {'#mediawiki-feed', '#wikimedia-collaboration', '#pywikibot'} == \
        set(chanfilter.channels_for(['Pywikibot-Flow']))
예제 #3
0
#!/usr/bin/env python

import channelfilter
import json

chanfilter = channelfilter.ChannelFilter()
# An exception would have been raised if that wasn't the case
print('channels.yaml has valid syntax')


def assertEquals(expected, actual):
    assert expected == actual, "\nExpected: %s\nActual:   %s" % (expected, actual)

assertEquals(
    {'#mediawiki-feed', '#wikimedia-releng'},
    set(chanfilter.channels_for(['Continuous-Integration'])))

assertEquals(
    {'#mediawiki-feed', '#wikimedia-devtools', '#wikimedia-dev'},
    set(chanfilter.channels_for(['Phabricator'])))


json.load(open("config.json.example"))
print('config.json.example is valid json')

print('Acceptance tests passed')
예제 #4
0
            if proj_channels:
                channels.union(proj_channels)

        return channels

    def start(self):
        while 1:
            time.sleep(0.1)
            useful_info = self.rqueue.get()
            print(useful_info)
            if useful_info:
                useful_info['matched_projects'] = list(
                    useful_info['projects'])[:]
                useful_info['channel'] = '#wikimedia-labs'
                text = self.builder.build_message(useful_info)
                updated = self.channelfilter.update()
                if updated:
                    print('!log tools.wikibugs Updated channels.yaml to: %s' %
                          updated)

                channels = self.get_channels_for_projects(
                    useful_info['projects'])
                print(','.join(channels) + ': ' + repr(text))


if __name__ == '__main__':
    bot = Redis2Stdout(configfetcher.ConfigFetcher(),
                       messagebuilder.IRCMessageBuilder(),
                       channelfilter.ChannelFilter())
    bot.start()