Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket
- server = "redoasis.com"
- channel = "#mr.nose"
- botnick = "goquin"
- pongmessage = ""#thismessage is only seen by the server
- def ping():
- ircsock.send("PONG :"+ pongmessage +"\n")
- def sendmsg(chan , msg):
- ircsock.send("PRIVMSG "+ chan +" :"+ msg +"\n")
- def joinchan(chan):
- ircsock.send("JOIN "+ chan +"\n")
- def hello():
- ircsock.send("PRIVMSG "+ channel +" :Yo\n")
- ircsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- ircsock.connect((server, 6667))
- ircsock.send("USER "+ botnick +" "+ botnick +" "+ botnick +" :goquin.\n")
- ircsock.send("NICK "+ botnick +"\n")
- joinchan(channel)
- while 1: # Be careful with these! it might send you to an infinite loop
- ircmsg = ircsock.recv(2048)
- ircmsg = ircmsg.strip('\n\r')
- print(ircmsg)
- if ircmsg.find(":Hello "+ botnick) != -1:
- hello()
- if ircmsg.find("PING :") != -1:
- ping()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement