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 4.5k 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

      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 cowboysdudeC 2 Replies Last reply Reply Quote 0
      • C Offline
        clubbi
        last edited by

        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

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

          C 1 Reply Last reply Reply Quote 0
          • cowboysdudeC Offline
            cowboysdude Module Developer @clubbi
            last edited by

            @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

              @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

              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

              With your input, this post could be even better 💗

              Register Login
              • 1 / 1
              • First post
                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