GithubHelp home page GithubHelp logo

flexberry / imapbot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from angelos-se/imapbot

0.0 1.0 0.0 25 KB

Telegram bot for watching an IMAP account and sending a message when you receive a new message. (WIP)

License: MIT License

Python 100.00%

imapbot's Introduction

IMAPBot

Telegram bot for watching an IMAP account and sending a message when you receive a new email.

The bot only sends messages, it does not respond or listen.

Configuration

There is only one configuration file. Copy config.TEMPLATE.py to config.py and fill in the details. Note that you have to create an individual bot, the details of the process can be found at https://core.telegram.org/bots .

  • bot_token: When the bot is regsitered via @botfather it will get a unique and long token. This is that token.
  • chat_ids: This bot posts messages only to predefined chats, which can be a groupchat or individual. The easiest way to get the id of the chat is to add the bot to the chat and then check https://api.telegram.org/<bot_token>/getUpdates on your browser. Bot should be added to the chat to be able to post.
  • email.{host,port}: Settings of the IMAP server.
  • email.{email,password}: Username and password for the account. On many servers email/username should be in format [email protected]. If you enable 2-factor authentication for GMail, you have to create and application password for the bot, it does not support 2-factor authentication.
  • email.search: This is an IMAP command. (UNSEEN) gets only the unread messages and mark them as read. You can put a search criterion here.
  • email.maxLen: Email will be trimmed if it is longer than this value.

Usage

After creating config.py and putting in the correct values, the bot can be run with the command ./imapbot.py. It will get the new messages, or the ones that satisfy the search criterion, and post them to the specified chats.

Additionally, the version in this fork supports passing config.py as a command line argument eg: ./imapbot.py config_account1.py, should things fail it falls back to config.py; when using this feature, please note:

  1. Since the file is imported as module, please make sure the file name complies with Python module name requirements;
  2. If you don't name your file config_<account name>.py, you should look into adjusting your .gitignore as well.

Currently the bot is not memory resilient, i.e., it finishes its job and exits. Therefore, a cron job should be created to regularly check the emails. If you clone this repo into /opt/imapbot/ then you can add the following line to your crontab file to run the bot every 5 minutes.

*/5 * * * *     /opt/imapbot/imapbot.py

To open the crontab file type crontab -e.

imapbot's People

Contributors

eminaksehirli avatar angelos-se avatar z3ntu avatar mmitkevich avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.