<s> import os <EOL> from slackbot . bot import respond_to <EOL> from slackbot . utils import download_file , create_tmp_file <EOL> @ respond_to ( r'<STR_LIT>' ) <EOL> def upload ( message , url ) : <EOL> url = url . lstrip ( '<STR_LIT:<>' ) . rstrip ( '<STR_LIT:>>' ) <EOL> fname = os . path . basename ( url ) <EOL> message . reply ( '<STR_LIT>' . format ( fname ) ) <EOL> if url . startswith ( '<STR_LIT:http>' ) : <EOL> with create_tmp_file ( ) as tmpf : <EOL> download_file ( url , tmpf ) <EOL> message . channel . upload_file ( fname , tmpf , '<STR_LIT>' . format ( url ) ) <EOL> elif url . startswith ( '<STR_LIT:/>' ) : <EOL> message . channel . upload_file ( fname , url ) </s>
