All Projects → lubien → Elixir Telegram Bot Boilerplate

lubien / Elixir Telegram Bot Boilerplate

Licence: mit
A boilerplate for making telegram bots with Elixir and Nadia

Programming Languages

elixir
2628 projects

Projects that are alternatives of or similar to Elixir Telegram Bot Boilerplate

Base App Nestjs
Base application using nest JS focused on DDD architecture and SOLID principles
Stars: ✭ 115 (-4.17%)
Mutual labels:  boilerplate
Simple Boilerplate
A simple webpack boilerplate for your comfortable work with HTML, JS and CSS.
Stars: ✭ 116 (-3.33%)
Mutual labels:  boilerplate
Django Crud Ajax Login Register Fileupload
Django Crud, Django Crud Application, Django ajax CRUD,Django Boilerplate application, Django Register, Django Login,Django fileupload, CRUD, Bootstrap, AJAX, sample App
Stars: ✭ 118 (-1.67%)
Mutual labels:  boilerplate
Pmcenter
A Telegram bot helping you process private messages.
Stars: ✭ 115 (-4.17%)
Mutual labels:  telegram-bot
Telegram Clonebot
Simple Bot to clone Google Drive Files (or Folders) to your Team Drive[or Normal Drive]. P.S This is not a Mirror Bot. Enjoy ✌🏻
Stars: ✭ 114 (-5%)
Mutual labels:  telegram-bot
Flask Full
starter/boilerplate flask application with celery, mongoengine, signals, shell commands, swagger api docs and sphinx docs integration
Stars: ✭ 117 (-2.5%)
Mutual labels:  boilerplate
Vue Plugin Simple
A template to create vue plugins and shareable components.
Stars: ✭ 114 (-5%)
Mutual labels:  boilerplate
Vue Ts Lib
Vue 3 library starter in TS with lint, auto release, changelog and tests
Stars: ✭ 119 (-0.83%)
Mutual labels:  boilerplate
Go Postgres Jwt React Starter
A go, gin, and postgres API with jwt auth, complete with a react frontend
Stars: ✭ 115 (-4.17%)
Mutual labels:  boilerplate
Node Telegram Api
A simple API to create and control Telegram bots
Stars: ✭ 117 (-2.5%)
Mutual labels:  telegram-bot
React Redux Auth0 Kit
Minimal starter boilerplate project with CRA, React, Redux, React Router and Auth0 authentication
Stars: ✭ 115 (-4.17%)
Mutual labels:  boilerplate
Electron Boilerplate
Boilerplate to kickstart creating an app with Electron
Stars: ✭ 1,560 (+1200%)
Mutual labels:  boilerplate
Razzle Material Ui Styled Example
Razzle Material-UI example with Styled Components using Express with compression
Stars: ✭ 117 (-2.5%)
Mutual labels:  boilerplate
Web Extension Starter
Typescript, React, Redux, Styled-Component and Webpack based sample extension boilerplate. Runs on Chrome and Firefox. Sample chrome extension.
Stars: ✭ 115 (-4.17%)
Mutual labels:  boilerplate
Koalerplate
Simple Koa Boilerplate for APIs
Stars: ✭ 118 (-1.67%)
Mutual labels:  boilerplate
Golang Gin Realworld Example App
Exemplary real world application built with Golang + Gin
Stars: ✭ 1,780 (+1383.33%)
Mutual labels:  boilerplate
Docker Nginx Gunicorn Flask Letsencrypt
Boilerplate code for setting up Nginx + Gunicorn + Flask + automated LetsEncrypt certificates (https) using docker-compose.
Stars: ✭ 117 (-2.5%)
Mutual labels:  boilerplate
Angular5 Example Shopping App
Angular 5 Example Shopping App + Angular Material + Responsive
Stars: ✭ 120 (+0%)
Mutual labels:  boilerplate
Aiogram
Is a pretty simple and fully asynchronous framework for Telegram Bot API written in Python 3.7 with asyncio and aiohttp.
Stars: ✭ 2,195 (+1729.17%)
Mutual labels:  telegram-bot
Static Site Boilerplate
A better workflow for building modern static websites.
Stars: ✭ 1,633 (+1260.83%)
Mutual labels:  boilerplate

Elixir Telegram Bot Boilerplate

A boilerplate for making bots for telegram using Elixir because of yes

Getting Started

  1. Setup you bot name and telegram bot token at config/config.ex

You may set up environment-wide configurations at dev.ex, prod.ex and test at the config/ folder if you have different bots for different environments

config :app,
  bot_name: "bot_user_name"

config :nadia,
  token: "abcdefg_12345678910_the_game"
  1. Setup commands at lib/app/commands.ex

  2. Run at your shell

λ mix

Macros

command "foo" do
    IO.inspect update
    send_message "Hello Telegram"
end

The command/2 macro take a string and a block. In this case, it'll try to match anything that starts with /foo. Once it matches, it'll inject a constant named update at the scope of the do block.

send_message/2 is a macro that takes a string and a keyword list of options. But, in fact, send_message/2 maps to Nadia.send_message/3 a function that takes a chat ID as the first parameter.

The send_message/2 macro automatically understands the local scoped update constant and properly injects the chat ID for you so you can focus on sending stuff. Most of the methods at Nadia module have it's macro version for you. Take a look at App.Commander to understand better.

Another feature that must be mentioned is that these macros can understand context. Let's take a look at the get_chat_id/2 definitions:

  defmacro get_chat_id do
    quote do
      case var!(update) do
        %{inline_query: inline_query} when not is_nil(inline_query) ->
          inline_query.from.id
        %{callback_query: callback_query} when not is_nil(callback_query) ->
          callback_query.message.chat.id
        update ->
          update.message.chat.id
      end
    end
  end

If you ever used telegram bot API you may have experienced issues trying to find where is the chat ID for the current update. That's solves it under the hood in this boilerplate for you. Read more about it at App.Commands.

Matcher macros

# matches "/foo" commands
command "foo" do
end
# matches "/foo" commands from callback querys
callback_query_command "foo" do
end
# matches "/foo" commands from inline querys
inline_query_command "foo" do
end
# fallback for callback querys
callback_query do
end
# fallback for inline querys
inline_query do
end
# fallback for all updates
# must be at the end of the file
message do
end

Sender macros

answer_callback_query(options \\ [])
answer_inline_query(results, options \\ [])
send_audio(audio, options \\ [])
send_chat_action(action)
send_contact(phone_number, first_name, options \\ [])
send_document(document, options \\ [])
send_location(latitude, longitude, options \\ [])
send_message(text, options \\ [])
send_photo(photo, options \\ [])
send_sticker(sticker, options \\ [])
send_venue(latitude, longitude, title, address, options \\ [])
send_videos(video, options \\ [])
send_voice(voice, options \\ [])

Action macros

# except for inline querys
forward_message(chat_id)
get_chat
# except for inline querys
get_chat_admnistrators
get_chat_member(user_id)
get_chat_member_count
# except for inline querys
kick_chat_member(user_id)
# except for inline querys
leave_chat
# except for inline querys
unban_chat_member
get_chat_id

See also

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].