📈Example CHAT V2

example code of chat v1, Version 2.1.0

from PyCAI2 import PyAsyncCAI2

owner_id = '54dbda---------'
char = "piwvxvcMQFwb----------"
room_id = "TiqLm-------------"
voice_target = "E:\\FOLDER\\FOLDER\\FOLDER\\FOLDER\\FOLDER"

clinet = PyAsyncCAI2(owner_id)

async def main():
    message = input("You: ")
     
    # TRANSLATE 
    #TRANSLATE FROM INDONESIA TO ENG
    await clinet.chat2.transl(text=message,target='en',source='id') 

    # GET HISTORIES
    await clinet.chat2.get_histories(char=char)
    
    # GET HISTORY
    await clinet.chat2.get_history(char=char)

    # GET AVATAR
    await clinet.chat2.get_avatar(char=char)

    # CREATE IMAGE
    async with clinet.connect(owner_id) as chat2:
        # RETUR MESSAGE + IMAGE LINK 
        await chat2.create_img(char=char,text=message,
                               author_name='FALCO',
                               Return_all=True)
        # RETURN IMAGE LINK
        await chat2.create_img(char=char,text=message,
                               author_name='FALCO',
                               Return_img=True)
        
    # SEND MESSAGE
    async with clinet.connect(owner_id) as chat2:
        # RETURN W NAME {(CHAR NAME) + MESSAGE}
        await chat2.send_message(char=char,
                                 text=message,
                                 author_name="FALCO",
                                 Return_name=True)
        
        # RETURN WITHOUT NAME (MESSAGE)
        await chat2.send_message(char=char,
                                 text=message,
                                 author_name="FALCO",
                                 Return_name=False)
    
    # NEW CHAT
    async with clinet.connect(owner_id) as chat2:
        # RETURN WITH GREETING
        await chat2.new_chat(char=char,with_greeting=True)

        # RETURN WITHOUT GREETING 
        await chat2.new_chat(char=char,with_greeting=False)

    # DELATE MESSAGE 
    async with clinet.connect(owner_id) as chat2:
        # GET TURN ID FROM HISTORY FUNCTION!
        await chat2.delete_message(char=char, turn_ids=trun_id)

Last updated