14 Commits

Author SHA1 Message Date
8461afd08f Fixed runner repo links
Some checks failed
Push Docker image to registries
2023-03-20 20:14:41 -04:00
30d4c41eee Added repo auth
Some checks failed
Push Docker image to registries
2023-03-20 20:11:22 -04:00
fadc678ac3 Fixed pipeline trigger
Some checks failed
Push Docker image to registries
2023-03-20 20:01:52 -04:00
9b06a629f0 Added gitea runner 2023-03-20 19:58:20 -04:00
bb96bcde61 Fixed bug deleting entire user variable
All checks were successful
continuous-integration/drone/push Build is passing
2023-02-15 16:33:57 -05:00
15416e3728 Fixed log date 2023-02-15 16:33:45 -05:00
feccbc05e6 Updated readme
All checks were successful
continuous-integration/drone/push Build is passing
2023-02-15 14:12:00 -05:00
7d16552d65 Updated .gitignore 2023-02-15 13:55:16 -05:00
268bbdf9b7 Added json field checks 2023-02-15 13:53:47 -05:00
8ab6b9d986 Added log message
All checks were successful
continuous-integration/drone/push Build is passing
2023-02-15 12:25:05 -05:00
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
6 changed files with 115 additions and 13 deletions

View File

@ -0,0 +1,36 @@
# .gitea/workflows/build.yaml
name: Publish Docker image
on:
push:
branches: [main]
jobs:
push_to_registry:
name: Push Docker image to registries
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
with:
token: ${{ secrets.GITEA_TOKEN }}
- name: Login to DockerHub
uses: https://github.com/docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Login to Gitea registry
uses: https://github.com/docker/login-action@v2
with:
registry: git.kizaing.ca
username: ${{ gitea.actor }}
password: ${{ secrets.GITEA_TOKEN }}
- name: Build and push Docker image
uses: https://github.com/docker/build-push-action@v4
with:
context: .
push: true
tags: git.kizaing.ca/kizaing/teletok:latest, kizaing

4
.gitignore vendored
View File

@ -1,2 +1,4 @@
bin bin
obj obj
.vscode
config.Dev.json

View File

@ -15,12 +15,29 @@ namespace TeleTok
static async Task Main(string[] args) static async Task Main(string[] args)
{ {
//Checks if the config json data is valid
TelegramListener listener = new TelegramListener(); if(token == "" || token == null || token == "INSERT TOKEN HERE")
Console.WriteLine("Now listening..."); {
LogMessage("Telegram bot token is invalid! Exiting...");
}
else if(ptInstance == "" || ptInstance == null || ptInstance == "PROXITOK INSTANCE URL")
{
LogMessage("Proxitok instance is invalid! Exiting...");
}
else
{
TelegramListener listener = new TelegramListener();
LogMessage("Now listening...");
listener.RunListener(); listener.RunListener();
}
}
public static void LogMessage(string text)
{
DateTime now =DateTime.Now;
Console.WriteLine("[" + now.ToString() + "] " + text);
} }
} }
} }

View File

@ -1,5 +1,31 @@
[![Build Status](https://ci.kizaing.ca/api/badges/kizaing/TeleTok/status.svg)](https://ci.kizaing.ca/kizaing/TeleTok)
# TeleTok Telegram Bot # TeleTok Telegram Bot
This bot will monitor any chats for TikTok links that are posted, and then will run the link through a [ProxiTok](https://github.com/pablouser1/ProxiTok) instance to generate a download link. The resulting video file will then get directly uploaded directly to your chat.
This bot is in early development, but the end goal is to have this bot automatically convert all tiktok links in a chat into a videofile that can be re-uploaded to the telegram chat ## Building
Requirements: Dotnet SDK 6.0
Run `dotnet build` for a Debug instance
Run `dotnet publish` for a full release
## Installation
### Requirements
* A telegram bot token
* A working [ProxiTok](https://github.com/pablouser1/ProxiTok) instance, either public or hosted yourself. (Please be kind and take bandwidth into account when using a public instance)
### Binary
1. Either build the application or download a release zip for your OS/architecture
2. Edit the config.json and put your telegram bot token in the "token" field, and your chosen ProxiTok instance in the "ptInstance" field
3. Run the TeleTok.exe/TeleTok executable
### Docker
1. You can build an image for yourself with `docker build teletok .` or you can pull a prebuilt image with `docker pull kizaing/teletok:latest`
2. Copy the placeholder config.json from the repo to a location of your choosing
3. Edit the config.json and put your telegram bot token in the "token" field, and your chosen ProxiTok instance in the "ptInstance" field
4. Run the container with `docker run -v ${PWD}/config.json:/app/teletok/config.json -d kizaing/teletok:latest`
## To Do
- [x] Add better error and link handling
- [x] Process videos into telegram
- [ ] Add [Matrix](https://matrix.org) support
- [ ] Automate binary release publishing

View File

@ -77,7 +77,7 @@ namespace TeleTok
_ => exception.ToString() _ => exception.ToString()
}; };
Console.WriteLine(ErrorMessage); TeleTok.LogMessage(ErrorMessage);
return Task.CompletedTask; return Task.CompletedTask;
} }
} }

View File

@ -12,15 +12,16 @@ namespace TeleTok
string url = videourl; string url = videourl;
string proxyUrl; string proxyUrl;
DateTime now =DateTime.Now; 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("[" + now.ToString() + "] " + "Video for " + url + " has been sent..");
TeleTok.LogMessage("Sending video link for " + proxyUrl);
return proxyUrl; return proxyUrl;
} }
@ -35,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, 1);
string proxyLink = TeleTok.ptInstance + "/download?url=" + fixedUrl;
TeleTok.LogMessage("Input User ID is: " + videoUser);
TeleTok.LogMessage("Input video ID is: " + videoID);
return proxyLink;
}
} }
} }