<commit_before>from tehbot.plugins import *
import urllib
from random import *
import shlex

class BlamePlugin(Plugin):
    def execute(self, connection, event, extra, dbconn):
        try:
            pargs = self.parser.parse_args(extra["args"])
            if self.parser.help_requested:
                return self.parser.format_help().strip()
        except Exception as e:
            return u"Error: %s" % str(e)

        space = u"spaceone"
        goats = zip((space for one in range(23)), 42 * [ reduce(random, [], space) ])
        shuffle(goats)
        goats.sort(key=lambda x: random())
        shuffle(goats)
        scapegoat = goats[randint(0, len(goats) - 1)][int(1337 * random()) % 2]
        return u"I blame %s." % scapegoat

register_plugin("blame", BlamePlugin())

class FamPlugin(Plugin):
    """This help at fam"""

    def execute(self, connection, event, extra, dbconn):
        try:
            pargs = self.parser.parse_args(extra["args"])
            if self.parser.help_requested:
                return self.parser.format_help().strip()
        except Exception as e:
            return u"Error: %s" % str(e)

        return ".quoet fom"

register_plugin("fam", FamPlugin())


class LiarsPlugin(Plugin):
    def execute(self, connection, event, extra, dbconn):
        try:
            pargs = self.parser.parse_args(extra["args"])
            if self.parser.help_requested:
                return self.parser.format_help().strip()
        except Exception as e:
            return u"Error: %s" % str(e)

        return "roun, Nimda3, neoxquick, dloser, thefinder"

#register_plugin("liars", LiarsPlugin())

class PricksPlugin(Plugin):
    def execute(self, connection, event, extra, dbconn):
        try:
            pargs = self.parser.parse_args(extra["args"])
            if self.parser.help_requested:
                return self.parser.format_help().strip()
        except Exception as e:
            return u"Error: %s" % str(e)

        return "dloser"

#register_plugin("pricks", PricksPlugin())


class BeerPlugin(Plugin):
    """Serves the best beer on IRC (way better than Lamb3's!)"""

    def query_beers(self, dbconn):
        c = dbconn.execute("select value from BeerPlugin where key='beers'")
        res = c.fetchone()
        if res is None:
            return 0
        beers = int(res[0])

        if beers > 0:
            with dbconn:
                dbconn.execute("update BeerPlugin set value=? where key='beers'", (str(beers - 1), ))

        return beers

    def refill(self, dbconn, beers=10):
        with dbconn:
            dbconn.execute("update BeerPlugin set value=value+? where key='beers'", (str(beers), ))

    def __init__(self):
        Plugin.__init__(self)
        group = self.parser.add_mutually_exclusive_group()
        group.add_argument("recpt", nargs="?")
        group.add_argument("--refill", action="store_true")

    def execute(self, connection, event, extra, dbconn):
        self.parser.set_defaults(recpt=event.source.nick)

        try:
            pargs = self.parser.parse_args(extra["args"])
            if self.parser.help_requested:
                return self.parser.format_help().strip()
        except Exception as e:
            return u"Error: %s" % str(e)

        if pargs.refill:
            self.refill(dbconn)
            return u"Ok, beer refilled. That was easy, hu?"

        beers = self.query_beers(dbconn)
        if beers == 0:
            return [("me", u"has no beer left :(")]

        if pargs.recpt == event.source.nick:
            return [("me", u"passes 1 of %d bottles of cold beer around to %s" % (beers, event.source.nick))]

        return [("me", u"and %s pass 1 of %d bottles of cold beer around to %s" % (event.source.nick, beers, pargs.recpt))]

register_plugin("beer", BeerPlugin())


from socket import *
import string
import time
import tehbot.plugins as plugins
class BOSPlugin(Plugin):
    """Can you solve The BrownOS? [WeChall]"""
    def __init__(self):
        Plugin.__init__(self)
        self.parser.add_argument("data", nargs=1)

    def execute(self, connection, event, extra, dbconn):
        try:
            pargs = self.parser.parse_args(extra["args"])
            if self.parser.help_requested:
                return self.parser.format_help().strip()
        except Exception as e:
            return u"Error: %s" % str(e)<commit_msg>add --status to BeerPlugin<commit_after>from tehbot.plugins import *
import urllib
from random import *
import shlex

class BlamePlugin(Plugin):
    def execute(self, connection, event, extra, dbconn):
        try:
            pargs = self.parser.parse_args(extra["args"])
            if self.parser.help_requested:
                return self.parser.format_help().strip()
        except Exception as e:
            return u"Error: %s" % str(e)

        space = u"spaceone"
        goats = zip((space for one in range(23)), 42 * [ reduce(random, [], space) ])
        shuffle(goats)
        goats.sort(key=lambda x: random())
        shuffle(goats)
        scapegoat = goats[randint(0, len(goats) - 1)][int(1337 * random()) % 2]
        return u"I blame %s." % scapegoat

