fedimbed: subtext to minimal with message linking
This commit is contained in:
		
							parent
							
								
									8f5a5914ba
								
							
						
					
					
						commit
						c28d79947f
					
				
					 1 changed files with 4 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -14,7 +14,7 @@ const {htmlToMarkdown} = require("#util/html.js");
 | 
			
		|||
const FRIENDLY_USERAGENT =
 | 
			
		||||
  "Mozilla/5.0 (compatible; HiddenPhox/fedimbed; +https://gitdab.com/Cynosphere/HiddenPhox) Discordbot/2.0";
 | 
			
		||||
 | 
			
		||||
const URLS_REGEX = /(?:\s|^|\]\()(\|\|\s*)?(https?:\/\/[^\s<]+[^<.,:;"'\]|)\s])(\s*\)?\|\||\s*[\S]*?\))?/g;
 | 
			
		||||
const URLS_REGEX = /(?:\s|^|\]\(|-#\s+)(\|\|\s*)?(https?:\/\/[^\s<]+[^<.,:;"'\]|)\s])(\s*\)?\|\||\s*[\S]*?\))?/g;
 | 
			
		||||
const SPOILER_REGEX = /(?:\s|^)\|\|([\s\S]+?)\|\|/;
 | 
			
		||||
 | 
			
		||||
const BSKY_POST_REGEX =
 | 
			
		||||
| 
						 | 
				
			
			@ -1601,11 +1601,13 @@ events.add("messageCreate", "fedimbed", async function (msg) {
 | 
			
		|||
  if (URLS_REGEX.test(msg.content)) {
 | 
			
		||||
    const urls = msg.content.match(URLS_REGEX);
 | 
			
		||||
    for (let url of urls) {
 | 
			
		||||
      const minimal = /^-#\s+/.test(url);
 | 
			
		||||
      const hasSpoiler = SPOILER_REGEX.test(url);
 | 
			
		||||
      url = url
 | 
			
		||||
        .replace(/\|/g, "")
 | 
			
		||||
        .replace(/^\]\(/, "")
 | 
			
		||||
        .replace(/\s*[\S]*?\)$/, "")
 | 
			
		||||
        .replace(/^-#\s+/, "")
 | 
			
		||||
        .trim()
 | 
			
		||||
        .replace("#\u200b", "#")
 | 
			
		||||
        .replace("#%E2%80%8B", "#");
 | 
			
		||||
| 
						 | 
				
			
			@ -1620,7 +1622,7 @@ events.add("messageCreate", "fedimbed", async function (msg) {
 | 
			
		|||
        if (urlObj && regex.test(urlObj.pathname)) {
 | 
			
		||||
          if (service != "twitter") logger.verbose("fedimbed", `Hit "${service}" for "${url}", processing now.`);
 | 
			
		||||
          try {
 | 
			
		||||
            const {response, sendWait} = await processUrl(msg, url, hasSpoiler);
 | 
			
		||||
            const {response, sendWait} = await processUrl(msg, url, hasSpoiler, false, false, minimal);
 | 
			
		||||
            if (!response) return;
 | 
			
		||||
            await msg.channel.createMessage(response).then(() => {
 | 
			
		||||
              if (sendWait) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue