|
Post by Fringe Pioneer on Dec 22, 2010 3:16:30 GMT
This doesn't work anymore. Go here.-Qwerty #Import chatango.py so that you can use some of its classes and methods. import chatango
#Make an instance of the chatroom where the bot will reside. room = chatango.chatroom("danball1")
#Log in with a given username and password. #If the password is wrong or omitted, the bot will log in as an anon. room.login(username, password)
#Post a message 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.disconnect()
|
|
|
Post by Rabidbadger on Dec 22, 2010 12:06:19 GMT
You are a genius, Veers. To think that this is your first Python project is unbelievable. I just hope my first project will go as well... Oh, and thanks for the code. It is pretty interesting stuff... I take it you had to download some chatango modules for Python?
|
|
|
Post by Fringe Pioneer on Dec 22, 2010 12:17:12 GMT
Well, I had to get much help from disabled. I probably would have been too deep in syntax and runtime errors without his help, although I did manage to clearly express what I wanted to happen down in code most of the time.
Also, the above code is erratic. Let me correct the syntax errors...
EDIT: There, the simple code should be fixed.
|
|
|
Post by clockwork on Dec 31, 2010 18:17:54 GMT
You need parenthesis around danball1
|
|
|
Post by Fringe Pioneer on Jan 1, 2011 8:50:26 GMT
You mean the missing quotation marks? I edited the excerpt to include quotation marks to mark "danball1" as a string...
|
|
|
Post by clockwork on Jan 1, 2011 17:23:52 GMT
Oops sorry, but yeah, ""
|
|
|
Post by ~Memzak~ on Jan 5, 2011 21:17:30 GMT
Wow.. a very short code indeed.
A simple startup method and a couple commands. This should give one everything he needs to make a bot.
|
|