@ChanMBot 6.1

In this update we will add /md and /html to inline!

bot.on('inlineQuery', msg => {
  let query = msg.query;
  let answers = bot.answerList(msg.id);

  if (query.startsWith('/html ')) {
    query = query.replace('/html ', '');
    answers.addArticle({
      id: 'html',
      title: 'HTML',
      description: `${query}`,
      message_text: `${query}`,
      parse_mode: 'html',
      disable_web_page_preview: true
    });
  } else if (query.startsWith('/md')) {
    answers.addArticle({
      id: 'markdown',
      title: 'Markdown',
      description: `${query}`,
      message_text: `${query}`,
      parse_mode: 'markdown',
      disable_web_page_preview: true
    });
  }

  return bot.answerQuery(answers);
});

@ChanMbot 6.0.0 – Markdown boostup? BitCoin price!!!

Bitcoin price is falling down and going up again… How to check this price??? If you like JSON you can check it here: https://blockchain.info/ticker . But maybe you don’t like JSON and you are crypto currency channel owner?

IN THIS UPDATE!!!!!!

you can check BTC price using ((btc)) in any message! How to do this? Look:

At top of our code we need to add:

var request = require('request');
var btcpurl = "https://blockchain.info/ticker"

And we need to type:

$ npm install

Then we need to find /md command.

After this:

We need to add let btcPrice;

After this we need to add:

