• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

Telegram Bot

Scheduled Pinned Locked Moved Requests
5 Posts 5 Posters 3.9k Views 4 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    clubbi
    last edited by Jul 28, 2017, 3:04 PM

    Hey.

    After I experimented with the Google Hangoutsbot for a while, I am now at the Telegrambot. Currently my telegrambot sends me a simple message if the CPU temperature is too high. For this I ‘quickndirty’ inserted a few lines of code into the forked MMM-SystemStats module:

    	var url="https://api.telegram.org/bot[BOT-TOKEN]/sendMessage?chat_id=[CHAT-ID]&text=CPU%20zu%20warm%20";
    	var method = "POST";
    	var postData = "Some data";
    	var async = true;
    	var request = new XMLHttpRequest();
    	request.onload = function () {
    	var status = request.status; // HTTP response status, e.g., 200 for "200 OK"
    	var data = request.responseText; // Returned data, e.g., an HTML document.
    	}
    	request.open(method, url, async);
    	request.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
    	request.send(postData);
    

    It would be great if, for example, also MMM-Syslog, MMM-PIR or MMM-NetworkScanner sends messages, as good as centrally via a Telegram module.

    For example https://github.com/enricostara/telegram.link or https://github.com/yagop/node-telegram-bot-api.

    Thank you.

    R C 2 Replies Last reply Jul 30, 2017, 5:14 PM Reply Quote 0
    • C Offline
      clubbi
      last edited by Jul 30, 2017, 3:27 PM

      I’ve updated the MMM-SystemStats module on github.
      Now the request is sent by nodehelper.js.

      request({ url:  'https://api.telegram.org/bot' + this.config.botToken + '/sendMessage?chat_id=' + this.config.chatID + '&text=' + encodeURI(payload.message), method: 'POST' }, function(error, response, body) {
      console.log("TG with response " + response.statusCode);
      

      It is not a separate module, but it works.

      1 Reply Last reply Reply Quote 0
      • R Offline
        ryck Module Developer @clubbi
        last edited by Jul 30, 2017, 5:14 PM

        @clubbi maybe you could implement this in a separate module, implementing sendNotification / notificationReceived ?

        C 1 Reply Last reply Aug 3, 2017, 3:54 PM Reply Quote 0
        • C Offline
          cowboysdude Module Developer @clubbi
          last edited by Jul 30, 2017, 6:23 PM

          @clubbi said in Telegram Bot:

          Telegrambot.

          Why don’t you just use something like this

          https://www.npmjs.com/package/telegram-bot-api

          1 Reply Last reply Reply Quote 1
          • C Offline
            clubbi @ryck
            last edited by Aug 3, 2017, 3:54 PM

            @ryck
            Currently, I do not have much time, but I’ll keep it in mind.

            @cowboysdude
            ah, ok. thanks.

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            1 / 1
            • First post
              1/5
              Last post
            Enjoying MagicMirror? Please consider a donation!
            MagicMirror created by Michael Teeuw.
            Forum managed by Sam, technical setup by Karsten.
            This forum is using NodeBB as its core | Contributors
            Contact | Privacy Policy