def send_msg(group, peer, message, tgin): if (group is not None): message = peer + ": \n" + spacer + "\n" + message #4100 is the Telegram limit, make sure that we dont over shoot that. #TODO: Split into multiple messages? if len(message) >= 4100: print "Too long! Trimming..." message = message[:4090] + "..." peer = group.rstrip() if (('\n' in message) or ('\r' in message) or ('\r\n' in message)): try: tempfile = 'temp' temp = open(tempfile, 'w') #Handle potential unicode situations temp.write(message) temp.close() if not temp == None: cliInput.write( tgin, 'send_text', ' '.join( [peer.replace(' ', '_'), tempfile.encode('UTF-8')]) + '\n') except Exception as e: print "Error occurred..." print traceback.print_exc() else: if not message == None: cliInput.write( tgin, 'msg', ' '.join([peer.replace(' ', '_'), message]) + '\n') return message
def send_doc(user, doc_dir, tgin): if (user is not None and tgin is not None): cliInput.write(tgin, 'send_document', ' '.join([user.replace(' ', '_'), doc_dir])+'\n')
def send_doc(group, doc_dir, tgin): if (group is not None and tgin is not None): cliInput.write(tgin, 'send_document', ' '.join([group.replace(' ', '_'), doc_dir])+'\n')
def send_image(group, photo_dir, tgin): if (group is not None and tgin is not None): cliInput.write(tgin, 'send_photo', ' '.join([group.replace(' ', '_'), photo_dir])+'\n')
def delete_user(group, user, tgin): if (group is not None and tgin is not None): cliInput.write(tgin, 'chat_del_user', ' '.join([group.replace(' ', '_'), user])+'\n')
def set_pic(group, picDir, tgin): if (group is not None): cliInput.write(tgin, 'chat_set_photo', ' '.join([group.replace(' ', '_'), picDir])+'\n')
def send_text(group, text_dir, tgin): if (group is not None and tgin is not None): cliInput.write(tgin, 'send_text', ' '.join([group.replace(' ', '_'), text_dir]) + '\n')
def send_video(group, video_dir, tgin): if (group is not None and tgin is not None): cliInput.write(tgin, 'send_video', ' '.join([group.replace(' ', '_'), video_dir]) + '\n')
def send_video(user, video_dir, tgin): if (user is not None and tgin is not None): cliInput.write(tgin, 'send_video', ' '.join([user.replace(' ', '_'), video_dir]) + '\n')
def send_doc(user, doc_dir, tgin): if (user is not None and tgin is not None): cliInput.write(tgin, 'send_document', ' '.join([user.replace(' ', '_'), doc_dir]) + '\n')
def send_image(user, photo_dir, tgin): if (user is not None and tgin is not None): cliInput.write(tgin, 'send_photo', ' '.join([user.replace(' ', '_'), photo_dir]) + '\n')
def set_profile_pic(photo_dir, tgin): if (photo_dir is not None and tgin is not None): cliInput.write(tgin, 'set_profile_photo', ' '.join([photo_dir])+'\n')
def send_text(user, text_dir, tgin): if (user is not None and tgin is not None): cliInput.write(tgin, 'send_text', ' '.join([user.replace(' ', '_'), text_dir])+'\n')
def send_video(user, video_dir, tgin): if (user is not None and tgin is not None): cliInput.write(tgin, 'send_video', ' '.join([user.replace(' ', '_'), video_dir])+'\n')
def create_group(group, users, tgin): #Users is an array, must give within square brackets eg. [user1, user2, user3, ..., usern] if (group is not None and tgin is not None): cliInput.write( tgin, 'chat_del_user', ' '.join([group.replace(' ', '_'), " ".join(user)]) + '\n')
def send_image(group, photo_dir, tgin): if (group is not None and tgin is not None): cliInput.write(tgin, 'send_photo', ' '.join([group.replace(' ', '_'), photo_dir]) + '\n')
def send_text(user, text_dir, tgin): if (user is not None and tgin is not None): cliInput.write(tgin, 'send_text', ' '.join([user.replace(' ', '_'), text_dir]) + '\n')
def send_doc(group, doc_dir, tgin): if (group is not None and tgin is not None): cliInput.write(tgin, 'send_document', ' '.join([group.replace(' ', '_'), doc_dir]) + '\n')
def set_profile_pic(photo_dir, tgin): if (photo_dir is not None and tgin is not None): cliInput.write(tgin, 'set_profile_photo', ' '.join([photo_dir]) + '\n')
def rename(group, topic, tgin): if (group is not None): cliInput.write(tgin, 'rename_chat', ' '.join([group.replace(' ', '_'), topic])+'\n')
def rename(group, topic, tgin): if (group is not None): cliInput.write(tgin, 'rename_chat', ' '.join([group.replace(' ', '_'), topic]) + '\n')
def chat_info(group, tgin): cliInput.write(tgin, 'chat_info', ' '.join([group.replace(' ', '_')])+'\n')
def set_pic(group, picDir, tgin): if (group is not None): cliInput.write(tgin, 'chat_set_photo', ' '.join([group.replace(' ', '_'), picDir]) + '\n')
def create_group(group, users, tgin): #Users is an array, must give within square brackets eg. [user1, user2, user3, ..., usern] if (group is not None and tgin is not None): cliInput.write(tgin, 'chat_del_user', ' '.join([group.replace(' ', '_'), " ".join(user)])+'\n')
def chat_info(group, tgin): cliInput.write(tgin, 'chat_info', ' '.join([group.replace(' ', '_')]) + '\n')
def send_video(group, video_dir, tgin): if (group is not None and tgin is not None): cliInput.write(tgin, 'send_video', ' '.join([group.replace(' ', '_'), video_dir])+'\n')
def delete_user(group, user, tgin): if (group is not None and tgin is not None): cliInput.write(tgin, 'chat_del_user', ' '.join([group.replace(' ', '_'), user]) + '\n')
def send_text(group, text_dir, tgin): if (group is not None and tgin is not None): cliInput.write(tgin, 'send_text', ' '.join([group.replace(' ', '_'), text_dir])+'\n')
def send_image(user, photo_dir, tgin): if (user is not None and tgin is not None): cliInput.write(tgin, 'send_photo', ' '.join([user.replace(' ', '_'), photo_dir])+'\n')