Liking cljdoc? Tell your friends :D

lemme-know-bot

Build Status [Clojars Project]clojars [Clojure Docs]cljdoc-link Clojure version

A Telegram Bot that mentions you when your specified text in a chat matches.

Using the Code

Using the lemme-know-bot code in your own project.

To build the service JAR or use the Docker container instead, go to the next section.

See the lemme-know-bot Clojars page for details on adding this library to projects for Leiningen, Boot, and CLI/deps.edn.

Require the Library

In the REPL

(require '[lemme-know-bot.core :as lemme])

In your application

(ns my-app.core
  (:require [lemme-know-bot.core :as lemme]))

Configuration

Supported environment variables and whether they are required to be provided.

VariableDefaultDescriptionRequired?
BOT_TOKENnoneToken for bot to authenticate to the Telegram servers.Yes
LKB_SEARCHES"/tmp/lemme-know-bot-searches.edn"File for saving search state to.No
LKB_SLEEP10000Sleep time in ms between long polls.No
LKB_TIMEOUT10Timeout in seconds to wait while long polling.No

Usage

Building the Java Jar and running it or the Docker container.

Pre-Reqs

Before building the JAR or running the docker container:

  • Create a Telegram bot using the botfather.
    • Configure the bot to give it access to group chat messages. (group privacy disabled)

Proceed with either the Docker or Jar instructions.

Run the App - Docker

  • Setup the volume for saving the search state
# Docker volume name (docker volume ls)
DOCKER_VOL=lemme-know-bot

docker volume create ${DOCKER_VOL}

# Container path for the search state (matches the Dockerfile)
CONTAINER_SAVE_DIR=/usr/src/app/state
  • Run the container
docker run \
--detach \
--name lemme-know-bot \
--env BOT_TOKEN="MY-TOKEN-HERE" \
--env LKB_SEARCHES=${CONTAINER_SAVE_DIR}/lemme-know-bot-searches.edn \
--volume ${DOCKER_VOL}:${CONTAINER_SAVE_DIR} \
wdhowe/lemme-know-bot

Pre-Reqs - Java Jar

Pre-reqs for building the Java Jar.

  • Install leiningen.
  • Clone this project.
  • Build the jar
lein uberjar

Run the App - Java Jar

  • Make your bot token available in the environment
    • Other env vars should be exported at this step if you would like to change any default settings.
    • See Configuration for details.
export BOT_TOKEN="MY-TOKEN-HERE"
  • Start the service
java -jar lemme-know-bot-VERSION-standalone.jar

Telegram Group Setup

Once the service is running from one of the above methods:

  • Add your bot to a Telegram group chat.
  • Start chatting with your bot in the Telegram group chat.
    • Send '/help' to get started.

License

Copyright © 2020 Bill Howe

This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0.

This Source Code may also be made available under the following Secondary Licenses when the conditions for such availability set forth in the Eclipse Public License, v. 2.0 are satisfied: GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version, with the GNU Classpath Exception which is available at https://www.gnu.org/software/classpath/license.html.


Can you improve this documentation? These fine people already did:
wdhowe & Bill Howe
Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close