room = chatango.chatroom("xxxxx")
room.login("xxxxxx", "xxxxxx")
room.say("Hello, I am an example bot")
running = True
while running:
event = room.get_event()
if event["event"] == "message":
post = event["message"]
message = post.content
poster = post.user
prettyPoster = poster.displayname
room.say(prettyPoster + " just made a post.")
if(message == "Leave"):
room.say("I will leave now.")
running = False
elif event["event"] == "login":
poster = event["user"]
prettyPoster = poster.displayname
room.say(prettyPoster + " just logged onto chat.")
elif event["event"] == "logout":
poster = event["user"]
prettyPoster = poster.displayname
room.say(prettyPoster + " just logged off chat.")
room.disconnec
ok thats pretty much it
here is my error
Traceback (most recent call last):
File "C:\Users\xxxx\Desktop\bot.py", line 1, in <module>
room = chatango.chatroom("bwcg")
NameError: name 'chatango' is not defined
Results 1 to 2 of 2
- 19 Apr. 2011 03:19am #1
i need help with this python code
Last edited by rygaku; 19 Apr. 2011 at 03:38am.
- 19 Apr. 2011 09:12am #2
The indentation is all wrong, but I'm assuming that probably just because you didn't use code tags;
Code:room = chatango.chatroom("xxxxx") room.login("xxxxxx", "xxxxxx") room.say("Hello, I am an example bot") running = True while running: event = room.get_event() if event["event"] == "message": post = event["message"] message = post.content poster = post.user prettyPoster = poster.displayname room.say(prettyPoster + " just made a post.") if(message == "Leave"): room.say("I will leave now.") running = False elif event["event"] == "login": poster = event["user"] prettyPoster = poster.displayname room.say(prettyPoster + " just logged onto chat.") elif event["event"] == "logout": poster = event["user"] prettyPoster = poster.displayname room.say(prettyPoster + " just logged off chat.") room.disconnec
Code:import chatango