Skip to content

Telegram bot for broadcasting video and photos from CCTV cameras

Notifications You must be signed in to change notification settings

1337m3rcy/TelegramBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 

Repository files navigation

TelegramBot

  1. Для установки необходимых зависимостей: Для установки необходимых зависимостей:
   npm i
  1. Скрипт для отправки с почты в телеграмм бота:

    // The token of your Telegram bot
    var TOKEN = "<< Your bot token >>";
    
    
    // Name of the Gmail Label which need to search for
    var LABEL = "<< Your Label >>"
    
    function processEmails() {
      
      // Search unread emails with specified label
      var search = "label:" + LABEL + " is:unread";
      Logger.log('Search: ' + search);
      var threads = GmailApp.search(search, 0, 10);
      
      for (var i = 0; i < threads.length; i++) {
        var messages = threads[i].getMessages();
        Logger.log('Number of emails found: ' + messages.length);
    
        for (var j = 0; j < messages.length; j++) {
          var m = messages[j];
          if (!m.isInTrash() && m.isUnread()) {
            if (m.getAttachments().length > 0) {
              
              // Get the first attachment (image jpeg file)
              // and send to telegram bot
              sendPhoto(m.getAttachments()[0].copyBlob());
            }
            m.markRead();
          }
        }
      }
    }
    
    function sendPhoto(photo) {
        var payload = {
          'chat_id': "<<Your Chat ID>>",
          'photo': photo
        };
        var options = {
          'method': 'post',
          'payload': payload
        };
        UrlFetchApp.fetch("https://api.telegram.org/bot" + TOKEN + "/sendPhoto", options);
      }

About

Telegram bot for broadcasting video and photos from CCTV cameras

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages