Coder Social home page Coder Social logo

raghur / hey.py Goto Github PK

View Code? Open in Web Editor NEW
5.0 3.0 1.0 58 KB

Dead simple reminder CLI tool for linux; Reminders are shown on Web and Mobile using your own Telegram bot

Python 96.88% Shell 3.12%
telegram-bot productivity-timer reminder-app console-tool linux-app atd

hey.py's Introduction

Hey - your personal telegram notifier

Set simple one-shot reminders and texts with an easy, approachable CLI with notifications on all your devices

Why

  1. Dead simple - all of 130 lines in a single script file

  2. No server process to run. Uses atd daemon and most likely that’s already running

  3. Telegram clients are available for pretty much every platform

  4. Handles fuzzy, human friendly dates and times (like friday after next); Handles timezone conversions as well (so 9AM EST)

    But my machine isn’t ONLINE 24x7
  5. Install it on a server and with password-less ssh and setup a shell script or alias to execute hey on the server.

Installation

# clone the repo
# cd into the folder

./install.sh

# check if at daemon is enabled & running
sudo systemctl status atd

# Enable and start it if needed.
sudo systemctl enable atd
sudo systemctl start atd

That’s about it for installation You’ll need to configure a telegram bot before you can get started. See the section below

Configuration

Create a telegram BOT
  1. Create a telegram bot and send it a message

    • search for BotFather

    • type /newbot

    • give it a friendly name and a bot name (bot name must end in _bot)

    • Pick up the bot token from botfather.

  2. Get a chat id

    • Telegram global search, type your bot name or id

    • type /start

    • send any text.

    • Run curl https://api.telegram.org/bot$TOKEN/getUpdates

          {
        "ok": true,
        "result": [
          {
            "update_id": 519260759,
            "message": {
              "message_id": 2,
              "from": {
                "id": 535955002,
                "is_bot": false,
              },
              "chat": {
                "id": 123456789, //(1)
                "type": "private"
              },
              "date": 1567922393,
              "text": "hello"
            }
          }
        ]
      }
  3. Update the config file in the folder with the bot token and chat id

Timezone

In case you run this on a server that’s on UTC (As with most cloud providers), then set the TIMEZONE=<Tz code> to set the timezone of the client machine.

NOTE Once again, this isn’t the server timezone. If your client and server are in the same timezone, then DO NOT specify the timezone (key should not present)

NOTE 2: Timezone code is one of TZ database names, like so - TIMEZONE=Asia/Kolkata see TZ Database

Config file locations

Files are read in the following sequence, later files override earlier entries defined in earlier ones. . Alongside hey.py, named as config . /etc/hey.conf . ~/.config/hey.conf

Usage

> hey.py /t 10 AM Friday /m Get a hair cut


# My local timezone is India (IST, +0530), hey is on a server on UTC
# and you can have tz info in the string - say some office opens at 9 AM EST

> hey.py -t 9 AM EST -m call customer support
reminder 'call customer support' set for 10:30 PM 2019-10-16
Note
arg parsing is basic and does not follow typical shell parsing conventions. First arg has to be /t and then it scans forward till a /m. The gathered string is parsed to a date. Anything after the /m is just concatenated to the message.

Time expressions

Time expression examples:
    in 10 minutes
    in 1 month
    next week
    friday 10 AM
    wed 10 AM
    10 AM Tues
Refer to https://dateparser.readthedocs.io/en/latest/ for documentation on date
expressions

hey.py's People

Contributors

dependabot[bot] avatar raghur avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

joeeager

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.