Skip to content

Latest commit

 

History

History
70 lines (53 loc) · 1.52 KB

README.md

File metadata and controls

70 lines (53 loc) · 1.52 KB

Bing Chat

WARN Due to the use of robot check in bingChat, the api is temporarily unuseful.

Requirements

Export Bingchat Cookie

  • Install Cookie-Editor in your browser.
  • Export bing.com cookies with json

Warn

This project currently support parallel sessions (multi sessions) and context

Please make sure that websocket be closed at the end of conversation

Use

go get github.com/NoahAmethyst/bingchat-api

Example

You can see example codes in chat_test.go which include conversation with context and multi conversations

Test

import (
"fmt"
bingchat_api "github.com/NoahAmethyst/bingchat-api"
"os"
"strings"
"testing"
"time"
)

func Test_Conversation(t *testing.T) {
    chat, err := bingchat_api.NewBingChat(os.Getenv("COOKIE"), bingchat_api.ConversationBalanceStyle, 2*time.Minute)
    if err != nil {
        panic(err)
    }

    defer func() {
        chat.Close()
        t.Logf("%+v", chat.CheckAlive())
    }()
	
    message, err := chat.SendMessage("how is the weather today in Seattle")
    if err != nil {
        panic(err)
    }
	
    var respBuilder strings.Builder
    for {
        msg, ok := <-message.Notify
        if !ok {
            fmt.Println()
            break
        }
        respBuilder.WriteString(msg)
    }

    t.Logf("%s", respBuilder.String())

}