fix dcinside regex
This commit is contained in:
parent
aedc3d5ac4
commit
31f04afd8b
|
|
@ -10,31 +10,53 @@ export default async function messageCreateEvent(message) {
|
|||
|
||||
|
||||
// URL 감지 및 메타데이터 처리
|
||||
const urlPattern = /https?:\/\/(www\.)?(m\.)?gall\.dcinside\.com\/(mgallery\/board\/view\/\?id=[^&]+&no=\d+|board\/[^\s]+)/g;
|
||||
const urls = message.content.match(urlPattern);
|
||||
const mobileUrlPattern = /https?:\/\/m\.dcinside\.com\/board\/[^\s]+/g;
|
||||
const normalUrlPattern = /https?:\/\/gall\.dcinside\.com\/mgallery\/board\/view\/\?id=[^&]+&no=\d+/g;
|
||||
|
||||
if (urls && urls.length > 0) {
|
||||
const mobileUrls = message.content.match(mobileUrlPattern);
|
||||
const normalUrls = message.content.match(normalUrlPattern);
|
||||
|
||||
// 모바일 URL 처리
|
||||
if (mobileUrls && mobileUrls.length > 0) {
|
||||
try {
|
||||
// 첫 번째 URL의 메타데이터 추출
|
||||
const metaData = await getMetaData(urls[0]);
|
||||
const metaData = await getMetaData(mobileUrls[0]); // 첫 번째 모바일 URL 메타데이터 추출
|
||||
|
||||
// Embed 메시지 생성
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(0x0099FF)
|
||||
.setTitle(metaData.title || '제목 없음')
|
||||
.setURL(urls[0])
|
||||
.setURL(mobileUrls[0])
|
||||
.setDescription(metaData.description || '설명 없음');
|
||||
|
||||
// 이미지가 있을 경우에만 추가
|
||||
if (metaData.image) {
|
||||
embed.setImage(metaData.image);
|
||||
}
|
||||
|
||||
// 메시지 채널에 Embed 전송
|
||||
await message.channel.send({ embeds: [embed] });
|
||||
} catch (error) {
|
||||
console.error('메타데이터 처리 중 오류:', error.message);
|
||||
await message.channel.send('URL에서 메타데이터를 가져오는 중 오류가 발생했습니다.');
|
||||
console.error('모바일 URL 메타데이터 처리 중 오류:', error.message);
|
||||
await message.channel.send('모바일 URL에서 메타데이터를 가져오는 중 오류가 발생했습니다.');
|
||||
}
|
||||
}
|
||||
|
||||
// 갤러리 URL 처리
|
||||
if (normalUrls && normalUrls.length > 0) {
|
||||
try {
|
||||
const metaData = await getMetaData(normalUrls[0]); // 첫 번째 갤러리 URL 메타데이터 추출
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(0x0099FF)
|
||||
.setTitle(metaData.title || '제목 없음')
|
||||
.setURL(normalUrls[0])
|
||||
.setDescription(metaData.description || '설명 없음');
|
||||
|
||||
if (metaData.image) {
|
||||
embed.setImage(metaData.image);
|
||||
}
|
||||
|
||||
await message.channel.send({ embeds: [embed] });
|
||||
} catch (error) {
|
||||
console.error('갤러리 URL 메타데이터 처리 중 오류:', error.message);
|
||||
await message.channel.send('갤러리 URL에서 메타데이터를 가져오는 중 오류가 발생했습니다.');
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue