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.
[sourcecode lang=”python”]
#!/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()
[/sourcecode]
I suspect the world would be better if that percentage were even greater.
Apparently 15% of all web traffic is cat related. There's no reason for Brainwagon be any different.
Thanks Mal! I'm trying to reclaim the time that I was using doom scrolling and writing pointless political diatribes on…
Brainwagons back! I can't help you with a job, not least because I'm on the other side of our little…
Congrats, glad to hear all is well.