• Stars
    star
    507
  • Rank 86,452 (Top 2 %)
  • Language
    Python
  • License
    GNU General Publi...
  • Created almost 2 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🤖️ an AI chat Telegram bot can Web Search Powered by GPT-3.5/4/4 Turbo/4o, DALL·E 3, Groq, Gemini 1.5 Pro/Flash and the official Claude2.1/3/3.5 API using Python on Zeabur, fly.io and Replit.

ChatGPT & New Bing Telegram Bot

Features

同时集成 ChatGPT 和 New Bing

异步处理消息,多线程回答问题

支持消息 Markdown 渲染

同时支持 ChatGPT 和 New Bing 流式输出,实现打字机效果

同时对比 ChatGPT 和 New Bing 的消息

增加一键 Replit 部署,真正的零成本,傻瓜式部署,支持 kuma 防睡眠

全平台,随时随地,只要有 telegram 就可以打破知识壁垒

支持 docker,fly.io 部署

Replit 远程部署

Run on Repl.it

导入 Github 仓库后,设置运行命令

pip install -r requirements.txt --index-url https://pypi.python.org/simple/ > /dev/null && python3 webhook.py

在左边栏 Tools 里面选择 Secrets,添加机器人需要的环境变量,一共四个:

  • BOT_TOKEN: 你需要在 BotFather 创建一个 bot 以获取 BOT_TOKEN
  • WEB_HOOK: 在 Replit 会自动分配一个域名给你,填入 https://appname.username.repl.co
  • API: openai 的 api key.
  • API_URL: 调用 api 的地址,默认是:https://api.openai.com/v1/chat/completions
  • GPT_ENGINE:模型名字,默认是 gpt-3.5-turbo
  • COOKIES: bing.com 的 cookies。可以用 Cookie-Editor 点击链接安装插件,点导出会自动复制到剪贴板。有效期两周,一个对话有 20 次提问,过期后每个对话提问次数限制在 5 次。
  • NICK: 可选,默认为空,NICK 是机器人的名字。当用户输入消息以 NICK 开头,机器人才会回答,否则机器人会回答任何消息。尤其在群聊里,没有 NICK,机器人会对所有消息进行回复。

点击屏幕上方的 run,即可运行机器人。记得打开 Always On。

fly.io 远程部署

官方文档:https://fly.io/docs/

使用 Docker 镜像部署 fly.io 应用

flyctl launch --image yym68686/chatgpt:1.0

输入应用的名字,若提示初始化 Postgresql 或 Redis,一律选择否。

按照提示部署。在官网控制面板会提供一个二级域名,可以使用这个二级域名访问到服务。

设置环境变量

flyctl secrets set WEB_HOOK=https://flyio-app-name.fly.dev/
flyctl secrets set BOT_TOKEN=bottoken
flyctl secrets set API=
flyctl secrets set COOKIES=
# 可选
flyctl secrets set NICK=javis

查看所有环境变量

flyctl secrets list

移除环境变量

flyctl secrets unset MY_SECRET DATABASE_URL

ssh 连接 fly.io 容器

# 生成密钥
flyctl ssh issue --agent
# ssh 连接
flyctl ssh establish

查看 webhook url 是否正确

https://api.telegram.org/bot<token>/getWebhookInfo

Docker 本地部署

下载镜像

docker pull yym68686/chatgpt:1.0

启动容器

docker run -p 80:8080 -dit \
    -e BOT_TOKEN="telegram bot token" \
    -e WEB_HOOK="https://your_host.com/" \
    -e API="" \
    -e COOKIES= \
    chatgpt:1.0

或者你想使用 Docker Compose,下面是 docker-compose.yml 示例:

version: "3.5"
services:
  chatgptbot:
    container_name: chatgptbot
    image: yym68686/chatgpt:1.0
    environment:
      - NICK=
      - BOT_TOKEN=
      - WEB_HOOK=
      - API=
      - COOKIES=
    ports:
      - 80:8080

Reference

参考项目:

https://core.telegram.org/bots/api

https://github.com/acheong08/ChatGPT

acheong08/EdgeGPT: Reverse engineered API of Microsoft's Bing Chat AI (github.com)

https://github.com/franalgaba/chatgpt-telegram-bot-serverless

https://github.com/gpchelkin/scdlbot/blob/d64d14f6c6d357ba818e80b8a0a9291c2146d6fe/scdlbot/__main__.py#L8

消息的 markdown 渲染用的是我的另一个项目:https://github.com/yym68686/md2tgmd

More Repositories

1

md2tgmd

md2tgmd is a Markdown to Telegram-specific-markdown(MarkdownV2) converter
Python
54
star
2

uniRank

世界主流机构大学排名爬虫:qs,usnews,软科,武书连
Python
9
star
3

Markdown-i18n

Add i18n support to any markdown document, support translation from any language to any language.
Python
9
star
4

uni-api

这是一个统一管理大模型API的项目,可以通过一个统一的API接口调用多个后端服务,统一转换为 OpenAI 格式,支持负载均衡。目前支持的后端服务有:OpenAI、Anthropic、DeepBricks、OpenRouter、Gemini等。
Python
9
star
5

OS_practice

NUAA 2022 操作系统实践作业
C
7
star
6

APT-Malware-Classification

自动判定恶意样本所属 APT 组织
Python
5
star
7

ics2022

NUAA PA ics2022 x86 所有实验报告在分支pa3里
C
5
star
8

VirusTotalSpider

基于sha256使用selenium爬取Virustotal获得文件类型与行为特征文件
Python
4
star
9

DeepLX

Integrate and utilize multiple DeepLX translation APIs, enjoying the efficiency and stability provided by load balancing.
Python
4
star
10

ModelMerge

modelmerge is a powerful library designed to simplify and unify the use of various large language models, including GPT-4, GPT-3.5, Claude3, Claude2, Gemini1.5 Pro, DALL-E 3, and Groq.
Python
3
star
11

Logical-Simplification

基于QT的计算机辅助逻辑化简
C++
1
star
12

ROS-Lab

ROS 机器人系统学习实践
Makefile
1
star
13

nuaa-course

NUAA评课系统
JavaScript
1
star
14

chatgpt2api

Reverse engineered ChatGPT API follow acheong08
Python
1
star
15

Arduino-uno-NFC

使用Arduino uno开发板实现识别NFC并驱动MG90S舵机
C++
1
star