Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nushell-prophet/nu-telegram-bot
https://github.com/nushell-prophet/nu-telegram-bot
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/nushell-prophet/nu-telegram-bot
- Owner: nushell-prophet
- License: unlicense
- Created: 2024-03-30T13:24:28.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-06-16T10:14:13.000Z (6 months ago)
- Last Synced: 2024-06-16T11:31:29.156Z (6 months ago)
- Language: Nushell
- Size: 31.3 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-nu - nu-telegram-bot
README
# nu-telegram-bot
[![No Maintenance Intended](http://unmaintained.tech/badge.svg)](http://unmaintained.tech/)
A basic Nushell module for interacting with the Telegram Bot API.
![nutgb-demo](https://github.com/nushell-prophet/nu-telegram-bot/assets/4896754/ab93a871-54a8-4c5c-99c9-1ae54fce19e2)
# Quick start
1. Clone this repository
```nu no-run
> git clone https://github.com/nushell-prophet/nu-telegram-bot
> cd nu-telegram-bot
> use nutgb.nu
```
2. Obtain the token for your bot from [@botfather](https://t.me/botfather) and add it to `nutgb````nu no-run
nutgb add-bot
```
3. Send any message to your new bot from the account that will later receive messages from the bot.
(optionally, you can add this bot to the group or channel).4. Receive updates (sent messages to the bot or events of adding him to groups).
Mind that you can use `tab` auto-completion for the bot's name here.```nu no-run
nutgb get-updates
```5. If the previous command gave you some data, it means that now you can send messages using `nutgb send-message`
```nu no-run
nutgb send-message 'some message' --recipient
````nutgb` saves tokens and conversations with users:
1. If `$env.nutgb-path` is set - in that folder.
2. If `$env.XDG_CONFIG_HOME` is set, then in `nutgb` folder inside.
3. Otherwise, in `.nutgb` folder in home `$nu.home-path`.You are welcome to read the code and make your understanding.
The part about locating needed files is described [here](https://github.com/nushell-prophet/nu-telegram-bot/blob/a4528eef02de23e9faa0054304cce46f35ef584e/nutgb.nu#L167).# commands help
```nushell
use nutgb.nu
nutgb add-bot -h
```Output:
```
add a Telegram bot using the provided token and optionally return bot informationUsage:
> add-bot {flags}Flags:
--return_info - if set, returns bot information instead of saving it
--default - make this bot default for sending messages from
-h, --help - Display the help message for this commandParameters:
bot_token : the bot token provided by Telegram's Botfather https://t.me/botfather
``````nushell
nutgb get-updates -h
```Output:
```
retrieve messages sent to a bot by users in last hours and save them locallyUsage:
> get-updatesFlags:
-h, --help - Display the help message for this commandParameters:
bot_name : the name of the bot to retrieve updates for
``````nushell
nutgb send-message -h
```Output:
```
send a text message to a recipient via a botUsage:
> send-message {flags} (message_text)Flags:
--silent_notification - if set, disables notification for the recipient
--text_format - the mode for parsing the message - 'MarkdownV2', 'Markdown', 'HTML' (default: '')
--recipient_id - the recipient of the message
--reply_to_id - the message ID to reply to (default: '')
--suppress_output - don't output send details
-h, --help - Display the help message for this commandParameters:
message_text : the message text to be sent (optional)
``````nushell
nutgb send-image -h
```Output:
```
send an image or animation file to a recipient via a botUsage:
> send-image {flags} (media_path)Flags:
--recipient_id - the recipient of the message
--text_format - the mode for parsing the message caption (default: '')
--media_caption - the caption for the image or animation (default: '')
--reply_to_id - the message ID to reply to (default: '')
--silent_notification - if set, disables notification for the recipient
--suppress_output - don't output send details
-h, --help - Display the help message for this commandParameters:
media_path : the path to the image or animation file to be sent (optional)
``````nushell
nutgb get-recipients -h
```Output:
```
get a list of recipients for a bot, optionally updating the listUsage:
> get-recipients {flags} (bot_name)Flags:
--refresh_chat_list - if set, updates the recipient list by making a request
--set-default - set default recipient to omit setting in other commands
-h, --help - Display the help message for this commandParameters:
bot_name : the name of the bot to retrieve recipients for (optional)
```