import sys
import socket
import string
import os
host = "irc.freenode.net" # the irc server
port = 6667 # port number
nick = "aussiebot" # nickname
ident = "aussiebot" # identity
realname = "aussiebot" # the name of the bot
owner = "Guardian-PFD" # who made it
channel = "##aussiepowder"
server_msg = "" # messages from the server and client
s = socket.socket() # open socket
s.connect((host, port)) # connect to server
s.send("Nick: "+nick+"\n") # we send the nickname to the server
s.send("User: "+ident+" "+host+" Name: "+realname+"\n")
while 1:
line = s.recv(500) # recieve the server messages
print(line)
if line.find("Welcome to the aussie powder IRC network!!!") != -1: # join #c0dingf0x
s.send("JOIN "+channel+"\n")
if line.find("PRIVMSG") != -1:
parsemsg(line)
line = line.rstrip()
line = line.split()
if(line[0] == "PING"):
s.send("PONG "+line[1]+"\n")
def parsemsg(msg):
complete = msg[1: ].split(":", 1) # Parse the message into useful data
info = complete[0].split(" ")
msgpart = complete[1]
sender = info[0].split("!")
if msgpart[0] == "$" and sender[0] == owner: # treat messge starting with $ as a command
cmd = msgpart[1: ].split(" ")
if cmd[0] == "op":
s.send("MODE "+info[2]+" +o "+cmd[1]+"\n")
if cmd[0] == "deop":
s.send("MODE "+info[2]+" -o "+cmd[1]+"\n")
if cmd[0] == "voice":
s.send("MODE "+info[2]+" +v "+cmd[1]+"\n")
if cmd[0] == "devoice":
s.send("MODE "+info[2]+" -v "+cmd[1]+"\n")
if cmd[0] == "sys":
syscmd(msgpart[1: ], info[2])
if msgpart[0] == "_" and sender[0] == owner: # treat messages with _ as explict command sent to the server
cmd = msgpart[1: ]
s.send(cmd+"\n")
print("cmd = "+cmd)
def syscmd(commandline, channel):
cmd = commandline.replace("sys ", "")
cmd = cmd.rstrip()
os.system(cmd+" >temp.txt")
a = open("temp.txt")
ot = a.read()
ot.replace("\n", "|")
a.close()
s.send("PRIVMSG "+channel+" :"+ot+"\n")
i have this error:
Traceback (most recent call last):
File "C:\Python32\aussiebot", line 17, in <module>
s.send("Nick: "+nick+"\n") # we send the nickname to the server
TypeError: 'str' does not support the buffer interface

New Topic/Question
Reply



MultiQuote





|