brainwagon "There is much pleasure in useless knowledge." — Bertrand Russell

30Jan/110

A Neighborhood of Infinity: Quine Central

Dan Piponi has a very cool article on nth degree quines on his blog. It's much more understandable than his fascinating but mostly over-my-head postings which I read often, only to be struck by serious feelings of inadequacy.

A Neighborhood of Infinity: Quine Central.

30Jan/110

My speech bot, using irclib.py

Okay, revamped the basic idea, now using the irclib, which in spite of a lack of documentation, actually proved to be pretty easy to use. You should be able to figure out what it does, and modify it to use your own nicks and channel.

#!/usr/bin/env python

import sys
import os
import optparse
import irclib

network = "irc.freenode.net"
port = 6667
channel = "#somechannel"
nick = "SomeNick"
name = "SomeNick is a bot."

irc = irclib.IRC()
server = irc.server()
server.connect(network, port, nick, ircname = name)
server.join(channel)

lastspeaker = None

def handlePubMessage(connection, event):
        global lastspeaker
        target = event.target()
        speaker = event.source().split('!')[0]
        msg = event.arguments()[0]
        print target, ">", speaker, ":", msg
        p = os.popen("festival --tts", "w")
        if speaker != lastspeaker:
                p.write(speaker + " says ")
        p.write(msg)
        p.close()
        lastspeaker = speaker

irc.add_global_handler('pubmsg', handlePubMessage)

irc.process_forever()
Filed under: My Projects No Comments