Skip to content

Instantly share code, notes, and snippets.

@manzoorwanijk
Last active September 15, 2022 19:21
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manzoorwanijk/7b1786ad69826d1a7acf20b8be83c5aa to your computer and use it in GitHub Desktop.
Save manzoorwanijk/7b1786ad69826d1a7acf20b8be83c5aa to your computer and use it in GitHub Desktop.
Google Script to bypass the blockage of requests to t.me from by webhost

WPTelegram Widget Google Script

You can use this script to bypass the bans on requests to t.me by different hosts. Simply send the request to this script instead of the and pass the actual URL as url param after deploying it as a web app and allowing anonymous access.

Params

It accepts bot GET and POST requests with the following params

name type Description
url String The t.me URL

How to Deploy

  • Goto script.google.com and sign in if required.
  • Create a new project and give it a name you love :)
  • It should open a file (Code.gs by default). Remove the contents of this file.
  • Copy the contents of wptelegram-google-script for-t.me.gs below and paste into your project file (Code.gs)
  • Click File > Save or press Ctrl+S
  • Click "Publish" from the menu and select "Deploy as web app..."
  • If asked, Enter any name for the project and click "OK"
  • In "Execute the app as:", select "Me (<your email>)" [IMPORTANT]
  • In "Who has access to the app:", select "Anyone, even anonymous" [IMPORTANT]
  • Click "Deploy" to open the Authorization box.
  • Click "Review Permissions" to authorize the script.
  • In the popup window select your Google Account.
  • On the next screen, click "Allow".
  • After redirection, you should see "This project is now deployed as a web app."
  • Copy the "Current web app URL:" and paste it in your app or plugin

Watch the video

Watch the video here

function doGet(e) {
if(typeof e !== 'undefined'){
return requestHandler(e);
}
}
function doPost(e) {
if(typeof e !== 'undefined'){
return requestHandler(e);
}
}
function requestHandler(e){
var res = handleRequest(e);
return ContentService.createTextOutput(res);
}
function handleRequest(e) {
if(typeof e.parameter.url === 'undefined'){
return 'Error! URL not provided';
}
var url = e.parameter.url;
delete e.parameter.url;
var data = {
"method": "post",
"muteHttpExceptions": true,
"payload": e.parameter
}
if(typeof e.parameter.headers !== 'undefined'){
data.headers = e.parameter.headers;
}
var res = UrlFetchApp.fetch(url, data);
return res.getContentText();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment