Exemplo n.º 1
0
Arquivo: seen.py Projeto: nslater/saxo
def record(irc):
    if irc.sender.startswith("#"):
        path = os.path.join(irc.base, "database.sqlite3")
        with saxo.database(path) as db:
            if "saxo_seen" in db:
                # TODO: db["saxo_seen"].replace
                command = "INSERT OR REPLACE INTO saxo_seen" + " (nick,unixtime,channel) VALUES(?,?,?)"
                db.execute(command, irc.nick, int(time.time()), irc.sender)
                db.commit()
Exemplo n.º 2
0
Arquivo: seen.py Projeto: nslater/saxo
def setup(irc):
    path = os.path.join(irc.base, "database.sqlite3")
    with saxo.database(path) as db:
        if "saxo_seen" not in db:
            db["saxo_seen"].create(("nick", "TEXT PRIMARY KEY"), ("unixtime", int), ("channel", str))
        # TODO: Drop nicknames seen more than a year ago

        if "saxo_private" not in db:
            db["saxo_private"].create(("channel", "TEXT PRIMARY KEY"))
Exemplo n.º 3
0
def setup(irc):
    path = os.path.join(irc.base, "database.sqlite3")
    with saxo.database(path) as db:
        if "saxo_seen" not in db:
            db["saxo_seen"].create(("nick", "TEXT PRIMARY KEY"),
                                   ("unixtime", int), ("channel", str))
        # TODO: Drop nicknames seen more than a year ago

        if "saxo_private" not in db:
            db["saxo_private"].create(("channel", "TEXT PRIMARY KEY"))
Exemplo n.º 4
0
def record(irc):
    if irc.sender.startswith("#"):
        path = os.path.join(irc.base, "database.sqlite3")
        with saxo.database(path) as db:
            if "saxo_seen" in db:
                # TODO: db["saxo_seen"].replace
                command = "INSERT OR REPLACE INTO saxo_seen" + \
                    " (nick,unixtime,channel) VALUES(?,?,?)"
                db.execute(command, irc.nick, int(time.time()), irc.sender)
                db.commit()
Exemplo n.º 5
0
def setup(irc):
    path = os.path.join(irc.base, "database.sqlite3")
    with saxo.database(path) as db:
        if "saxo_to" not in db:
            db["saxo_to"].create(
                ("sender", str),
                ("recipient", str),
                ("unixtime", int),
                ("channel", str),
                ("message", str))
Exemplo n.º 6
0
Arquivo: to.py Projeto: candeira/saxo
def setup(irc):
    path = os.path.join(irc.base, "database.sqlite3")
    with saxo.database(path) as db:
        if "saxo_to" not in db:
            db["saxo_to"].create(
                ("sender", str),
                ("recipient", str),
                ("unixtime", int),
                ("channel", str),
                ("message", str))
Exemplo n.º 7
0
def remove_unicode_data(irc):
    if "owner" in irc.config:
        if irc.prefix == irc.config["owner"]:
            path = os.path.join(irc.base, "database.sqlite3")
            with saxo.database(path) as db:
                if "saxo_unicode" in db:
                    delete_table(db)
                    irc.say("Removed saxo_unicode from database.sqlite3")
                else:
                    irc.say("No saxo_unicode table in database.sqlite3")
Exemplo n.º 8
0
Arquivo: seen.py Projeto: nslater/saxo
def private_channel(irc):
    if "owner" in irc.config:
        if irc.prefix == irc.config["owner"]:
            path = os.path.join(irc.base, "database.sqlite3")
            with saxo.database(path) as db:
                if "saxo_private" in db:
                    command = "INSERT OR REPLACE INTO saxo_private" + " (channel) VALUES(?)"
                    db.execute(command, irc.arg)
                    db.commit()
                    irc.say("Set %s as private" % irc.arg)
