Compare commits
14 Commits
bugfixes/c
...
8ab6b9d986
Author | SHA1 | Date | |
---|---|---|---|
8ab6b9d986 | |||
2261e753d5 | |||
88dd3b5908 | |||
f8f94b4afc | |||
309d7c0cd3 | |||
f37beb0a5d | |||
eec1050e17 | |||
8ffd920007 | |||
846b7d10d8 | |||
5adc9b7b9f | |||
3eb412bd6e | |||
1949c7af1b | |||
993a94ddb1 | |||
26dcd962b8 |
@ -4,11 +4,6 @@ type: docker
|
||||
name: publish-bot
|
||||
|
||||
steps:
|
||||
- name: build-dotnet
|
||||
image: mcr.microsoft.com/dotnet/sdk:6.0
|
||||
commands:
|
||||
- dotnet publish
|
||||
|
||||
- name: build-image
|
||||
image: plugins/docker
|
||||
settings:
|
||||
@ -17,10 +12,8 @@ steps:
|
||||
from_secret: DOCKER_USER
|
||||
password:
|
||||
from_secret: DOCKER_PASS
|
||||
repo: git.kizaing.ca/kizaing/TeleTok
|
||||
repo: git.kizaing.ca/kizaing/teletok
|
||||
tags: latest
|
||||
platform: linux/amd64,linux/arm64
|
||||
|
||||
|
||||
# Commented out until stuff actually works
|
||||
trigger:
|
||||
|
13
Dockerfile
13
Dockerfile
@ -1,7 +1,14 @@
|
||||
FROM mcr.microsoft.com/dotnet/runtime:6.0-alpine3
|
||||
#Builds the bot from source
|
||||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-task
|
||||
|
||||
COPY . /build
|
||||
RUN cd /build && dotnet publish
|
||||
|
||||
# Actually runs the bot
|
||||
FROM mcr.microsoft.com/dotnet/runtime:6.0
|
||||
|
||||
WORKDIR /app/teletok
|
||||
|
||||
COPY bin/Debug/net6.0/publish/* /app/teletok/
|
||||
COPY --from=build-task /build/bin/Debug/net6.0/publish/* /app/teletok/
|
||||
|
||||
CMD [ "TeleTok" ]
|
||||
CMD [ "./TeleTok" ]
|
@ -22,5 +22,12 @@ namespace TeleTok
|
||||
listener.RunListener();
|
||||
|
||||
}
|
||||
|
||||
public static void LogMessage(string text)
|
||||
{
|
||||
DateTime now =DateTime.Now;
|
||||
|
||||
Console.WriteLine("[" + now.ToString() + "] " + text);
|
||||
}
|
||||
}
|
||||
}
|
@ -55,22 +55,15 @@ namespace TeleTok
|
||||
// Passes the url along to the video downloader if it is valid AND a tiktok link
|
||||
if (isUri)
|
||||
{
|
||||
try
|
||||
if(messageText.Contains("tiktok.com"))
|
||||
{
|
||||
if(messageText.Contains("tiktok.com"))
|
||||
{
|
||||
proxyUrl = VidDownload.TikTokURL(messageText);
|
||||
proxyUrl = VidDownload.TikTokURL(messageText);
|
||||
|
||||
Message ttVideo = await botClient.SendVideoAsync(
|
||||
chatId: chatId,
|
||||
video: proxyUrl,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("Valid TikTok URI was sent, but was not a video!");
|
||||
Message ttVideo = await botClient.SendVideoAsync(
|
||||
chatId: chatId,
|
||||
video: proxyUrl,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -84,7 +77,7 @@ namespace TeleTok
|
||||
_ => exception.ToString()
|
||||
};
|
||||
|
||||
Console.WriteLine(ErrorMessage);
|
||||
TeleTok.LogMessage(ErrorMessage);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
@ -12,13 +12,16 @@ namespace TeleTok
|
||||
string url = videourl;
|
||||
string proxyUrl;
|
||||
|
||||
TeleTok.LogMessage("Video for " + videourl + " processing..");
|
||||
|
||||
if(url.Contains("vm.tiktok.com"))
|
||||
{
|
||||
url = UnshortenUrl(url);
|
||||
}
|
||||
|
||||
proxyUrl = TeleTok.ptInstance + "/download?url=" + url;
|
||||
Console.WriteLine("Video for " + url + " has been sent..");
|
||||
proxyUrl = CreateDownloadLink(url);
|
||||
|
||||
TeleTok.LogMessage("Sending video link for " + proxyUrl);
|
||||
|
||||
return proxyUrl;
|
||||
}
|
||||
@ -33,5 +36,25 @@ namespace TeleTok
|
||||
|
||||
return realUrl;
|
||||
}
|
||||
|
||||
//Breaks apart the URL and extracts the User and Video ID to be processed into a working download link
|
||||
static string CreateDownloadLink(string videourl)
|
||||
{
|
||||
Uri segmentedUri = new Uri(videourl);
|
||||
segmentedUri = new Uri(segmentedUri.AbsoluteUri.Replace(segmentedUri.Query, string.Empty));
|
||||
|
||||
string videoUser = segmentedUri.Segments[1];
|
||||
videoUser = videoUser.Replace(@"/", "");
|
||||
string videoID = segmentedUri.Segments[3];
|
||||
|
||||
string fixedUrl = "https://www.tiktok.com/" + videoUser + "/video/" + videoID + @"&id=" + videoID + @"&user=" + videoUser.Remove(0);
|
||||
|
||||
string proxyLink = TeleTok.ptInstance + "/download?url=" + fixedUrl;
|
||||
|
||||
TeleTok.LogMessage("Input User ID is: " + videoUser);
|
||||
TeleTok.LogMessage("Input video ID is: " + videoID);
|
||||
|
||||
return proxyLink;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user