Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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')
Ejemplo n.º 3
0
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')
Ejemplo n.º 4
0
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')
Ejemplo n.º 5
0
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')
Ejemplo n.º 6
0
def set_pic(group, picDir, tgin):
        if (group is not None):
                cliInput.write(tgin, 'chat_set_photo', ' '.join([group.replace(' ', '_'), picDir])+'\n')
Ejemplo n.º 7
0
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')
Ejemplo n.º 8
0
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')
Ejemplo n.º 9
0
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')
Ejemplo n.º 10
0
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')
Ejemplo n.º 11
0
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')
Ejemplo n.º 12
0
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')
Ejemplo n.º 13
0
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')
Ejemplo n.º 14
0
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')
Ejemplo n.º 15
0
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')
Ejemplo n.º 16
0
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')
Ejemplo n.º 17
0
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')
Ejemplo n.º 18
0
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')
Ejemplo n.º 19
0
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')
Ejemplo n.º 20
0
def rename(group, topic, tgin):
        if (group is not None):
                cliInput.write(tgin, 'rename_chat', ' '.join([group.replace(' ', '_'), topic])+'\n')
Ejemplo n.º 21
0
def rename(group, topic, tgin):
    if (group is not None):
        cliInput.write(tgin, 'rename_chat',
                       ' '.join([group.replace(' ', '_'), topic]) + '\n')
Ejemplo n.º 22
0
def chat_info(group, tgin):
	cliInput.write(tgin, 'chat_info', ' '.join([group.replace(' ', '_')])+'\n')
Ejemplo n.º 23
0
def set_pic(group, picDir, tgin):
    if (group is not None):
        cliInput.write(tgin, 'chat_set_photo',
                       ' '.join([group.replace(' ', '_'), picDir]) + '\n')
Ejemplo n.º 24
0
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')
Ejemplo n.º 25
0
def chat_info(group, tgin):
    cliInput.write(tgin, 'chat_info',
                   ' '.join([group.replace(' ', '_')]) + '\n')
Ejemplo n.º 26
0
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')
Ejemplo n.º 27
0
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')
Ejemplo n.º 28
0
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')
Ejemplo n.º 29
0
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')