Skip to content

Instantly share code, notes, and snippets.

@anna-is-cute
Last active October 12, 2015 22:11
Show Gist options
  • Save anna-is-cute/80b36c2af83d2d86d2f9 to your computer and use it in GitHub Desktop.
Save anna-is-cute/80b36c2af83d2d86d2f9 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
from irc3 import plugin, IrcBot
from bottle import route, run, request, response
from threading import Thread
bot = None
@route("/<INSERT UNIQUE SHIT HERE>", method="POST")
def index():
if bot is None:
print("bot not assigned")
return
json = request.json
totals = json['report']['totals']
msg = '[\u0002\u000313{repo}\u000f/\u000306{branch}\u000f] \u000314{short_commit}\u000f {coverage}% coverage: \u000309{hit}\u000fh\u000307{partial}\u000fp\u000304{miss}\u000fm in \u0002{files}\u000f file{files_plural}'.format(
repo = json['repo'],
branch = json['branch'],
short_commit = json['commitid'][:7],
coverage = json['coverage'],
hit = totals['hit'],
partial = totals['partial'],
miss = totals['missed'],
files = totals['files'],
files_plural = 's' if totals['files'] != 1 else ''
)
bot.privmsg('#chan', msg)
@plugin
class Plugin(object):
def __init__(self, bot):
self.bot = bot
def start_bot():
global bot
config = dict(
nick='Nick', autojoins=['#chan'],
host='irc.example.com', port=6667, ssl=False,
#password='password',
includes=[
'irc3.plugins.core',
__name__,
]
)
bot = IrcBot.from_config(config)
bot.run(forever=True)
def start_web():
run(host="0.0.0.0", port=9000)
def main():
t = Thread(target=start_web)
t.start()
start_bot()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment