GithubHelp home page GithubHelp logo

codebam / cf-workers-telegram-bot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nikhiljohn10/telegram-bot-worker

204.0 1.0 182.0 5.1 MB

Telegram Bot library for CloudFlare Workers

Home Page: https://t.me/TuxRobot

License: Apache License 2.0

TypeScript 92.20% Makefile 2.01% JavaScript 3.86% Shell 1.93%
cloudflare telegram webhook worker ai llama2 llama3 mistral

cf-workers-telegram-bot's Introduction


CF Workers Telegram Bot

GitHub stars GitHub issues GitHub forks npm version

screenshot of cf-workers-telegram-bot

npm i @codebam/cf-workers-telegram-bot

See cwtb-consumer for an example of what a bot might look like. Just import from @codebam/cf-workers-telegram-bot.

See my blog post for a more in-depth guide for how to set up a bot.

  • npm create cloudflare@latest
  • npx wrangler login
  • npx wrangler secret put SECRET_TELEGRAM_API_TOKEN, set it to your telegram bot token that you got from @BotFather
  • npx wrangler deploy
  • Open this url in your browser to set your webhook https://your-worker.username.workers.dev/SECRET_TELEGRAM_API_TOKEN?command=set

To set up GitHub actions to deploy when you push, see https://github.com/cloudflare/wrangler-action


These instructions are for if you want to deploy a copy of the bot along with the library. Such as if you need extra API requests that haven't been implemented yet.

Deploy to Cloudflare Workers

  • Click the deploy button

  • Navigate to your new GitHub repository > Settings > Secrets and add the following secrets:

    - Name: CLOUDFLARE_API_TOKEN  (should be added automatically)
    - Name: CLOUDFLARE_ACCOUNT_ID (should be added automatically)
    
    - Name: SECRET_TELEGRAM_API_TOKEN
    - Value: your-telegram-bot-token
  • Push to master to trigger a deploy

cf-workers-telegram-bot's People

Contributors

cherry avatar chrisspiegl avatar codebam avatar dependabot[bot] avatar github-actions[bot] avatar kevinj045 avatar nikhiljohn10 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

cf-workers-telegram-bot's Issues

wrangler-action is broken

wrangler-action broke. it says it can't connect to the cloudflare api, so maybe github is blocking it now? cloudflare should fix it in v3 so I'll need to bump the version in the action once it's fixed

Inline commands on @TuxRobot are broken

POST https://cf-workers-telegram-bot.codebam.workers.dev/REDACTED - Exception Thrown @ 5/20/2023, 9:55:12 AM                                                                                 
  (log) {                                                                                                                                                                                    
  update: {                                                                                                                                                                                  
    update_id: 429931513,                                                                                                                                                                    
    inline_query: {                                                                                                                                                                          
      id: '296990623136499555',                                                                                                                                                              
      from: [Object],                                                                                                                                                                        
      chat_type: 'supergroup',                                                                                                                                                               
      query: '/epoch',                                                                                                                                                                       
      offset: ''                                                                                                                                                                             
    }                                                                                                                                                                                        
  }                                                                                                                                                                                          
}                                                                                                                                                                                            
  (log) { execute: { text: '/epoch', args: [] } }                                                                                                                                            
  (log) https://api.telegram.org/bot********************************/answerInlineQuery?inline_query_id=********************
%22e68815ac-8726-493*******************                                                                                                                                                         
  (log) { execute: { text: 'inline', args: [ '/epoch' ] } }                                                                                                                                  
  (log) { error: "command 'inline' does not exist" }                                                                                                                                         
โœ˜ [ERROR]   TypeError: Incorrect type for Promise: the Promise did not resolve to 'Response'.

Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import

Hi,

Looks great but having trouble - when trying to test locally using Javascript I see this error:

Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import 'C:\Users\M\Documents\code\project\node_modules\@codebam\cf-workers-telegram-bot\dist\types' is not supported resolving ES modules imported from C:\Users\M\Documents\code\project\node_modules\@codebam\cf-workers-telegram-bot\dist\telegram_bot.js.

importing like so:

import TelegramBot, { TelegramExecutionContext } from '@codebam/cf-workers-telegram-bot';

I'm using "type": "module" in package.json.

Any idea what's going on?

Exactly where are you setting the model to be used?

I know that currently the bot is set to use GPT3. The bot will simply responds and tell you that. However I would like to move the model to use '@cf/mistral/mistral-7b-instruct-v0.1' It shoud be as simple as just swapping out the the model names. However in the code for the worker I cant ind to save my life where GPT3 is actually set. Could you possibly point me in the right direction??

PS.. this is an awesome project. Props my dude

Am I the only one this doesn't work for. It fails when I try to deploy?

When I press the deploy buttton. after i enter my cloudflare id and api it appears as it is going to work but then errors out. and when I try to run with wrangler I also get an error. below are screenshots. Am i retarded or something.. Lol.. Thank you for your help.
Screenshot_20240301_100850
Screenshot_20240301_100548

PS.. each time I ran I removed the create db and worker and went through the build fresh. But i still think it is something db related. Would appreciate if someone could point me in the right direction.

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.