Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import socket
- import string
- import os #not necassary but later on I am going to use a few features from this
- import time
- CRLF = "\r\n"
- HOST='irc.freenode.net' #The server we want to connect to
- PORT=6667 #The connection port which is usually 6667
- NICK='CamBot' #The bot's nickname
- IDENT='pybot'
- REALNAME='PyBot - Cam'
- OWNER='Cam' #The bot owner's nick
- CHANNEL='##camcam' #The default channel for the bot
- readbuffer='' #Here we store all the messages from server
- s=socket.socket( ) #Create the socket
- s.connect((HOST, PORT)) #Connect to server
- s.send('NICK '+NICK+CRLF) #Send the nick to server
- s.send('USER '+IDENT+' '+HOST+' bla :'+REALNAME+CRLF) #Identify to server
- while 1:
- line=s.recv(500) #recieve server messages
- print line #server message is output
- if line.find("Welcome")!=-1:
- s.send('JOIN '+CHANNEL+CRLF) #Join a channel
- if line.find('!test'):
- line.send("PRIVMSG CHANNEL :Test"+CRLF)
Add Comment
Please, Sign In to add comment