Guest User

Untitled

a guest
Jul 22nd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. import sys
  2. import socket
  3. import string
  4. import os #not necassary but later on I am going to use a few features from this
  5. import time
  6. CRLF = "\r\n"
  7. HOST='irc.freenode.net' #The server we want to connect to
  8. PORT=6667 #The connection port which is usually 6667
  9. NICK='CamBot' #The bot's nickname
  10. IDENT='pybot'
  11. REALNAME='PyBot - Cam'
  12. OWNER='Cam' #The bot owner's nick
  13. CHANNEL='##camcam' #The default channel for the bot
  14. readbuffer='' #Here we store all the messages from server
  15.  
  16. s=socket.socket( ) #Create the socket
  17. s.connect((HOST, PORT)) #Connect to server
  18. s.send('NICK '+NICK+CRLF) #Send the nick to server
  19. s.send('USER '+IDENT+' '+HOST+' bla :'+REALNAME+CRLF) #Identify to server
  20.  
  21. while 1:
  22.  
  23. line=s.recv(500) #recieve server messages
  24. print line #server message is output
  25. if line.find("Welcome")!=-1:
  26. s.send('JOIN '+CHANNEL+CRLF) #Join a channel
  27. if line.find('!test'):
  28. line.send("PRIVMSG CHANNEL :Test"+CRLF)
Add Comment
Please, Sign In to add comment