#NEWLINE# def relay( self , bot , relay_ins ) : #NEWLINE# #INDENT# def channel_for( channel_id ) : #NEWLINE# #INDENT# return bot . slack_client . server . channels . find ( channel_id ) #NEWLINE# #UNINDENT# def name( channel ) : #NEWLINE# #INDENT# if self . name : #NEWLINE# #INDENT# if ( not channel . name . startswith ( self . name ) ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# return channel . name . split ( '-' , 1 ) [ 1 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return channel . name #NEWLINE# #UNINDENT# #UNINDENT# for data in relay_ins : #NEWLINE# #INDENT# if ( 'channel' in data ) : #NEWLINE# #INDENT# channel = channel_for ( data [ 'channel' ] ) #NEWLINE# if ( channel is None ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# #UNINDENT# if ( data [ 'type' ] == 'join' ) : #NEWLINE# #INDENT# line = 'join #{}' . format ( name ( channel ) ) #NEWLINE# self . irc_client . send_line ( line ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( data [ 'type' ] == 'message' ) : #NEWLINE# #INDENT# print ( 'do?' , data ) #NEWLINE# message = data . get ( 'text' , '' ) #NEWLINE# try : #NEWLINE# #INDENT# import html #NEWLINE# message = html . unescape ( message ) #NEWLINE# #UNINDENT# except ImportError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# message = message . replace ( '\r' , ' ' ) . replace ( '\n' , ' ' ) #NEWLINE# user_id = data . get ( 'user' , None ) #NEWLINE# if user_id : #NEWLINE# #INDENT# user = bot . slack_client . server . users . find ( user_id ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# user = None #NEWLINE# #UNINDENT# user #NEWLINE# if message : #NEWLINE# #INDENT# line = 'privmsg #{} :{}' . format ( name ( channel ) , message ) #NEWLINE# self . irc_client . send_line ( line ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# line = 'privmsg #{} :{}' . format ( self . config [ 'irc' ] . get ( 'nick' , 'slairck' ) , unicode ( data ) ) #NEWLINE# self . irc_client . send_line ( line )