Post by Draxorion on Apr 2, 2012 4:36:53 GMT
You see, this Bot was made for logging the discussions on Chatango, onto a text file. Later reviews, references, etc. would need this very much, as the Chatango history is not very reliable. However, the problem is, I can not get it to write to my file. No errors appear, and no clues give any information as to why it can't. The text file is simply empty. I once came upon the file and saw that it was filled with a single instance of a previous discussion. It doesn't give an indication that this is possible any longer.
Please help.
import time
import chatango
import urllib.parse
import string
import urllib.request
t = time.time()
delay=time.time
pages={}
logging = True
logfile = open("chatlog.txt", "w")
logfile.write(str(id))
defaultaddress = input('RECON : ')
username = "StalkingBot"
password = ""
room = chatango.chatroom(defaultaddress)
room.login(username, password)
username=None;password=None
def findUsernames(array):
usernames = []
if len(array) == 3:
usernames.append(array[2])
else:
for username in array[2:]:
usernames.append(noPunctuation(username))
return usernames
def findChusers(array):
chusers = []
for displayName in array:
chuser = room.find_user(lambda x: x.displayname == noPunctuation(displayName))
if chuser:
chusers.append(chuser[0])
return chusers
print('\nElapsed Startup Time: '+str((time.time())-t)+'\n')
t=time.time()
while True:
if time.time()-t > 1800:
t=time.time()
room.silent(False)
event = room.get_event()
if event["event"] == "message":
post = event["message"]
message = post.content
poster = post.user
prettyPoster = poster.displayname
postername = prettyPoster.lower()
print(' ')
print('-')
print(prettyPoster+': '+message)
print('-')
print(' ')
if (logging == True):
logfile.write(prettyPoster+': '+message+'\n')
room.disconnect()
Please help.