Advertisement
Guest User

Untitled

a guest
Sep 29th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.45 KB | None | 0 0
  1. import chatango
  2. #Went over the following already...
  3. address = input('CHTRM: ')
  4. username = input('USER:')
  5. password = input('PASS:')
  6. room = chatango.chatroom(address)
  7. #Just do this. It's cleaner.
  8. chatango.debug(False)
  9. #duh.
  10. room.login(username, password)
  11.  
  12. #FUNSTUF! Main command loop:
  13. while True:
  14.     event = room.get_event() #get an event
  15.     if event["event"] == "message": #Determine that it's a message
  16.         post = event["message"] #get the whole message, put it into something more readable
  17.         message = post.content #take the text out
  18.         poster = post.user      #take the poster
  19.         prettyPoster = poster.displayname #get the proper capitalization of it
  20.         messageArray=message.split(' ') #split up the message
  21.         print(prettyPoster+': '+message) #post it in the script's window, cuz u can.
  22.         if messageArray[0].lower()=='!say': #Determine the message starts with a command, eg: "!say"
  23.             room.say(' '.join(messageArray[0])) #post the following text to chat
  24.             continue
  25.     elif event["event"] == "login": #I don't feel like getting into this. figgur it out ursalf.
  26.         poster = event["user"]
  27.         prettyPoster = poster.displayname
  28.         print(prettyPoster + " just logged onto chat.")
  29.         continue
  30.     elif event["event"] == "logout":
  31.         poster = event["user"]
  32.         prettyPoster = poster.displayname
  33.         print(prettyPoster + " just logged off chat.")
  34. room.disconnect()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement