#NEWLINE# def direct_msg( self , user , msg ) : #NEWLINE# #INDENT# 'Send direct message to specified Twitter user.\n\n        Args:\n            user: User to send DM to.\n            msg: Message to send. Long messages will automatically be truncated.\n        ' #NEWLINE# self . connect ( ) #NEWLINE# if ( self . twitter_api != None ) : #NEWLINE# #INDENT# msg = ( strftime ( '%Y-%m-%d %H:%M:%S: ' ) + msg ) #NEWLINE# self . logger . info ( 'Sending twitter DM to %s: %s' , user , msg ) #NEWLINE# try : #NEWLINE# #INDENT# self . twitter_api . send_direct_message ( user = user , text = truncate ( msg , 140 ) ) #NEWLINE# #UNINDENT# except tweepy . error . TweepError as ex : #NEWLINE# #INDENT# self . logger . error ( 'Unable to send Tweet: %s' , ex )