Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket, string, os, re, time
- #some user data, change as per your taste
- SERVER = 'irc.freenode.net'
- PORT = 6667
- NICKNAME = 'MsgToSpeech'
- CHANNEL = '#itunix-eu'
- #open a socket to handle the connection
- IRC = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- #open a connection with the server
- def irc_conn():
- IRC.connect((SERVER, PORT))
- #simple function to send data through the socket
- def send_data(command):
- IRC.send(command + '\n')
- #join the channel
- def join(channel):
- send_data("JOIN %s" % channel)
- #send login data (customizable)
- def login(nickname, username='user', password = None, realname='Pythonist', hostname='Helena', servername='Server'):
- send_data("USER %s %s %s %s" % (username, hostname, servername, realname))
- send_data("NICK " + nickname)
- irc_conn()
- login(NICKNAME)
- join(CHANNEL)
- while (1):
- buffer = IRC.recv(1024)
- msg = string.split(buffer)
- if msg [1] == 'PRIVMSG':
- message = ' '.join(msg[3:])
- print message
- os.system('espeak -v en "{0}" --stdout | aplay 2>/dev/null >/dev/null'.format(message)) #speech this!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement