SReporter

Builds and tests pub package pub points Latest release Stable Version Stability repo size

A helpful dart package to send reports, crash logs and messages from your app to telegram chat (private, group or channel) using telegram bot. or to discored server to specific channel using server webhook.

Usage

To use this plugin, add SReporter as a dependency in your pubspec.yaml file.

dependencies:
  sreporter: ^1.0.0

Example

Import the library.

import 'package:sreporter/sreporter.dart';

Use it anywhere you want to create a Telegram or Discord reports:

Telegram Report

Preview

tele preview

How to use

Telegram report supports markdown elements within its header ande content. Use:

    TeleCode('// Code...', lang: 'java').toString(); // lang is optional
    TeleUnderline(' text ').toString();
    TeleSpoiler(' text ').toString();
    TeleStrikeThrough(' text ').toString();
    TeleItalics(' text ').toString();
    TeleBold(' text ').toString();

Whole Code:

    SReporter.teleReporter(
      botToken: '195211143...', // get it from @botFather in Telegram
      targetChat: '14888...', // ID or mention username '@smith8h'
      reportHeader: 'Report sent from ${Italic('Demo App')}.',
      reportSubHeader: '${Spoiler(Underline('Flutter-Demo').toString())}', // optional
      reportMessage: '${Code('Custom.message', lang: 'dart')}',
      reportFooter: 'Footer (More Info)...', // optional
      onSuccess: () {
        // on success to send the report
      },
      onFailure: (msg) {
        // on failed to send the report
      },
    ).report();

Discord Report

Preview

disc preview

How to use

Discord report supports markdown elements within its header ande content. Use:

    DiscCode('// Code...', multiline: true).toString(); // multiline is false by default.
    DiscUnderline(' text ').toString();
    DiscSpoiler(' text ').toString();
    DiscStrikeThrough(' text ').toString();
    DiscItalics(' text ').toString();
    DiscBold(' text ').toString();
    DiscHeader(' text ', type: 1).toString(); // type represents header degree h1, h2, h3...
    DiscLink('text', 'url').toString();
    DiscListItem('text', indent: true).toString(); // indent to make the list item belongs to secondary list.
    DiscBlockQuote('text', wholeMsg: true).toString(); // wholeMsg to set the block qoute to single line or whole message.

Whole Code:

    SReporter.discReporter(
      webhook: 'https://discord.com/api/webhooks/11...',
      contentMessage: 'Content Message with ${DiscBold('spoiler text')}...',
      onSucess: () {
        // on success to send the report
      },
      onFailure: (failMsg) {
        // on failed to send the report
        // use fail message.
      },
    ).report();