Exemplo n.º 9
0
def update_unicode_data(irc):
    if "owner" in irc.config:
        if irc.prefix == irc.config["owner"]:
            path = os.path.join(irc.base, "database.sqlite3")
            with saxo.database(path) as db:
                if "saxo_unicode" in db:
                    delete_table(db)
                create_table(db)
                irc.say("Downloading UnicodeData.txt from unicode.org...")
                populate_table_web(db)
                irc.say("Updated saxo_unicode in database.sqlite3")
Exemplo n.º 10
0
def deliver(irc):
    path = os.path.join(irc.base, "database.sqlite3")
    with saxo.database(path) as db:
        query = "SELECT * FROM saxo_to WHERE recipient = ?"
        for row in db.query(query, irc.nick):
            print(row)
            recipient = row[1]
            sender = row[0]
            message = row[4]
            irc.say("%s: <%s> %s" % (recipient, sender, message))
            del db["saxo_to"][row]
Exemplo n.º 11
0
Arquivo: to.py Projeto: candeira/saxo
def deliver(irc):
    path = os.path.join(irc.base, "database.sqlite3")
    with saxo.database(path) as db:
        query = "SELECT * FROM saxo_to WHERE recipient = ?"
        for row in db.query(query, irc.nick):
            print(row)
            recipient = row[1]
            sender = row[0]
            message = row[4]
            irc.say("%s: <%s> %s" % (recipient, sender, message))
            del db["saxo_to"][row]
Exemplo n.º 12
0
Arquivo: to.py Projeto: zort/saxo
def deliver(irc):
    path = os.path.join(irc.base, "database.sqlite3")
    with saxo.database(path) as db:
        query = "SELECT * FROM saxo_to WHERE recipient = ? COLLATE NOCASE"
        for row in db.query(query, irc.nick.strip("_-`")):
            print(row)
            sender = row[0]
            recipient = row[1]
            unixtime = row[2]
            message = row[4]
            sender = sender.replace("Phoenix", random.choice(["ponik", "ponix"]))
            irc.say("%s: <%s> %s [%s]" % (irc.nick, sender, message, time.ctime(unixtime)))
            del db["saxo_to"][row]
Exemplo n.º 13
0
Arquivo: seen.py Projeto: nslater/saxo
def public_channel(irc):
    if "owner" in irc.config:
        if irc.prefix == irc.config["owner"]:
            path = os.path.join(irc.base, "database.sqlite3")
            with saxo.database(path) as db:
                if "saxo_private" in db:
                    deleted = False
                    query = "SELECT * FROM saxo_private WHERE channel = ?"
                    for row in db.query(query, irc.arg):
                        del db["saxo_private"][row]
                        deleted = True
                    if deleted:
                        irc.say("Set %s as public" % irc.arg)
                    else:
                        irc.say("Already set as public")
Exemplo n.º 14
0
Arquivo: seen.py Projeto: nslater/saxo
def seen(irc):
    path = os.path.join(irc.base, "database.sqlite3")
    with saxo.database(path) as db:
        if "saxo_seen" in db:
            query = "SELECT * FROM saxo_seen WHERE nick = ?"
            for (nick, unixtime, channel) in db.query(query, irc.arg):
                private = False
                query = "SELECT * FROM saxo_private WHERE channel = ?"
                for row in db.query(query, channel):
                    if row[0] == channel:
                        private = True
                        break
                if not private:
                    formatted = time.ctime(unixtime)
                    irc.say("%s was on %s at %s" % (nick, channel, formatted))
                else:
                    irc.say("Sorry, there is no available data")
                break
        else:
            irc.say("Sorry, there is no saxo_seen database table")
Exemplo n.º 15
0
def setup(irc):
    path = os.path.join(irc.base, "database.sqlite3")
    with saxo.database(path) as db:
        if "saxo_unicode" not in db:
            create_table(db)
            populate_table_python(db)
Exemplo n.º 16
0
Arquivo: yo.py Projeto: zort/saxo
def deliver(irc):
    path = os.path.join(irc.base, "database.sqlite3")
    with saxo.database(path) as db:
        query = "SELECT * FROM saxo_yo WHERE recipient = ? COLLATE NOCASE"
        for row in db.query(query, irc.nick.strip("_-`")):
            print(row)
            message = row[4]
            def MC(message):
                splitted = message.split(maxsplit=1)
                if len(splitted) == 1:
                    return 'Yo, I\'m MC {0} and I\'m here to say,'.format(*splitted)
                else:
                    return 'Yo, I\'m MC {0} and I\'m here to say, {1}'.format(*splitted)
            quote = choice([
                    'The old man down the road says, "%s"'
                    ,'A little bird said, "%s", and flew away.'
                    ,"There's a rumour going around that %s"
                    ,'Nobody can deny that %s'
                    ,'There was a message in a bottle: "%s"'
                    ,'The tea leaves spell out: "%s"'
                    ,'I once heard this: "%s"'
                    ,'Yo, by the way, %s'
                    ,'At night, they howl and they cackle, and their words are: "%s"'
                    ,'If you listen carefully to the wind, you can hear "%s"'
                    ,'Heed this, and you shall prosper: "%s"'
                    ,'Some babies\' first words are "%s"'
                    ,MC
                    ,'It\'s forseeable that %s'
                    ,'Ancient scriptures read: "%s"'
                    ,'Your horoscope for today (or since last horoscope): "%s"'
                    ,'The alignment of the stars foretell %s'
                    ,'The townsfolk mutter about %s'
                    ,'The monks in the forest chant "%s"'
                    ,'From the depths of the well echoes a voice murmuring, "%s"'
                    ,'The tarot cards predict %s'
                    ,'The answer to Life, the Universe and Everything is: %s'
                    ,'Once a generation, someone has this brilliant thought: %s'
                    ,'Don\'t do drugs, they ruin you. Also, %s'
                    ,'Protect your environment. Also, %s'
                    ,'Don\'t do drugs, they ruin you. Also, protect your environment. Also, %s'
                    ,'Don\'t forget: "%s"'
                    ,'As William Wallace used to say, "%s"'
                    ,'Even the ancients knew: %s'
                    ,'The bible contains the encoded message: "%s"'
                    ,'If you put a seashell to your ear, you can hear "%s"'
                    ,'Any undergraduate can tell you that %s'
                    ,'The message you have been tasked to deliver is: "%s"'
                    ,'They go my niggaz all up in da hood sayin\' "%s"'
                    ,'Dem hoes keep tryin to buck my rides, one spittin\' "%s"'
                    ,'It was complete darkness. The little boy heard a whisper coming from the closed wardrobe: "%s%"'
                    ,'"%s" is a lie.'
                    ,'"%s" is the truth.'
                    ,'Only idiots say things like "%s"'
                    ,'I have been told that "%s" is a must.'
                    ,'"%s" and a puppy just died.'
                    ,'Money cannot buy you "%s".'
                    ,irc.nick + ', you are the ugliest person on this planet. But "%s".'
                    ,'Here, "%s". By the way, ' + irc.nick + ' is a terrible name.'
                    ,'I have a message for you written with blood: "%s"'
                    ,irc.nick + ', I will kill you in your sleep, whispering "%s".'
                    ,'Dear ' + irc.nick + ', please stop playing with yourself while moaning "%s".'
                    ,'In this room %s is turning me on, but %%s' % irc.nick
                    ,'Goddamnit %s! Here have your smelly message: %%s' % irc.nick
                    ])
            irc.say(quote % message if type(quote) == type("") else quote(message))
            del db["saxo_yo"][row]
Exemplo n.º 17
0
def setup(irc):
    path = os.path.join(irc.base, "database.sqlite3")
    with saxo.database(path) as db:
        if "saxo_unicode" not in db:
            create_table(db)
            populate_table_python(db)