Skip to content

`televerse_shelf` extends the functionality of the Televerse framework, enabling you to integrate the power of Shelf into your Telegram bots. ๐Ÿค–

License

Notifications You must be signed in to change notification settings

xooniverse/televerse_shelf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

televerse_shelf

Pub Version GitHub Dart


๐Ÿš€ Combine Televerse with Shelf for Custom Webhook Servers

televerse_shelf extends the functionality of the Televerse framework, enabling you to integrate the power of Shelf into your Telegram bots. While Televerse natively supports webhooks, it implicitly handles server creation, limiting user control over routes and server customization. With televerse_shelf, you can build fully customizable web servers using Shelf while managing your bot's webhook on a dedicated route.

This package is perfect for developers who want to combine the simplicity of Televerse with the flexibility of Shelf to handle other web server tasks alongside Telegram bot updates.


โœจ Key Features

  • Customizable Webhook Routes
    Define a specific route for handling Telegram updates via webhooks, without interfering with other routes.

  • Full Shelf Integration
    Seamlessly use Shelf's powerful routing and middleware alongside Televerse.

  • Dedicated TeleverseShelfWebhook
    A custom adapter for Televerse, enabling webhook updates via Shelf.

  • Multi-route Support
    Dedicate a single port for your bot webhook and additional routes, like APIs or health checks, all under one server.


๐Ÿ›  Installation

Add televerse_shelf to your pubspec.yaml:

dependencies:
  televerse_shelf: <latest>

Then import the package in your Dart code:

import 'package:televerse_shelf/televerse_shelf.dart';

๐Ÿ’ป Getting Started

Here's a basic example to get you started with televerse_shelf:

import 'dart:io';
import 'package:shelf/shelf.dart';
import 'package:shelf/shelf_io.dart';
import 'package:shelf_router/shelf_router.dart';
import 'package:televerse/televerse.dart';
import 'package:televerse_shelf/televerse_shelf.dart';

void main() async {
  final token = Platform.environment['BOT_TOKEN']!;
  final fetcher = TeleverseShelfWebhook();
  final bot = Bot(token, fetcher: fetcher);

  bot.command('start', (ctx) async {
    await ctx.reply('Hello, world!');
  });

  final router = Router();

  // Set up your webhook route
  router.post('/webhook', fetcher.createHandler());

  // Define other custom routes
  router.get('/api', (req) => Response.ok('Hello from API!'));
  router.get('/health', (req) => Response.ok('{"status":"OK"}'));

  final pipeline = Pipeline().addMiddleware(logRequests()).addHandler(router.call);

  final server = await serve(pipeline, 'localhost', 8080);

  await bot.start();
  print('Server running on port ${server.port}');
}

๐Ÿค” Whatโ€™s Happening Here?

  • TeleverseShelfWebhook: Manages webhook updates and integrates with Shelf.
  • Custom Routes: Use Shelf's Router to define /api and /health alongside the bot's /webhook.
  • Pipeline & Middleware: Add logging, authentication, or other middleware to your server.

๐Ÿ“š Documentation

To use televerse_shelf effectively:

  1. Set Up Webhooks: Use TeleverseShelfWebhook and fetcher.createHandler() for handling webhook routes.
  2. Customize Your Server: Combine Televerse with Shelfโ€™s routing and middleware to create versatile applications.
  3. Run Your Bot: Call bot.start() to initiate the bot alongside your server.

For detailed examples and advanced usage, check out the Televerse documentation.


๐Ÿ’ก Use Cases

  • Deploy bots on a single port with APIs or health checks.
  • Build server applications that combine bot updates with REST APIs.
  • Add middleware for logging, rate-limiting, or security to your bot server.

๐Ÿค Contributing

Weโ€™d love to see contributions from the community! Feel free to fork the repository, open issues, or submit pull requests.


๐ŸŒŸ Shoot a Star

If you find televerse_shelf helpful, consider giving us a star on our GitHub repository. It motivates us to keep building cool tools!


๐Ÿค Join the Community

Need help? Have ideas? Join the discussion with other developers:


Thank you for using televerse_shelf! ๐Ÿš€

About

`televerse_shelf` extends the functionality of the Televerse framework, enabling you to integrate the power of Shelf into your Telegram bots. ๐Ÿค–

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages