Ejemplo n.º 1
0
import random
import json
from zenircbot_api import ZenIRCBot, load_config


bot_config = load_config("../bot.json")

zen = ZenIRCBot(bot_config["redis"]["host"], bot_config["redis"]["port"], bot_config["redis"]["db"])


zen.register_commands(
    "twsrs.py",
    [
        {
            "name": "that's what she said",
            "description": ('Replies to "That\'s what she said" with quotes from ' "famous women"),
        }
    ],
)

quote_list = open("twsrs_quotes.txt").readlines()


def get_quote():
    """get_quote"""
    index = random.randint(0, len(quote_list) - 1)
    quote = quote_list[index].strip()
    return quote


sub = zen.get_redis_client().pubsub()
Ejemplo n.º 2
0
import json
import re
import requests
import sys

from zenircbot_api import ZenIRCBot, load_config

bot_config = load_config('../bot.json')

zen = ZenIRCBot(bot_config['redis']['host'], bot_config['redis']['port'],
                bot_config['redis']['db'])

ISSUE = re.compile('^#(\d*)| #(\d*)')
URL = 'https://api.github.com/repos/%s/issues/{nb}' % sys.argv[1]

sub = zen.get_redis_client().pubsub()
sub.subscribe('in')
for msg in sub.listen():
    if msg['type'] != 'message':
        continue
    message = json.loads(msg['data'])
    if message['version'] == 1:
        if message['type'] == 'privmsg':
            text = message['data']['message']
            match = ISSUE.search(text)
            if match:
                issue_nb = match.groups()[0] or match.groups()[1]
                resp = requests.get(URL.format(nb=issue_nb))
                if resp.status_code == 200:
                    msg = "{title} ({state}) - {html_url}".format(**resp.json)
                    zen.send_privmsg(message['data']['channel'], msg)
Ejemplo n.º 3
0
from datetime import datetime, timedelta
from time import sleep
import re

from BeautifulSoup import BeautifulSoup
from feedparser import parse
from zenircbot_api import ZenIRCBot, load_config

bot_config = load_config('../bot.json')

zen = ZenIRCBot(bot_config['redis']['host'], bot_config['redis']['port'],
                bot_config['redis']['db'])

zen.register_commands('jira_feed.py', [])
jira_config = load_config("./jira.json")
jira_url = '%sbrowse/\\1' % jira_config['jira_url']
latest = None


def strtodt(string):
    return datetime.strptime(string, '%Y-%m-%dT%H:%M:%SZ')


while True:
    feed = parse(jira_config['feed_url'])
    if latest is None:
        latest = strtodt(feed['entries'][0].updated) - timedelta(seconds=1)
    entries = [
        entry for entry in feed['entries'] if strtodt(entry.updated) > latest
    ]
    for entry in entries:
Ejemplo n.º 4
0
import random
import json
from zenircbot_api import ZenIRCBot, load_config


bot_config = load_config('../bot.json')

zen = ZenIRCBot(bot_config['redis']['host'],
                bot_config['redis']['port'],
                bot_config['redis']['db'])


zen.register_commands('twsrs.py', [{'name': 'that\'s what she said',
                                    'description': 'Replies to "That\'s what she said" with quotes from famous women'}])

quote_list = open('twsrs_quotes.txt').readlines()

def get_quote():
    """get_quote"""
    index = random.randint(0, len(quote_list) - 1)
    quote = quote_list[index].strip()
    return quote


sub = zen.get_redis_client().pubsub()
sub.subscribe('in')
for msg in sub.listen():
    message = json.loads(msg['data'])
    if message['version'] == 1:
        if message['type'] == 'privmsg':
            text = message['data']['message']
Ejemplo n.º 5
0
from datetime import datetime, timedelta
from time import sleep
import re

from BeautifulSoup import BeautifulSoup
from feedparser import parse
from zenircbot_api import ZenIRCBot, load_config


bot_config = load_config('../bot.json')

zen = ZenIRCBot(bot_config['redis']['host'],
                bot_config['redis']['port'],
                bot_config['redis']['db'])


zen.register_commands('jira_feed.py', [])
jira_config = load_config("./jira.json")
jira_url = '%sbrowse/\\1' % jira_config['jira_url']
latest = None


def strtodt(string):
    return datetime.strptime(string, '%Y-%m-%dT%H:%M:%SZ')


while True:
    feed = parse(jira_config['feed_url'])
    if latest is None:
        latest = strtodt(feed['entries'][0].updated) - timedelta(seconds=1)
    entries = [entry for entry in feed['entries']