forked from fedora-infra/fedmsg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
32 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,35 +16,44 @@ | |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
# | ||
# Authors: Ralph Bean <[email protected]> | ||
# Ryan Brown | ||
# | ||
# -*- coding; utf-8 -*- | ||
# Author: Ryan Brown | ||
# Description: A bot that takes a config and puts messages matching given | ||
# regexes in specified IRC channels. See fedmsg-config.py for options. | ||
from fedmsg.commands import command | ||
""" | ||
Description: A bot that takes a config and puts messages matching given | ||
regexes in specified IRC channels. See :term:`irc` for options. | ||
""" | ||
|
||
from fedmsg.commands import BaseCommand | ||
from fedmsg.consumers.ircbot import IRCBotConsumer | ||
|
||
extra_args = [] | ||
|
||
|
||
@command(name="fedmsg-irc", extra_args=extra_args, daemonizable=True) | ||
def ircbot(**kw): | ||
class IRCCommand(BaseCommand): | ||
""" Relay messages from the bus to any number of IRC channels. | ||
This is highly configurable by way of the :term:`irc` config value. | ||
""" | ||
|
||
# Do just like in fedmsg.commands.hub and mangle fedmsg-config.py to work | ||
# with moksha's expected configuration. | ||
moksha_options = dict( | ||
zmq_subscribe_endpoints=','.join( | ||
','.join(bunch) for bunch in kw['endpoints'].values() | ||
), | ||
) | ||
kw.update(moksha_options) | ||
name = "fedmsg-irc" | ||
extra_args = [] | ||
daemonizable = True | ||
|
||
def run(self): | ||
# Do just like in fedmsg.commands.hub and mangle fedmsg-config.py to | ||
# work with moksha's expected configuration. | ||
moksha_options = dict( | ||
zmq_subscribe_endpoints=','.join( | ||
','.join(bunch) for bunch in self.config['endpoints'].values() | ||
), | ||
) | ||
self.config.update(moksha_options) | ||
|
||
self.config[IRCBotConsumer.config_key] = True | ||
|
||
from moksha.hub import main | ||
main(options=self.config, consumers=[IRCBotConsumer]) | ||
|
||
kw[IRCBotConsumer.config_key] = True | ||
|
||
from moksha.hub import main | ||
main(options=kw, consumers=[IRCBotConsumer]) | ||
def ircbot(): | ||
command = IRCCommand() | ||
command.execute() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters