Skip to content

Commit

Permalink
api work
Browse files Browse the repository at this point in the history
  • Loading branch information
lndlrd committed Jul 6, 2012
1 parent f801d1c commit 10e4cce
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
12 changes: 9 additions & 3 deletions chatcleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@

chats = skype.Chats
for chat in chats:
chat.Unbookmark()
chat.Disband()
try:
chat.Unbookmark()
except Exception, e:
pass
try:
chat.Disband()
except Exception, e:
pass
chat.Leave()

api.ResetCache()
api.ResetCache()
14 changes: 6 additions & 8 deletions skypebot.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@ def __init__( self ):
super( BotThread, self ).__init__()

def message_all( self, message ):
lines = message.split("\n")
# send message to all connected chats
for chat_name in self.chat_handlers:
chat_handler = self.chat_handlers[ chat_name ]
try:
chat_handler.chat.SendMessage( message )
for line in lines:
chat_handler.chat.SendMessage( message )
except Exception, e:
logging.info( e )

Expand Down Expand Up @@ -217,21 +219,17 @@ def run( self ):
if ENABLE_API:
api_message = self.api_server.pop_message()
if api_message is not None:
print api_message
print api_message.payload
message_out = None
try:
message_out = api_message.payload["message"]
logging.info( message_out )
self.message_all( message_out )
except Exception, e:
logging.info( e )
if message_out is not None:
self.message_all( message_out )

time.sleep(1)
except Exception, e:
logging.info( e )
print e

if ENABLE_TWITTER:
self.twitter_connector.stop()
if ENABLE_API:
self.api_server.stop()

0 comments on commit 10e4cce

Please sign in to comment.