Compare commits

13 Commits

Author SHA1 Message Date
2261e753d5 Implemented timestamp logging
All checks were successful
continuous-integration/drone/push Build is passing
2023-02-15 12:20:23 -05:00
88dd3b5908 Added better link processing and logging 2023-02-15 12:20:07 -05:00
f8f94b4afc Added better link processing 2023-02-15 12:19:40 -05:00
309d7c0cd3 Added better log messaging 2023-02-15 12:17:08 -05:00
f37beb0a5d Removed try/catch it broke
All checks were successful
continuous-integration/drone/push Build is passing
2023-02-15 10:05:30 -05:00
eec1050e17 Added datetime for logging 2023-02-15 10:05:14 -05:00
8ffd920007 Updated CMD command
All checks were successful
continuous-integration/drone/push Build is passing
2023-02-14 15:29:55 -05:00
846b7d10d8 Fixed tag to be lowercase
All checks were successful
continuous-integration/drone/push Build is passing
2023-02-14 15:17:53 -05:00
5adc9b7b9f Fixed image tag
Some checks failed
continuous-integration/drone/push Build is failing
2023-02-14 15:13:30 -05:00
3eb412bd6e Fixed missing step
Some checks failed
continuous-integration/drone/push Build is failing
2023-02-14 15:09:57 -05:00
1949c7af1b Merge branch 'main' of git.kizaing.ca:kizaing/TeleTok
Some checks reported errors
continuous-integration/drone/push Build encountered an error
continuous-integration/drone Build encountered an error
2023-02-14 15:07:27 -05:00
993a94ddb1 Updated build task 2023-02-14 15:06:39 -05:00
26dcd962b8 Merge pull request 'bugfixes/crash-handler' (#1) from bugfixes/crash-handler into main
Some checks failed
continuous-integration/drone/push Build is failing
Reviewed-on: #1
2023-02-14 11:53:45 -08:00
5 changed files with 51 additions and 28 deletions

View File

@ -4,11 +4,6 @@ type: docker
name: publish-bot name: publish-bot
steps: steps:
- name: build-dotnet
image: mcr.microsoft.com/dotnet/sdk:6.0
commands:
- dotnet publish
- name: build-image - name: build-image
image: plugins/docker image: plugins/docker
settings: settings:
@ -17,10 +12,8 @@ steps:
from_secret: DOCKER_USER from_secret: DOCKER_USER
password: password:
from_secret: DOCKER_PASS from_secret: DOCKER_PASS
repo: git.kizaing.ca/kizaing/TeleTok repo: git.kizaing.ca/kizaing/teletok
tags: latest tags: latest
platform: linux/amd64,linux/arm64
# Commented out until stuff actually works # Commented out until stuff actually works
trigger: trigger:

View File

@ -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 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" ]

View File

@ -22,5 +22,12 @@ namespace TeleTok
listener.RunListener(); listener.RunListener();
} }
public static void LogMessage(string text)
{
DateTime now =DateTime.Now;
Console.WriteLine("[" + now.ToString() + "] " + text);
}
} }
} }

View File

@ -54,8 +54,6 @@ namespace TeleTok
// Passes the url along to the video downloader if it is valid AND a tiktok link // Passes the url along to the video downloader if it is valid AND a tiktok link
if (isUri) if (isUri)
{
try
{ {
if(messageText.Contains("tiktok.com")) if(messageText.Contains("tiktok.com"))
{ {
@ -68,11 +66,6 @@ namespace TeleTok
); );
} }
} }
catch
{
Console.WriteLine("Valid TikTok URI was sent, but was not a video!");
}
}
} }
Task HandlePollingErrorAsync(ITelegramBotClient botClient, Exception exception, CancellationToken cancellationToken) Task HandlePollingErrorAsync(ITelegramBotClient botClient, Exception exception, CancellationToken cancellationToken)
@ -84,7 +77,7 @@ namespace TeleTok
_ => exception.ToString() _ => exception.ToString()
}; };
Console.WriteLine(ErrorMessage); TeleTok.LogMessage(ErrorMessage);
return Task.CompletedTask; return Task.CompletedTask;
} }
} }

View File

@ -12,13 +12,16 @@ namespace TeleTok
string url = videourl; string url = videourl;
string proxyUrl; string proxyUrl;
TeleTok.LogMessage("Video for " + videourl + " processing..");
if(url.Contains("vm.tiktok.com")) if(url.Contains("vm.tiktok.com"))
{ {
url = UnshortenUrl(url); url = UnshortenUrl(url);
} }
proxyUrl = TeleTok.ptInstance + "/download?url=" + url; proxyUrl = CreateDownloadLink(url);
Console.WriteLine("Video for " + url + " has been sent..");
TeleTok.LogMessage("");
return proxyUrl; return proxyUrl;
} }
@ -33,5 +36,25 @@ namespace TeleTok
return realUrl; 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;
}
} }
} }