TeleLink - Link Minecraft accounts to Telegram with Skript!

  • 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!

DereWah

New Member
Jul 19, 2019
0
0
0
TeleLink
A helper skript to manage Minecraft players and their linked Telegram Accounts.



TeleLink account linking in Minecraft


TeleLink account linking in Telegram


Custom bot behaviour, on a separate Skript, but on the same telegram bot.

DEPENDENCIES
- Spigot/Paper 1.12.2+
- Skelegram addon 1.1-ALPHA

- Skript 2.6.2+


With this Skript, and with Skelegram, you'll create a new telegram bot that will interact with users. You'll be able to customize every aspect of the Skript, and even get functions to create your own!
Code:
#------- COMMANDS -------
#/telelink | telelink.use | main command
#/telelink link | telelink.use | begin linking your account.
#/telelink unlink | telelink.use | unlink your account.
#/telelink forceunlink | telelink.admin | forcefully unlink a player's account.
#/telelink stop | telelink.admin | stop the bot
#/telelink start | telelink.admin | start the bot
#/telelink reset | telelink.admin | reset all the variables and linked users.
#/telelink view | telelink.view | view another user's linked telegram account.
#------------------------

Code:
#------ FUNCTIONS -------
#You may use the following functions to automatically get a player's TG account on the server. This is useful to quickly build a bot without having to register every user, as this already does the work you.

#getLinkedMinecraft(id: text) | Get the linked minecraft account of a telegram ID of a user. The ID has to be a text, as Skript can't handle long numbers (and IDs are really long numbers)
#getBotUser() | Get the username of the bot that is running TeleLink. TeleLink can only run 1 bot at a time, but a server may be running multiple different bots, so in order to send messages on commands or outside of telegram events you need to specify a bot name.
#getTelegramID(p: player) | Get the unique Telegram ID of a player, if they have linked an account. Otherwise null.
#getTelegramUsername(p: player) | Get the username of a player. Use this just for aesthetics, DON't RELY ON THIS! It may be null or could even not correspond to the player's updated username, as they can change it. USE getTelegramID instead!!
#------------------------



Code:
Options:
    id: -1001921980391 #La chat in cui verrà mandato il messaggio


on chat:
    set {_message} to message
    set {_sender} to event-player
    send telegram message " %{_sender}%: %{_message}%" to {@id} with bot getBotUser()


on death of player:
    if attacker is set:
        send telegram message "⚔️ %victim% è stato ucciso da %attacker%" to {@id} with bot getBotUser()
        if getTelegramID(victim) is set:
            send telegram message "⚔️ Sei stato ucciso da %attacker%!" to getTelegramID(victim) with bot getBotUser()
     

on join:
    if getTelegramID(player) is set:
        set {_message} to a new telegram message with text " Ti sei connesso al server in data %now%"
        set {_button} to a new inline button with text "❌ KICK ❌" with callback data "kick"
        set {_keyboard} to a new inline keyboard with button {_button}
        set inline keyboard of {_message} to {_keyboard}
        send telegram message {_message} to getTelegramID(player) with bot getBotUser()
 
on callback query with data "kick":
    if "%event-telegram bot%" is getBotUser():
        set {_id} to "%id of event-telegram user%"
        if getLinkedMinecraft({_id}) is set:
            set {_p} to getLinkedMinecraft({_id})
            kick {_p}
            set {_text} to text of event-telegram message
            set {_text} to "%{_text}%%nl%%nl%✅ Hai kickato questo utente."
            set {_newmessage} to a new telegram message with text {_text}
            edit telegram message event-telegram message to {_newmessage} with bot getBotUser()
     
on join:
    send telegram message "➕ %player% si è connesso." to {@id} with bot getBotUser()

on quit:
    send telegram message "➖ %player% si è disconnesso." to {@id} with bot getBotUser()