Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

telegram-zi

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

telegram-zi

Easy telegram scenes

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Telegram Zi

Easy Telegram scenes based on buttons

Basic Example

require('dotenv').config();
const zi = require('./telegram-zi'); // const zi = require('telegram-zi');

(async() => {
    let bot = new zi.newBot(process.env.TELEGRAM_BOT_TOKEN);

    //Basic Scene config -> 1) scene Name, 2) scene buttons, 3) create Scene
    let exampleSceneName = "example_scene";
    zi.defineButtons(exampleSceneName, [
        ['Enter same scene again', exampleSceneName],
        ['This button does exactly the same', exampleSceneName],
    ])
    zi.newScene({sceneName: exampleSceneName, say:"Welcome @Linkfy's bot! Select an option to start"});

    zi.start(exampleSceneName);

})();

Bot Auth:

    let bot = new zi.newBot(process.env.TELEGRAM_BOT_TOKEN, ids=[5705569, 5705568]); //You can specify the authorized user ids

Advanced Example:



let startProcessScene = 'start_process';
zi.newScene({sceneName: startProcessScene, say: "Executing operation", 
                execute: {foo: buy, args: [{
                        serviceNumber: element.service, 
                        quantity: option, 
                        sceneContainingLink: sendLinkScene
                    }]}
                });

function buy(ctx, info) {
    let {serviceNumber, quantity, sceneContainingLink} = info;
    let link = ctx.session.saved[sceneContainingLink].desiredLink;
    let price = Number(quantity/100)-0.1;
    console.log(`The scene ${sceneContainingLink} has the link ${link}, and wants to use ${quantity} actions with the service number ${serviceNumber}`);
    ctx.reply(`The price for the operation is ${price} coins, [TODO]\n
    Going back to menu`);
    zi.changeScene(ctx, exampleSceneName, delay = 1000);

}

//...

Advanced Example 2:




zi.newScene({sceneName: "buy_scene", nextScene: "default_scene", 
    execute: {foo: myFunction, args: ['😃', '👍']}
});
zi.newScene({sceneName: "my_scene", say:"Send me the link please", nextScene: "BuyLikes", saveReply: "linkToBuy"});


function showMyLink(ctx, param1, param2) {
ctx.reply("It is not yet implemented but this is your reply: " + ctx.session.saved.my_scene.linkToBuy + " \nAnd also this: " + ctx.message.text + " " + param1 + " " + param2 );
//We can also change button names
zi.changeSceneButtonName("another_scene", "Buy this", "Buy again this");
//Or scenes
zi.changeScene(ctx, "welcomeScene", delay = 1000);

//...

FAQs

Package last updated on 01 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc