All Projects → seriyps → pe4kin

seriyps / pe4kin

Licence: Apache-2.0 license
Erlang wrapper for Telegram bot API https://core.telegram.org/bots

Programming Languages

erlang
1774 projects
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to pe4kin

telegram client
library for help you make userbot or bot telegram and support tdlib telegram database and only support nodejs dart and google-apps-script
Stars: ✭ 38 (-19.15%)
Mutual labels:  telegram-bot
python-ogren-4-saatte-python-baslangic
(TR) 4 saatlik Python başlangıç atölyesinin içerik dokümanı. (EN version is in progress!)
Stars: ✭ 71 (+51.06%)
Mutual labels:  telegram-bot
VideoPlayerBot
An Telegram Bot By @AsmSafone To Stream Videos in Telegram Voice Chat. This is Also The Source Code of The Bot Which is Being Used In Our Support Group! ❤️
Stars: ✭ 187 (+297.87%)
Mutual labels:  telegram-bot
telegram bot
(deprecated) see https://github.com/protoncr/tourmaline instead
Stars: ✭ 72 (+53.19%)
Mutual labels:  telegram-bot
Google-Search-Bot
A google search telegram bot.
Stars: ✭ 32 (-31.91%)
Mutual labels:  telegram-bot
RadioPlayerV3
An Advanced Telegram Bot to Play Radio & Music in Voice Chat. This is Also The Source Code of The Bot Which is Being Used For Playing Radio in @AsmSafone Channel ❤️
Stars: ✭ 232 (+393.62%)
Mutual labels:  telegram-bot
async py bot
dark0ghost.github.io/async_py_bot/
Stars: ✭ 23 (-51.06%)
Mutual labels:  telegram-bot
SmartyScheduleBot
Telegram timetable bot, for Zhytomyr Ivan Franko State University students. It uses Politek-soft Dekanat system for getting data. With 2000+ active users. Бот расписания для Телеграм.
Stars: ✭ 22 (-53.19%)
Mutual labels:  telegram-bot
Send2KindleBot
Send to Kindle Telegram Bot
Stars: ✭ 111 (+136.17%)
Mutual labels:  telegram-bot
RedditDownloaderBot
A reddit downloader telegram bot
Stars: ✭ 32 (-31.91%)
Mutual labels:  telegram-bot
TrashMailClient-TelegramBot
A Telegram Bot allows you to quickly create a trashmail and automatically confirm mails
Stars: ✭ 40 (-14.89%)
Mutual labels:  telegram-bot
gas-SphygmoBot
A human "Heartbeat" checker hosted on Telegram.
Stars: ✭ 20 (-57.45%)
Mutual labels:  telegram-bot
Aws-Manger-Bot
一个可以管理aws资源的telegram bot
Stars: ✭ 45 (-4.26%)
Mutual labels:  telegram-bot
TamilVcMusic
A telegram bot for which is help to play songs in vc 🥰 give 🌟 and fork this repo before use 😏
Stars: ✭ 126 (+168.09%)
Mutual labels:  telegram-bot
spigot-tg-bridge
Connect Telegram chats and Minecraft servers seamlessly
Stars: ✭ 27 (-42.55%)
Mutual labels:  telegram-bot
GitHub-Webhook-Bot
It is a Simple Telegram Bot, which will listen to GitHub Webhook and inform via Telegram
Stars: ✭ 33 (-29.79%)
Mutual labels:  telegram-bot
nim-telegram-bot
Nim Telegram Bot.
Stars: ✭ 18 (-61.7%)
Mutual labels:  telegram-bot
idea
Gestor de actividades en grupo
Stars: ✭ 16 (-65.96%)
Mutual labels:  telegram-bot
formatbot1
Make instant view easily and fast, from any article on the internet in the best messenger ever Telegram
Stars: ✭ 127 (+170.21%)
Mutual labels:  telegram-bot
coinmarketcap-new-listings-sniper-bot
Sniper bot to buy new tokens listed on Coinmarketcap.
Stars: ✭ 55 (+17.02%)
Mutual labels:  telegram-bot

pe4kin

Erlang Telegram bot library. Erlang wrapper for Telegram messenger bot APIs.

With pe4kin you can receive, send, reply and forward text, as well as media messages using telegram bot API.

Pe4kin is the name of the multiplicational postman.

Example

% $ rebar3 compile
% $ rebar3 shell

> application:ensure_all_started(pe4kin).

% First of all, you need to get bot's credentials.
% Consult telegram docs https://core.telegram.org/bots#6-botfather
> BotName = <<"Pe4kin_Test_Bot">>.
> BotToken = <<"186***:******">>.


%
% Receive messages from users
%

% Launch incoming messages receiver worker.
% XXX: In real applications you'll want to launch pe4kin_receiver gen_server
%      under supervisor!
> pe4kin:launch_bot(BotName, BotToken, #{receiver => true}).

% Subscribe self to incoming messages
> pe4kin_receiver:subscribe(BotName, self()).

% Start HTTP-polling of telegram server for incoming messages
> pe4kin_receiver:start_http_poll(BotName, #{limit=>100, timeout=>60}).

% Wait for new messages.
% ...here you should send "/start" to this bot via telegram client...
> Update = receive {pe4kin_update, BotName, Upd} -> Upd end.

% Guess incoming update payload type.
> message = pe4kin_types:update_type(Update).

% Note `ChatId` - it uniquely identifies this particular chat and will be used
% in replies.
> #{<<"message">> := #{<<"chat">> := #{<<"id">> := ChatId}} = Message} = Update.

% Guess message payload type
> text = pe4kin_types:message_type(Message).

% Decode "/start" command (will raise exception if no commands in message)
> {<<"/start">>, BotName, true, _} = pe4kin_types:message_command(BotName, Message).


%
% Send messages
%

% Check that bot configured properly
> {ok, #{<<"first_name">> := _, <<"id">> := _, <<"username">> := _}} = pe4kin:get_me(BotName).

% Send reply to previously received `Update` message (note `ChatId`)
> From = maps:get(<<"first_name">>, maps:get(<<"from">>, Message, #{}), <<"Anonimous">>).
> HeartEmoji = pe4kin_emoji:name_to_char('heart').
> ResponseText = unicode:characters_to_binary([<<"Hello, ">>, From, HeartEmoji]).
> {ok, _} = pe4kin:send_message(BotName, #{chat_id => ChatId, text => ResponseText}).

% Send image to the same chat
> CatImgFileName = "funny_cat.jpg".
> {ok, CatImgBin} = file:read_file(CatImgFileName).
> Photo = {file, CatImgFileName, <<"image/jpeg">>, CatImgBin}.
> {ok, _} = pe4kin:send_photo(BotName, #{chat_id => ChatId, photo => Photo}).
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].