Giter VIP home page Giter VIP logo

hebijush / ab Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jarylc/cf-workers-bingai-sydney-telegram-bot

0.0 0.0 0.0 1.33 MB

Synced from GitLab - Deploy your own Serverless Telegram bot integration to quickly interface with Bing's AI (a.k.a Sydney) using their reverse engineered API

Home Page: https://gitlab.com/jarylc/cf-workers-bingai-sydney-telegram-bot

License: MIT License

TypeScript 100.00%

ab's Introduction

cf-workers-bingai-sydney-telegram-bot

Logo

Description

Example Example (Inline)

Serverless Telegram bot in webhook mode to quickly interface with BingAI a.k.a Sydney's using a reversed engineered API.

This is much slower than ChatGPT variants as there is no way to disable streaming mode (words generate one at a time) and I have to capture when the stream ends.

This bot supports private chats, group chats and inline mode (tagging the bot in any chat with a query) with a confirmation button to make it smoother to use.

Notes:

  • To clear Inline Mode context, tag the bot in chat without a query and tap on Clear context and start a new conversation
  • Inline Mode is capped at a 64-character limit because of callback_data limits, but it can be solved by saving the query in KV if required
  • This is mainly for personal use, if you would like to add features, do fork the repository. Do perform PRs back if you would be so kind!

Prerequisites

Getting Started

Wrangler

  1. Sign in to https://www.bing.com/ on the browser
  2. Clone this repository
  3. Run npm ci or yarn install
  4. Run npx wrangler secret put TELEGRAM_BOT_TOKEN and set the Telegram bot token
  5. Run npx wrangler secret put BING_COOKIE and set your latest Bing cookie request header on https://edgeservices.bing.com/edgesvc/turing/conversation/create
  6. Add space-delimited case-sensitive usernames to whitelist in TELEGRAM_USERNAME_WHITELIST in wrangler.toml
  7. (Optional) Choose your BING_CONVERSATION_STYLE by commenting and uncommenting accordingly in wrangler.toml
  8. (Optional) Update BING_BEHAVIOR in wrangler.toml with your desired behavior / system message
  9. (Optional) To enable context, run npx wrangler kv:namespace create session and replace the ID of BINGAI_SYDNEY_TELEGRAM_BOT_KV wrangler.toml, else remove kv_namespaces block entirely from wrangler.toml
  10. Run npx wrangler publish to deploy to Cloudflare Workers
  11. (Optional) Enable Inline Mode for the bot on BotFather to allow inline query flow
  12. Replace {TELEGRAM_BOT_TOKEN} and {WORKERS_NAMESPACE} on the following https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/setWebhook?allowed_updates=%5B%22message%22%2C%22inline_query%22%2C%22callback_query%22%5D&url=https%3A%2F%2Fcf-workers-bingai-sydney-telegram-bot.{WORKERS_NAMESPACE}.workers.dev%2F{TELEGRAM_BOT_TOKEN} and access it on your browser

(On cookie expiry, roughly 2 weeks) Renewing BING_COOKIE

  1. Sign in to https://www.bing.com/ on the browser
  2. Run npx wrangler secret put BING_COOKIE and set your latest Bing cookie request header on https://edgeservices.bing.com/edgesvc/turing/conversation/create

Other Optional Steps

Bot Commands list

bingai - Triggers use of the bot in group chats without toggling Private Mode
sydney - Triggers use of the bot in group chats without toggling Private Mode
clear - Clear context for the current chat and start a new conversation

Bot Inline Query Placeholder

Type your query and tap on Query BingAI above to submit

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.