request.get(btcpurl,
function(error, response, body) {
usdPrice = JSON.parse(body).USD[“15m”];

Then we need to replace ((btc)) with usdPrice

:

let message = msg.text.replace(‘((btc))’ usdPrice)
let message1 = message.replace(‘/md ‘, ”);

Ok..

Bug found . (again..)

So:

Move this: request.get(btcpurl,
function(error, response, body) {
usdPrice = JSON.parse(body).USD[“15m”];

At top we need to add:

var usdPrice;

And remove let usdPrice; from /md.

Done! Debug in 6.0.1

@ChanMBot 5.2

Here I am with another update!

In this update we will add a way to get the id of other users

if you check the events section on the telebot github repository you can see forward

so we do it like this:

bot.on(['forward'], (msg) => {
  let id = msg.chat.id;
  let replyToMessage = msg.message_id;
  let parseMode = 'markdown';
  let ff = msg.forward_from;

  return bot.sendMessage(id, `From First Name: \`${ff.first_name}\`
From Last Name: \`${ff.last_name}\`
From Username: \`${ff.username}\`
From ID: \`${ff.id}\``, {parseMode, replyToMessage});
  }
});

and every time you forward a message from any user it will return a message with the first name, last name, username and id!

@ChanMbot 5.1

Im this update:

  • Self-destruct Timer!

Ok ok ok. So how it should work?

User: /md *Test* _message_

Bot: Test message

User: /rm1h

Bot: I’ll remove ⬆️ this ⬆ message // with reply to last bot message

Step 1.

Code:

bot.on([‘/rm1h’], function(msg) {

let id = msg.chat.id
let num1 = msg.message_id
let num2 = msg.chat.id
let sum = num1 – 1

return bot.sendMessage(msg.chat.id, “I’ll delete previous message in 1hour”).then(() => {
setTimeout(() => bot.
deleteMessage(id, sum).catch(console.log), 36000000);
});
});

Then we need to add more timers but it is easy to do we need to replace 36000000 with another numbers 🙂

Gj @BotDev

@ChanMBot 5.0

In this update we will add a /feedback command and a /send to reply.

First we will add /feedback:

bot.on(['/feedback'], (msg) => {
 let id = msg.from.id;
 let replyToMessage = msg.message_id;
 let replyMarkup = 'reply';

return bot.sendMessage(id, `Please send your feedback`, {replyToMessage, ask: 'feedback', replyMarkup});
});

bot.on(['ask.feedback'], (msg) => {
 let id = msg.from.id;
 let replyToMessage = msg.message_id;
 let parseMode = 'markdown';

if (msg.text == '/cancel') {
 return bot.sendMessage(id, "I've canceled that!", {replyToMessage});
 } else {
 return bot.sendMessage(id, `Thanks for the feedback`, {replyToMessage}), bot.sendMessage(YOUR_ID, `[${msg.from.username}](tg://user?id=${id}) (\`${id}\`):\n\n${msg.text}`, {parseMode});
 } 
});

and replace YOUR_ID with your id.

 

Next we will add /send:

let send, send_message;

bot.on(['/send'], (msg) => {
 let id = msg.from.id;
 let replyToMessage = msg.message_id;

if (id === YOUR_ID && msg.text == '/cancel') {
 return bot.sendMessage(id, "I've canceled that");
 } else if (id === YOUR_ID && msg.text != '/cancel') {
 return bot.sendMessage(msg.from.id, `Who would you like to send a message to?`, {replyToMessage, ask: 'send_id'});
 }
});

bot.on(['ask.send_id'], (msg) => {
 let id = msg.from.id;
 let replyToMessage = msg.message_id;

if (id === YOUR_ID && msg.text == '/cancel') {
 return bot.sendMessage(id, "I've canceled that");
 } else if (id === YOUR_ID && msg.text != '/cancel') {
 return bot.sendMessage(id, `What would you like to send?`, {replyToMessage, ask: 'send_msg'}).then(() => send = `${msg.text}`).then(() => console.log(send));
 }
});

bot.on(['ask.send_msg'], (msg) => {
 let id = msg.from.id;
 let replyToMessage = msg.message_id;

if (id === YOUR_ID && msg.text == '/cancel') {
 return bot.sendMessage(id, "I've canceled that");
 } else if (id === YOUR_ID && msg.text != '/cancel') {
 return bot.sendMessage(id, `What would you like to send?`, {replyToMessage}).then(() => send_message = `${msg.text}`).then(() => console.log(send_message)).then(() => bot.sendMessage(send, `Message from the admin:\n\n${send_message}`));
 }
});

and again replace YOUR_ID with your id.

@ChanM 4.3

In part 2 we added /id but we need to fix the problem if the user doesnt have a username.

So we do it like this:

bot.on(['/id'], (msg, self) => {
  let id = msg.chat.id;
  let replyToMessage = msg.message_id;
  let username = msg.chat.username;
  let type = self.type;
  let parseMode = 'markdown';

  if (username != 'undefined') {
    return bot.sendMessage(id, `Chat ID: \`${id}\`
Message ID: \`${replyToMessage}\`
username: @${username}
t.me link: t.me/${username}
telegram link: [${msg.from.first_name}](tg://user?id=${ id })`, {replyToMessage, parseMode});
  } else {
    return bot.sendMessage(id, `Chat ID: \`${ id }\`
Message ID: \`${replyToMessage}\`
telegram link: [${msg.from.first_name}](tg://user?id=${ id })`, {replyToMessage, parseMode});
  }
});

@ChanMbot 4.2

In this update:

Self-destruct timer!!!

First thing to do is: HOW TO DO THIS!!!

Ok. Maybe command /rm1h *message* _text_ *here*

Ok… So code:

bot.on([‘/rm1h’], function(msg) {

let id = msg.chat.id
let num1 = msg.message_id
let num2 = msg.chat.id
let sum = num1 + 2

return bot.sendMessage(msg.chat.id, “I’ll delete this message in 1hour”).then(() => {
setTimeout(() => bot.
deleteMessage(id, sum).catch(console.log), 36000000);
});
});

And /md commands should also answer this command add Just this:

‘/md’,’rm1h’

@ChanMbot 4.0

In this update we will add themes!

And /commands in @BotFather

/start – rly? idk What this command does

/help – let me thing… maybe it shows help?

/markdown – markdown help menu

/htmlhelp – html help menu

/md – /md *Your* _text_ *here*

/html – /html <b>Your text here</b>

So What themes?

Template #1

🌐 *Article name*

[🔰](link://for.image/preview) [email protected] and @AntiMany!_

_Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut a libero pharetra, maximus ex vel, tincidunt sapien. Phasellus ut tempus libero. Proin sapien lectus, lobortis sit amet leo eu, venenatis eleifend leo. Fusce nibh metus, mollis sed posuere dapibus, molestie et libero.…_

[⬆️Read More…⬆️](http://google.com)

Also we need to create /template commands [:(]

bot.on(['/templates'], (msg, self) => {
let id = msg.from.id;
let replyToMessage = msg.message_id;
let type = self.type;
let parseMode = 'markdown';
return bot.sendMessage(
id, `*Templetes*

What kind of templates do you need?
- I need /markdown_templates.
- I need html_templates (soon)`, {replyToMessage, parseMode});
});

Continue reading “@ChanMbot 4.0”