Skip to content

Commit

Permalink
Merge pull request #3 from ozzy2345/master
Browse files Browse the repository at this point in the history
Adding display name
  • Loading branch information
zoh48gz04 committed Aug 5, 2012
2 parents 7818dcf + 78a3c54 commit abc17f5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
17 changes: 9 additions & 8 deletions plaudereckenbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,24 @@


class pBot:
def __init__(self, ip, port, username, password, sid, channellist, cpid):
def __init__(self, ip, port, username, password, displayname, sid, channellist, cpid):
self.ip = ip
self.port = port
self.username = username
self.password = password
self.sid = sid
self.channellist = channellist
self.cpid = cpid
self.connect(ip, port, username, password, sid)
self.connect(ip, port, username, password, displayname, sid)

def connect(self, ip, port, username, password, sid):
def connect(self, ip, port, username, password, displayname, sid):
self.teamspeak = PyTS3.ServerQuery(ip, port)
if self.teamspeak.connect() == False:
print "Could not connect"
os._exit(7)
self.teamspeak.command("login " + username + " " + password)
self.teamspeak.command("use " + str(sid))
self.teamspeak.command("clientupdate client_nickname=" + self.teamspeak.string2escaping(displayname))

def getUserInfo(self):
self.userInfo = self.teamspeak.command("clientlist")
Expand All @@ -43,13 +44,13 @@ def getChannelUsers(self, cid):
def addChannel(self):
#print str(self.channellist[len(self.channellist) - 1])
y = str("channelcreate channel_name=Plauderecke\s"
+ str(len(self.channellist) + 1) + " channel_order="
+ str(self.channellist[len(self.channellist) - 1]) + "")
+ str(len(self.channellist) + 1) + " channel_order="
+ str(self.channellist[len(self.channellist) - 1]) + "")
print y
x = self.teamspeak.command("channelcreate channel_name=Plauderecke\s"
+ str(len(self.channellist) + 1) + " channel_order="
+ str(self.channellist[len(self.channellist) - 1]) +
" cpid=" + str(self.cpid) + " channel_flag_semi_permanent=1 CHANNEL CODEC")
+ str(len(self.channellist) + 1) + " channel_order="
+ str(self.channellist[len(self.channellist) - 1]) +
" cpid=" + str(self.cpid) + " channel_flag_semi_permanent=1 CHANNEL CODEC")
print x
if isinstance(x['cid'], int):
self.channellist.append(x['cid'])
Expand Down
13 changes: 7 additions & 6 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
PORT = 10011
USERNAME = "serveradmin"
PASSWORD = ""
DISPLAYNAME = "Plauderecken-Bot"
SID = 1
ORIGINALCHANNELS = []
CHANNELLIST = [] # == ORIGINALCHANNELS
ORIGINALCHANNELS = [151, 152, 153]
CHANNELLIST = [151, 152, 153] # == ORIGINALCHANNELS
CPID = 54
pBot = plaudereckenbot.pBot(IP, PORT, USERNAME, PASSWORD,
SID, CHANNELLIST, CPID)
pBot = plaudereckenbot.pBot(IP, PORT, USERNAME, PASSWORD, DISPLAYNAME,
SID, CHANNELLIST, CPID)
while 1:
emptyRooms = 0
pBot.getUserInfo()
Expand All @@ -25,7 +26,7 @@
emptyRooms = emptyRooms + 1
print "ChanUserCount: " + str(channelUserCount)
print "lenSetUserCount: " + str(len(set(channelUserCount)) == 1
and channelUserCount[0] == True)
and channelUserCount[0] == True)
if len(set(channelUserCount)) == 1 and channelUserCount[0] == True:
pBot.addChannel()
print "emptyRooms: " + str(emptyRooms)
Expand All @@ -35,4 +36,4 @@
if pBot.channellist[i] not in ORIGINALCHANNELS:
pBot.delChannel(pBot.channellist[i])
break
time.sleep(5)
time.sleep(5)

0 comments on commit abc17f5

Please sign in to comment.