Sending messages to the sysop via Telegram: Difference between revisions

From DXSpider Documentation Wiki
Jump to navigation Jump to search
EA3CV (talk | contribs)
Created page with " = πŸ“‘ Sending messages to the sysop via Telegram = == πŸ“‹ Description == The `msg_sysop` command allows users connected to a DXSpider node to send a direct message to the sysop via Telegram. It is useful for: * Requesting registration on the node * Reporting issues or failures * Making general enquiries The message includes the following data: * User callsign * Subject (e.g. REGISTER, PROBLEM, INFO) * Email address * Message text * Access IP == ▢️ Command us..."
Β 
EA3CV (talk | contribs)
mNo edit summary
Line 79: Line 79:
Save it as:<pre>
Save it as:<pre>
/spider/local_cmd/msg_sysop.pl
/spider/local_cmd/msg_sysop.pl
</pre><pre>
</pre>It may be helpful to look at <nowiki>[https://wiki.dxcluster.org/wiki/Setting_up_the_EA3CV_contributions_repository]</nowiki>
Β 
Β 
</pre>


== πŸ” How to get your Telegram ID and Token ==
== πŸ” How to get your Telegram ID and Token ==

Revision as of 16:05, 9 April 2025

πŸ“‘ Sending messages to the sysop via Telegram

πŸ“‹ Description

The `msg_sysop` command allows users connected to a DXSpider node to send a direct message to the sysop via Telegram.

It is useful for:

  • Requesting registration on the node
  • Reporting issues or failures
  • Making general enquiries

The message includes the following data:

  • User callsign
  • Subject (e.g. REGISTER, PROBLEM, INFO)
  • Email address
  • Message text
  • Access IP

▢️ Command usage

From the DXSpider shell:

msg_sysop <CALL> <SUBJECT> <EMAIL> <MESSAGE>

Examples

set/msg_sysop XX0ABC REGISTER xx0abc@example.com Requesting registration
set/msg_sysop XX0ABC PROBLEM xx0abc@example.com My password is not working
set/msg_sysop XX0ABC-1 INFO xx0abc@example.com Greetings from DM42

The user will receive a confirmation, and the sysop will receive the complete message via Telegram.

βš™οΈ Required configuration

To use the `msg_sysop` command, minimal setup is needed for the Telegram bot.

πŸ“ File: /spider/local/Local.pm

Add the following to the end of the file, just before the final `1;`:

sub telegram
{
    my $payload = shift;

    my $url = "https://api.telegram.org/bot$main::token/sendMessage";
    `curl -s -X POST $url -d chat_id=$main::id -d text="$payload\n" -d parse_mode="Markdown"`;
}

If `/spider/local/Local.pm` does not exist, you can copy it from the base installation:

cp /spider/perl/Local.pm /spider/local/

πŸ“ File: /spider/local/DXVars.pm

Add your bot credentials at the end of the file, just before `1;`:

# Telegram Bot
$id = "123456789";
$token = "89734237899:KF90V20M90MCQJA9Q0'91C,CCC'0944";

Restart the node to apply the changes:

shutdown

πŸ’¬ Notify unregistered users

To let users know that they need to register and can use the `msg_sysop` command, you can override the default DXSpider error message.

Edit `/spider/startup` and add the following lines:

set/var $DXM::msgs{en}{e28} = 'Sorry, you need to be registered (Use the msg_sysop command to request registration.)'
set/var $DXM::msgs{es}{e28} = 'Lo sentimos, necesitas estar registrado (Usa el comando msg_sysop para solicitar registrarte)'

πŸ“’ Display a message in the MOTD

To remind users upon login, edit the file `/spider/local_data/motd_nor`:

+-----------------------------------------------------------------------------+
|     If you wish to have full access, please use the command 'msg_sysop'     |
|                to request registration on this node.                        |
+-----------------------------------------------------------------------------+

πŸ“¦ Script download

You can download the `msg_sysop.pl` script from the official repository:

View on GitHub - EA3CV/dxspider_info

Save it as:

/spider/local_cmd/msg_sysop.pl

It may be helpful to look at [https://wiki.dxcluster.org/wiki/Setting_up_the_EA3CV_contributions_repository]

πŸ” How to get your Telegram ID and Token

To receive messages, you need to configure a Telegram bot:

  1. Open Telegram and search for @BotFather
  2. Start a new bot with: /newbot and follow the instructions
  3. BotFather will return a token like:
1234567890:AAEjg0EjEMPLO_T0KEN4PRUEBA1234
  1. Send any message to your bot via Telegram
  2. Then open this URL in your browser (replace with your actual token):
https://api.telegram.org/bot<your_token>/getUpdates

You will see something like:

"chat":{"id":123456789,"first_name":"YourName",...}

That number is your **chat ID**. Use this ID and your token in `/spider/local/DXVars.pm`.

⚠️ Important

This script **only works with Telegram bots**. It is not possible to send messages directly to personal accounts via the Telegram API.

🧠 Additional notes

  • This command is designed as a lightweight and direct alternative to email.
  • The sysop receives all relevant data, including the user’s IP and callsign.
  • You may combine this with logging or other scripts for additional traceability.

πŸ§‘β€πŸ’» Author