Wanna have embedded Telegram with only MyCode?
#1
Hi,

i tossing around with MyCode for fun and suddenly *bang* i had embedded Telegram in my forum Confused 

If you are interessted in this feature, here is the salt:

1. It is a cascading MyCode. We need 2 MyCode for to do one thing.

Telegram1:
   

Quote:https://t.me/(.*)

Quote:[telegram]$1[/telegram]


Do not use (.*?) in Telegram1!!!! Use (.*)!!!

(there is a thread where you can smell my despair cause of that https://community.mybb.com/thread-240205.html)

and Telegram2:
   

Quote:\[telegram\](.*?)\[/telegram\]


Quote:<x><script src="https://telegram.org/js/telegram-widget.js?22" data-telegram-post="$1" data-width="100%" ></script></x>


What is essential is the "parse-order". Telegram1 has the 0, will executed first. Telegram2 has the 1, will be executed after Telegram1 has did its thing.


2. Also we have to add some code in global.css

x {
border: 1px solid #ccc;
margin: 0;
background: #fff;
padding: 10px;
display: inline-flex;
flex-flow: row wrap;
justify-content: center;
}

Yes, i just define a new "tag" x for that. You also can use "blockquote" or "span" ect. for that. But cause of all others are often used and somtimes specialized, there is a high chance that we would interfere in some formats e,g, the normal "blockquote cite" or like that. So better do a stand alone tag.

3. How it works

copy the url of a single Telegram-post, e.g. https://t.me/fcukalender/6, paste it in your post-reply, send your post reply, and then you get this telegram-post automatic embedded in your post in your forum, what then looks like that

   

Have fun with it Smile
Reply
#2
Complicated...

Regex: https://t.me/(.*)
Replacement: <div class='telegram'><script src="https://telegram.org/js/telegram-widget.js?22" data-telegram-post="$1" data-width="100%" ></script></div>

New css:
.telegram {
border: 1px solid #ccc;
margin: 0;
background: #fff;
padding: 10px;
display: inline-flex;
flex-flow: row wrap;
justify-content: center;
}
And you can add the css in a new file (eg telegram.css) rather than edit the global css.
Tchat en français
Do not ask me help through PM or Discord

Reply
#3
Hoo, yes, why did i splitt it into two? I dont know Smile (edit: maybe in subconscious i was so obsessed of MyCode-cascading so i did MyCode-cascading....)


Regex: https://t.me/(.*)

<x><script src="https://telegram.org/js/telegram-widget.js?22" data-telegram-post="$1" data-width="100%" ></script></x>

x {
border: 1px solid #ccc;
margin: 0;
background: #fff;
padding: 10px;
display: inline-flex;
flex-flow: row wrap;
justify-content: center;
}
Reply
#4
Works well so far, but after embedding mycode no further content is displayed. Is there a solution ? Many thanks in advance.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)