# Path: grazyna/utils/event_loop.py
# def loop(time_config_key, default):
#     def outter(old_func):
#         func = asyncio.coroutine(old_func)
#         @asyncio.coroutine
#         @wraps(func)
#         def inner(protocol, plugin, future):
#             while True:
#                 if future.cancelled():
#                     break
#                 cfg = protocol.config['plugin:%s' % plugin.name]
#                 time_to_sleep = cfg.getint(time_config_key, default)
#                 if time_to_sleep == 0:
#                     break
# 
#                 if protocol.ready:
#                     #special random delay
#                     yield from asyncio.sleep(random() * 3)
#                     try:
#                         yield from func(protocol, plugin, cfg)
#                     except:
#                         traceback.print_exc(file=sys.stdout)
# 
#                 yield from asyncio.sleep(time_to_sleep)
#         inner.is_loop = True
#         return inner
#     return outter
# 
# Path: grazyna/format.py
# def color(msg, front, back=None):
#     if back:
#         front = '%d,%d' % (front, back)
#     else:
#         front = str(front)
#     return "\x03%s%s\x03" % (front, msg)
# 
# def bold(msg):
#     return "\x02%s\x02" % msg


import asyncio
from aiohttp import ClientSession, ClientError
from grazyna.utils.event_loop import loop
from grazyna.format import color, bold
        return

    msg = "‼ {commit} '{msg}' by {committer} {url}".format(
        commit=bold('COMMIT'),
        msg=strip(data['commit']['message']),
        committer=data['commit']['author']['name'],
        url=data['html_url']
    )

    for chan in config['channels'].split(','):
        irc_protocol.say(chan.strip(), msg)


@loop(time_config_key="events_time", default=60)
def events(irc_protocol, plugin, config):
    try:
        data = yield from github_action('issues/events', plugin, config)
    except POSSIBLE_EXCEPTIONS:
        return

    issue = data['issue']
    state = data['event']
    state_color = state_colors.get(state, color.black)
    assignee = issue['assignee']
    assignee_login = assignee['login'] if assignee is not None else None
    msg = ("‼ {issue} {labels} '{title}' by {user} "
           "{assignee} {state} {url}").format(
        issue=bold('ISSUE'),
        labels=' '.join('[%s]' % label['name'] for label in issue['labels']),
        title=strip(issue['title']),

# Path: grazyna/utils/event_loop.py
# def loop(time_config_key, default):
#     def outter(old_func):
#         func = asyncio.coroutine(old_func)
#         @asyncio.coroutine
#         @wraps(func)
#         def inner(protocol, plugin, future):
#             while True:
#                 if future.cancelled():
#                     break
#                 cfg = protocol.config['plugin:%s' % plugin.name]
#                 time_to_sleep = cfg.getint(time_config_key, default)
#                 if time_to_sleep == 0:
#                     break
# 
#                 if protocol.ready:
#                     #special random delay
#                     yield from asyncio.sleep(random() * 3)
#                     try:
#                         yield from func(protocol, plugin, cfg)
#                     except:
#                         traceback.print_exc(file=sys.stdout)
# 
#                 yield from asyncio.sleep(time_to_sleep)
#         inner.is_loop = True
#         return inner
#     return outter
# 
# Path: grazyna/format.py
# def color(msg, front, back=None):
#     if back:
#         front = '%d,%d' % (front, back)
#     else:
#         front = str(front)
#     return "\x03%s%s\x03" % (front, msg)
# 
# def bold(msg):
#     return "\x02%s\x02" % msg


# Path: grazyna/plugins/github.py
import asyncio
from aiohttp import ClientSession, ClientError
from grazyna.utils.event_loop import loop
from grazyna.format import color, bold

        return

    msg = "‼ {commit} '{msg}' by {committer} {url}".format(
        commit=bold('COMMIT'),
        msg=strip(data['commit']['message']),
        committer=data['commit']['author']['name'],
        url=data['html_url']
    )

    for chan in config['channels'].split(','):
        irc_protocol.say(chan.strip(), msg)


@loop(time_config_key="events_time", default=60)
def events(irc_protocol, plugin, config):
    try:
        data = yield from github_action('issues/events', plugin, config)
    except POSSIBLE_EXCEPTIONS:
        return

    issue = data['issue']
    state = data['event']
    state_color = state_colors.get(state, color.black)
    assignee = issue['assignee']
    assignee_login = assignee['login'] if assignee is not None else None
    msg = ("‼ {issue} {labels} '{title}' by {user} "
           "{assignee} {state} {url}").format(
        issue=bold('ISSUE'),
        labels=' '.join('[%s]' % label['name'] for label in issue['labels']),
        title=strip(issue['title']),

        state=bold(color(' %s ' % state, color.white, state_color)),