Skelegram - The Skript Telegram Addon!

Addon Skelegram - The Skript Telegram Addon! 1.1-ALPHA

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

Supported Minecraft Versions
  1. 1.12
  2. 1.13
  3. 1.14
  4. 1.15
  5. 1.16
  6. 1.17
  7. 1.18
  8. 1.19
Hello everyone, I'm glad to announce
Skelegram
a skript addon for creating Telegram Bots entirely in Skript.

8594_834b84522e38cf18d69133d9d30dbe3f.png

A telegram message with buttons, created and sent entirely via Skript.​
Code:
Options:
p: &7[&bTG&7]
    username: SkriptItaly_bot #the username of the bot.
    token: TOKEN-HERE #the token of the bot
 

 
on load:
    send message "{@p} &9Authorizing telegram bot {@username}..." to console
    telegram login to bot "{@username}" with token "{@token}"
    send message "{@p} &9Completed." to console

on telegram message:
    if "%event-telegram bot%" is "{@username}":
        set {_mess} to a new telegram message with text "Welcome, @%sender of event-telegram message% to Skelegram!%nl%%nl%This Telegram bot has been entirely coded in ‍ Skript!"
        set {_link} to a new inline button with text " Link " with url "https://github.com/DereWah/Skelegram"
        set {_data} to a new inline button with text " About Us " with callback data "about_us"
        set {_kb} to a new inline keyboard with buttons {_link} and {_data}
        set inline keyboard of {_mess} to {_kb}
        send telegram message {_mess} to sender of event-telegram message




TelegramLink is basically a Skript that gives you functions for linking telegram users to minecraft users.

It is an helper skript, it's just for giving devs a simple and universal way of tracking users. You can choose to create your own method of tracking users.


How does this work?
Skelegram allows you to create a bot and interact with Telegram via its Bot API. Here are some possible application ideas (not created yet):

- Telegram Console - Run any command sent by a trusted user on telegram on the minecraft console.
- View Minecraft Chat on Telegram - Make the bot echo any message sent in Minecraft onto a Telegram channel.
- Get Intruder Alerts - Receive a telegram notification whenever a not trusted player enters your house in a region!
- 2FA - Ask players/staff to send in chat a code they will receive on telegram (they must have linked an account through a linking system before) to verify themselves.

These are only a few of the possible implementations! But now let's start playing with the addon.

How do I create a bot?
1. Create a bot on telegram.
On telegram, start
BotFather and follow the tutorial to create a bot. You will be asked for details about the bot. After setting it up, you will receive a message with a long token in it. Copy it and save it, as you will need it soon. Also save the unique username of the bot.
2. Create a new skript and authorize the bot.
Copy the code below to have a template authorization skript.
Code:
Options:

    p: &7[&bSkelegram&7]
    username: SkriptItaly_bot #the username of the bot.
    token: TOKEN-HERE #the token of the bot
 
on load:
    send message "{@p} &9Authorizing telegram bot {@username}..." to console
    telegram login to bot "{@username}" with token "{@token}"
    send message "{@p} &9Completed." to console

2.1 About bot sessions
Read this before going ahead with the tutorial please.
A telegram bot can be controlled by only 1 Skript at a time.
If you have multiple skripts running the same bot, you might end up receiving API errors in the console.
Bots are controlled by sessions, and in Skelegram, you can have multiple sessions running, but only 1 for each bot.

Reloading a skript does not stop a session!
This means that you can quickly edit your bot behaviour without having to send it offline.
Server reloads or restarts DO stop all the sessions!
And because stopping a session may take up to 50 seconds, those operations may take a little bit longer. It is how the Telegram API works, and you can't do much about it.

3. Customize your bot behaviour.
You can now setup your bot to connect Telegram to Minecraft! Let's see some examples.

You can listen for incoming messages via the event
Code:
on telegram message:
If you have multiple bots running, the event will be fired for any incoming message. You can filter if the message is directed to your bot with
Code:
on telegram message:
    if "%event-telegram bot%" is "{@username}":
        #the message is for our bot!

Let's now show the message we just received on Telegram in minecraft! This will allow any player that uses the bot to send a visible message to all the players in game.

Code:
Options:
    p: &7[&bTG&7]
    username: SkriptItaly_bot #the username of the bot.
    token: TOKEN-HERE #the token of the bot
 
on load:
    send message "{@p} &9Authorizing telegram bot {@username}..." to console
    telegram login to bot "{@username}" with token "{@token}"
    send message "{@p} &9Completed." to console

on telegram message:
    if "%event-telegram bot%" is "{@username}":
        send "{@p} &9%sender of event-telegram message%&7: %text of event-telegram message%" to all players

If we want to give some feedback to the user on telegram, we can let them know that their message has been succesfully forwarded to the Minecraft world!

To do so we can simply use the reply to telegram message effect:
Code:
reply to telegram message event-telegram message with "Your message has been sent!"
8593_1c108cf3335a1d010a625fe5eefb289d.png

8592_ccdfca345f8f39b673c958e06a40975a.png

4. Read the docs!
You can do a lot more with this addon. You can add buttons, add keyboards to the chat or edit messages! Even though there still are a lot of missing elements of the Telegram BOT Api in the addon, my plan is to implement them all. If you have any specific need from the API (that isn't implemented yet) you can suggest it on the issue tracker on github.

To learn more about how to use Skelegram at its full power, you can check out the documentation page with some examples HERE.

In the next few weeks I will create in-depth tutorials on how to create more advanced stuff such as working telegram keyboards and buttons.

Contacts
TG: @DereWah
Discord: DereWah#8414
  • upload_2023-5-5_20-2-11.png
    upload_2023-5-5_20-2-11.png
    15.7 KB · Views: 72
  • upload_2023-5-5_21-23-33.png
    upload_2023-5-5_21-23-33.png
    37.8 KB · Views: 84
  • upload_2023-5-5_21-32-23.png
    upload_2023-5-5_21-32-23.png
    21.5 KB · Views: 80
  • upload_2023-5-5_21-46-46.png
    upload_2023-5-5_21-46-46.png
    24.2 KB · Views: 70
Author
DereWah
Downloads
216
Views
477
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from DereWah