Sending messages to the sysop via Telegram: Difference between revisions

From DXSpider Documentation Wiki
Jump to navigation Jump to search
EA3CV (talk | contribs)
mNo edit summary
EA2CW (talk | contribs)
m changed set/msg_sysop by msg_sysop
 
Line 26: Line 26:
=== Examples ===
=== Examples ===
<pre>
<pre>
set/msg_sysop XX0ABC REGISTER xx0abc@example.com Requesting registration
msg_sysop XX0ABC REGISTER xx0abc@example.com Requesting registration
set/msg_sysop XX0ABC PROBLEM xx0abc@example.com My password is not working
msg_sysop XX0ABC PROBLEM xx0abc@example.com My password is not working
set/msg_sysop XX0ABC-1 INFO xx0abc@example.com Greetings from DM42
msg_sysop XX0ABC-1 INFO xx0abc@example.com Greetings from DM42
</pre>The user will receive a confirmation, and the sysop will receive the complete message via Telegram.
</pre>The user will receive a confirmation, and the sysop will receive the complete message via Telegram.



Latest revision as of 00:58, 10 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

msg_sysop XX0ABC REGISTER xx0abc@example.com Requesting registration
msg_sysop XX0ABC PROBLEM xx0abc@example.com My password is not working
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 [1]

🔐 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