register_plugin("blame", BlamePlugin())

class FamPlugin(Plugin):
    """This help at fam"""

    def execute(self, connection, event, extra, dbconn):
        try:
            pargs = self.parser.parse_args(extra["args"])
            if self.parser.help_requested:
                return self.parser.format_help().strip()
        except Exception as e:
            return u"Error: %s" % str(e)

        return ".quoet fom"

register_plugin("fam", FamPlugin())


class LiarsPlugin(Plugin):
    def execute(self, connection, event, extra, dbconn):
        try:
            pargs = self.parser.parse_args(extra["args"])
            if self.parser.help_requested:
                return self.parser.format_help().strip()
        except Exception as e:
            return u"Error: %s" % str(e)

        return "roun, Nimda3, neoxquick, dloser, thefinder"

#register_plugin("liars", LiarsPlugin())

class PricksPlugin(Plugin):
    def execute(self, connection, event, extra, dbconn):
        try:
            pargs = self.parser.parse_args(extra["args"])
            if self.parser.help_requested:
                return self.parser.format_help().strip()
        except Exception as e:
            return u"Error: %s" % str(e)

        return "dloser"

#register_plugin("pricks", PricksPlugin())


class BeerPlugin(Plugin):
    """Serves the best beer on IRC (way better than Lamb3's!)"""

    def beers(self, dbconn):
        c = dbconn.execute("select value from BeerPlugin where key='beers'")
        res = c.fetchone()
        if res is None:
            return 0
        return int(res[0])

    def get_beer(self, dbconn):
        beers = self.beers(dbconn)

        if beers > 0:
            with dbconn:
                dbconn.execute("update BeerPlugin set value=? where key='beers'", (str(beers - 1), ))

        return beers

    def refill(self, dbconn, beers=10):
        with dbconn:
            dbconn.execute("update BeerPlugin set value=value+? where key='beers'", (str(beers), ))

    def __init__(self):
        Plugin.__init__(self)
        group = self.parser.add_mutually_exclusive_group()
        group.add_argument("recipient", nargs="?")
        group.add_argument("--refill", action="store_true")
        group.add_argument("--status", action="store_true")

    def execute(self, connection, event, extra, dbconn):
        self.parser.set_defaults(recipient=event.source.nick)

        try:
            pargs = self.parser.parse_args(extra["args"])
            if self.parser.help_requested:
                return self.parser.format_help().strip()
        except Exception as e:
            return u"Error: %s" % str(e)

        if pargs.status:
            beers = self.beers(dbconn)
            if beers < 1:
                msg = u"has no beer left. :("
            elif beers == 1:
                msg = u"has one beer left."
            else:
                msg = u"has %d beers left." % beers
            return [("me", msg)]

        if pargs.refill:
            if not self.privileged(connection, event):
                return self.request_priv(extra)

            self.refill(dbconn)
            return u"Ok, beer refilled. That was easy, hu?"

        beers = self.get_beer(dbconn)
        if beers == 0:
            return [("me", u"has no beer left. :(")]

        if pargs.recipient == event.source.nick:
            if beers == 1:
                msg = u"passes the last bottle of cold beer around to %s." % event.source.nick
            else:
                msg = u"passes 1 of %d bottles of cold beer around to %s." % (beers, event.source.nick)
        else:
            if beers == 1:
                msg = u"and %s pass the last bottle of cold beer around to %s." % (event.source.nick, pargs.recipient)
            else:
                msg = u"and %s pass 1 of %d bottles of cold beer around to %s." % (event.source.nick, beers, pargs.recipient)
        return [("me", msg)]

register_plugin("beer", BeerPlugin())


from socket import *
import string
import time
import tehbot.plugins as plugins
class BOSPlugin(Plugin):
    """Can you solve The BrownOS? [WeChall]"""
    def __init__(self):
        Plugin.__init__(self)
        self.parser.add_argument("data", nargs=1)

    def execute(self, connection, event, extra, dbconn):
        try:
            pargs = self.parser.parse_args(extra["args"])
            if self.parser.help_requested:
                return self.parser.format_help().strip()
        except Exception as e:
            return u"Error: %s" % str(e)
{'fraction_non_alphanumeric': 0.12400455062571103, 'fraction_numerical': 0.005171165580721894, 'mean_word_length': 2.250420168067227, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '947083', 'n_tokens_mistral': 3022, 'n_tokens_neox': 2877, 'n_words': 778}