Skip to content

Instantly share code, notes, and snippets.

@whatsmate
whatsmate / send-whatsapp.cs
Last active July 18, 2022 06:45
Sending a WhatsApp message in C# (Visual Studio 2022)
using System;
using System.Net;
using System.Text.Json;
using System.IO;
using System.Text;
class WaMessageSender
{
// TODO: Replace the following with your gateway instance ID, Forever Green client ID and secret:
private static string INSTANCE_ID = "YOUR_INSTANCE_ID_HERE";
@whatsmate
whatsmate / group-send-telegram-opus.vbs
Created July 8, 2022 07:34
How to send a voice note file to a Telegram group in Visual Basic Script
Sub Main_Routine()
''' The first parameter is the name of the group
''' The second parameter is the number of the group admin
''' The third parameter is the full path to the voice note file (e.g. OPUS file)
''' The fourth parameter is the filename displayed to the recipient.
''' The fifth parameter is the caption for the voice note file.
TelegramVoice_GroupSend "Muscle Men Club", "19159876123", "C:\Users\Public\martin-luther-king.opus", "anyname.opus", "I have a dream" ''' TODO: Specify the target group
End Sub
@whatsmate
whatsmate / send-telegram-opus-group.py
Created July 8, 2022 06:58
How to send a voice note file to a Telegram group in Python
#!/usr/bin/env python3
import base64
import requests
# TODO: Put down your own Client ID and secret
instanceId = "YOUR_GATEWAY_INSTANCE_ID_HERE"
clientId = "YOUR_OWN_ID_HERE"
clientSecret = "YOUR_OWN_SECRET_HERE"
@whatsmate
whatsmate / group-send-telegram-opus.php
Created July 8, 2022 06:49
How to send a voice note file to a Telegram group in PHP
<?php
$INSTANCE_ID = 'YOUR_INSTANCE_ID_HERE'; // TODO: Replace it with your gateway instance ID here
$CLIENT_ID = "YOUR_CLIENT_ID_HERE"; // TODO: Replace it with your Premium client ID here
$CLIENT_SECRET = "YOUR_CLIENT_SECRET_HERE"; // TODO: Replace it with your Premium client secret here
$pathToDocument = "/tmp/martin-luther-king.opus"; // TODO: Replace it with the path to your voice note file
$voiceData = file_get_contents($pathToDocument);
$base64VoiceNote = base64_encode($voiceData);
$fn = "anyname.opus"; // TODO: Replace it with any name you like
$caption = "I have a dream"; // TODO: Replace it with an eye-catching caption
@whatsmate
whatsmate / group-send-telegram-opus.js
Created July 8, 2022 06:44
How to send a voice note file to a Telegram group in Node.js
#!/usr/bin/env node
var http = require('http');
var fs = require('fs');
// Put down your own client ID and secret here:
var instanceId = "YOUR_OWN_GATEWAY_INSTANCE_ID";
var clientId = "YOUR_OWN_CLIENT_ID";
var clientSecret = "YOUR_OWN_SECRET_ID";
@whatsmate
whatsmate / TelegramGroupOpusSender.java
Last active February 8, 2026 14:16
How to send a voice note file to a Telegram group in Java
/*
* If you use Maven, add the following to your pom.xml:
* <dependency>
* <groupId>com.google.code.gson</groupId>
* <artifactId>gson</artifactId>
* <version>2.8.0</version>
* </dependency>
* <dependency>
* <groupId>commons-codec</groupId>
* <artifactId>commons-codec</artifactId>
@whatsmate
whatsmate / group-send-telegram-opus.gs
Created July 7, 2022 09:06
How to send a voice note file to a Telegram group from Google Apps Script
function demoSendOpusToTelegramGroup() {
var group_name = "Muscle Men Club"; // TODO: Specify the name of your group
var group_admin = "12025550108"; // TODO: Specify the number of the group admin
var opusFilename = "martin-luther-king.opus"; // TODO: This file must be uniquely named and, of course, exist in your Google Drive!!!
var filename = "anyname.opus"; // TODO: Use any name you like
var caption = "I have a dream"; // TODO: Use any caption you like
var opusBase64 = base64encodeFileByName(opusFilename);
if (opusBase64 == null) {
Logger.log("Abort! OPUS file error: " + opusFilename);
@whatsmate
whatsmate / group-send-telegram-opus.cs
Created July 7, 2022 08:48
How to send a voice note file to a Telegram group in C#
using System;
using System.Net;
using System.Web.Script.Serialization; // requires the reference 'System.Web.Extensions'
using System.IO;
using System.Text;
class TelegramGroupOpusSender
{
// TODO: Replace the following with your gateway instance ID, client ID and secret!
private static string INSTANCE_ID = "YOUR_INSTANCE_ID";
@whatsmate
whatsmate / group-send-telegram-opus.sh
Created July 7, 2022 07:32
How to send an voice note file to a Telegram group from bash shell script
#!/bin/bash
#######################################################################
# You will need to have the utility `base64` available on your Linux
# system to run this script.
#
# To install it:
# sudo apt-get install coreutils
#######################################################################
@whatsmate
whatsmate / group-send-telegram-mp3.vbs
Created July 6, 2022 09:22
How to send an MP3 file to a Telegram group in Visual Basic Script
Sub Main_Routine()
''' The first parameter is the name of the group
''' The second parameter is the number of the group admin
''' The third parameter is the full path to the audio file (e.g. MP3 file)
''' The fourth parameter is the filename displayed to the recipient.
''' The fifth parameter is the caption for the audio file.
TelegramAudio_GroupSend "Muscle Men Club", "19159876123", "C:\Users\Public\ocean-waves.mp3", "anyname.mp3", "Enjoy the nature" ''' TODO: Specify the recipient's number here. NOT the gateway number
End Sub