How to use the puregram.Telegram function in puregram

To help you get started, we’ve selected a few puregram examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nitreojs / puregram / docs / examples / scene-bot.js View on Github external
// code by Negezor (https://github.com/negezor)

let { Telegram } = require('puregram');

let { SessionManager } = require('@puregram/session');
let { SceneManager, StepScene } = require('@puregram/scenes');

let telegram = new Telegram({
	token: process.env.TOKEN,
});

let sessionManager = new SessionManager();
let sceneManager = new SceneManager();

sceneManager.addScene(
  new StepScene('signup', [
    (context) => {
      if (context.scene.step.firstTime || !context.text) {
        return context.send('What\'s your name?');
      }

      context.scene.state.firstName = context.text;

      return context.scene.step.next();
github nitreojs / puregram / docs / examples / markdown.js View on Github external
let { oneLine } = require('common-tags');
let { Telegram, HTML, Markdown } = require('puregram');

let telegram = new Telegram({
  token: process.env.TOKEN,
});

telegram.updates.hear(/^markdown$/i, (context) => {
  return context.send(
    oneLine`
      Some ${Markdown.bold('epic')} ${Markdown.italic('markdown')}
      ${Markdown.code('right')} ${Markdown.url('there', 'example.com')}!
    `,
    {
      /**
       * There are 3 ways to pass Markdown or HTML as a parameter.
       * 
       * First is to pass class into parse_mode.
       */
      parse_mode: Markdown,
github nitreojs / puregram / docs / examples / keyboards.js View on Github external
let {
  Telegram,
  Keyboard,
  KeyboardBuilder,
  InlineKeyboard,
  InlineKeyboardBuilder,
} = require('puregram');

let telegram = new Telegram({
  token: process.env.TOKEN,
});

telegram.updates.setHearFallbackHandler(
  context => context.send(
    'Enter either /keyboard, /keyboardbuilder, /inline or /inlinebuilder.',
  ),
);

telegram.updates.hear('/keyboard', (context) => {
  return context.send('There\'s your keyboard!', {
    reply_markup: Keyboard.keyboard([
      [
        Keyboard.textButton('Button'),
      ],
github nitreojs / puregram / docs / examples / hello-world.js View on Github external
let { Telegram } = require('puregram');

let telegram = new Telegram({
  token: process.env.TOKEN,
});

telegram.updates.hear(
  /^hello/i,
  context => context.send('World!'),
);

telegram.updates.startPolling();