Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import platform
- import socket
- import getpass
- # Global Variables
- ircsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- server = "your.server.choice"
- channel = "#YourChannelHere"
- # IRC Socket & User/Nick Functions
- ircsock.connect((server, 6667))
- ircsock.send(bytes("USER "+ botnick +" "+ botnick +" "+ botnick + " " + botnick + "\n", "UTF-8"))
- ircsock.send(bytes("NICK "+ botnick +"\n", "UTF-8")) # assign the nick to the bot
- # System Info
- username = getpass.getuser()
- hostname = socket.gethostname()
- PS = platform.system()
- PR = platform.release()
- PS = "Z"
- PR = "6"
- if PS == "Windows":
- PS3 = "W"
- if PR == "8.1":
- PR3 = "8"
- if PR == "Vista":
- PR3 = "V"
- # Respond to Pings
- def ping():
- global ircsock
- ircsock.send(bytes("PONG :pingis\n", "UTF-8"))
- # Join Channel & Strip & Print Messages from IRC
- def joinchan(chan):
- ircsock.send(bytes("JOIN "+ chan +"\n", "UTF-8"))
- ircmsg = ""
- while ircmsg.find("End of /NAMES list.") == -1:
- ircmsg = ircsock.recv(2048).decode("UTF-8")
- ircmsg = ircmsg.strip('\n\r')
- print(ircmsg)
- def main():
- joinchan(channel)
- while 1:
- ircmsg = ircsock.recv(2048).decode("UTF-8")
- ircmsg = ircmsg.strip('\n\r')
- print(ircmsg)
- if ircmsg.find("PING :") != -1:
- ping()
- if ircmsg.find("PRIVMSG") != -1:
- name = ircmsg.split('!', 1)[0][1:]
- message = ircmsg.split('PRIVMSG', 1)[1].split(':', 1)[1]
- if len(name) < 17:
- if ircmsg.find("PING :") != -1:
- ping()
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement