Git Product home page Git Product logo

tgtranslator's Introduction

πŸ“™ TgTranslator

TgTranslator is a telegram bot that translates messages in groups. Try it for yourself: @TgTranslatorBot

Use it in your project support group, to study language with a tutor, and in many other ways!

alt text

3️⃣ Translation modes

This bot has 3 translation modes:

  1. Auto. This mode automatically translates all messages that do not match the language of the main group. In addition, the message should be less than the character limit (specified in appsettins.json -> TgTranslator -> CharLimit), should not be a command (for example: /help or .help for Userbots), and the group should not be in timeout.

  2. Forwards. Works like Auto, but translates only forwarded messages.

  3. Manual. Translates only after replying on message with !translate or bot username.

πŸ“™ Languages

By default, bot has 105 languages supported by Google Translate.

alt text

βš™οΈ Bot settings

In many group bots you can call menu in group chat. This one works different: the /settings command works only in private messages. It returns the main menu with Inline buttons which are the list of available settings.

alt text

When you select an option, it offers you to choose chat where you send ready command, like @TgTranslatorBot set:mode=auto.

alt text

This may seem a bit complicated, but it creates a lot more flexibility for larger groups. Users won't be interrupted by large message with buttons, and also, you can create prepared configurations for multiple groups.

Menu is higly customizable, so it's not hard to add new options, or even implement it in your own project.

▢️ Setup

You need to have Docker and PostgreSQL.

  1. Clone repository and open directory:
    git clone https://github.com/Dubzer/TgTranslator.git && cd TgTranslator
  2. Configure the appsettings.json (it's pretty self-explanatory)
  3. Create a new class and implement ITranslator and ILanguageDetector interfaces. After that, open DiServices.cs and replace TranslatePlaceholderService with your new class.
  4. Build the project.
    docker build -t tgtranslator.
  5. Start an app container.
     docker run tgtranslator

πŸ“ License

The project is licensed under the MIT license.

tgtranslator's People

Contributors

dubzer avatar lionzxy avatar pro100jekon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

tgtranslator's Issues

Build error on CentOS 7.x

First of all, you need to update the documentation (readme.md file) and change the required .NET version from 3.0 to 3.1

Second, I'm receiving the error below while trying to compile the project:

Extensions/ServiceCollectionExtensions.cs(54,52): error CS0246: The type or namespace name 'TranslatorMicroservice' could not be found (are you missing a using directive or an assembly reference?) [/home/web/public_html/_tools/bot/src/TgTranslator.csproj]
Exceptions/InvalidSettingValueException.cs(5,18): warning RCS1194: Implement exception constructors. [/home/web/public_html/_tools/bot/src/TgTranslator.csproj]
Exceptions/UnauthorizedSettingChangingException.cs(5,18): warning RCS1194: Implement exception constructors. [/home/web/public_html/_tools/bot/src/TgTranslator.csproj]
Exceptions/UnsupportedCommand.cs(5,18): warning RCS1194: Implement exception constructors. [/home/web/public_html/_tools/bot/src/TgTranslator.csproj]
Exceptions/UnsupportedMenuItem.cs(5,18): warning RCS1194: Implement exception constructors. [/home/web/public_html/_tools/bot/src/TgTranslator.csproj]

Readme makse no sense

TranslatorToken is not even an entry in the config file that the readme points to.
The build fails with

dotnet publish -c Release
Microsoft (R) Build Engine version 16.11.0+0538acc04 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  All projects are up-to-date for restore.
F:\Syncs\Repos\TgTranslator\src\Extensions\IpWhitelist.cs(26,22): warning CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. [F:\Syncs\Repos\TgTranslator\src\TgTranslator.csproj]
F:\Syncs\Repos\TgTranslator\src\Extensions\ServiceCollectionExtensions.cs(34,54): error CS0246: The type or namespace name 'YandexLanguageDetector' could not be found (are you missing a using directive or an assembly reference?) [F:\Syncs\Repos\TgTranslator\src\TgTranslator.csproj]
F:\Syncs\Repos\TgTranslator\src\Extensions\ServiceCollectionExtensions.cs(35,48): error CS0246: The type or namespace name 'YandexTranslator' could not be found (are you missing a using directive or an assembly reference?) [F:\Syncs\Repos\TgTranslator\src\TgTranslator.csproj]
F:\Syncs\Repos\TgTranslator\src\Data\TgTranslatorContext.cs(54,17): warning CS0618: 'RelationalIndexBuilderExtensions.HasName<TEntity>(IndexBuilder<TEntity>, string)' is obsolete: 'Use HasDatabaseName() instead.' [F:\Syncs\Repos\TgTranslator\src\TgTranslator.csproj]

Bilingual translation

I have a group with Spanish and English members, and would like all messages to appear in both languages. Can I run two instances of this bot, or can the bot have another mode to translate both ways please?

Build Errors

I'm still receiving build errors on VS:

image

25/02/2020 20:29:43
System.AggregateException: One or more errors occurred. ---> System.Exception: Build failed. Check the Output window for more details.
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at Microsoft.WebTools.Publish.PublishService.VsWebProjectPublish.<>c__DisplayClass43_0.<PublishAsync>b__3()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Publish.Framework.ViewModel.ProfileSelectorViewModel.<RunPublishTaskAsync>d__213.MoveNext()
---> (Inner Exception #0) System.Exception: Build failed. Check the Output window for more details.<---

System.Exception: Build failed. Check the Output window for more details.

===================

Also on Linux machine:

Exceptions/InvalidSettingValueException.cs(5,18): warning RCS1194: Implement exception constructors. [/root/TgTranslator/src/TgTranslator.csproj]
Exceptions/UnauthorizedSettingChangingException.cs(5,18): warning RCS1194: Implement exception constructors. [/root/TgTranslator/src/TgTranslator.csproj]
Exceptions/UnsupportedCommand.cs(5,18): warning RCS1194: Implement exception constructors. [/root/TgTranslator/src/TgTranslator.csproj]
Exceptions/UnsupportedMenuItem.cs(5,18): warning RCS1194: Implement exception constructors. [/root/TgTranslator/src/TgTranslator.csproj]

Build problem

I'm trying to build this on a Linux machine (Ubuntu 18.04), but I'm receiving the error below:

root@sam:/var/www/TelegramGroupTranslatorBot# dotnet publish -c Release
Microsoft (R) Build Engine version 16.3.2+e481bbf88 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

Restore completed in 1.85 sec for /var/www/TelegramGroupTranslatorBot/src/TgTranslator.csproj.
Extensions/IServiceCollectionExtensions.cs(81,28): error CS7036: There is no argument given that corresponds to the required formal parameter 'validator' of 'MessageHandler.MessageHandler(TelegramBotClient, BotMenu, SettingsProcessor, ILanguageDetector, ITranslator, IMetrics, Blacklist, MessageValidator)' [/var/www/TelegramGroupTranslatorBot/src/TgTranslator.csproj]
SettingsProcessor.cs(59,80): warning CS8509: The switch expression does not handle all possible inputs (it is not exhaustive). [/var/www/TelegramGroupTranslatorBot/src/TgTranslator.csproj]

No translations if removed from group

I tested some translators and needed to silence it, so i kicked it from my group. After i added the bot again, he does nothing anymore :(

// He currently translates 1/10 messages in this chat. In another chat he works as expected. What could be the cause or the fix? This Chat has 20 members and not much messages to parse.

No translation between Two similar language

I have a telegram group that has people spoken in two languages, there is no need translating from one to another. Will you please add some features to support this scenario? For instance, Simplified Chinese and Traditional Chinese, there is no need translating from Traditional Chinese to Simplified Chinese, coz all people can read those two languages.

Inquiry about ChatGPT integration with TgTranslator

Thank you for developing TgTranslator. I find it extremely helpful in translating messages in groups. Recently, I came across ChatGPT (OpenAI GPT-3.5/4 API), which offers advanced language translation capabilities.

I would like to inquire whether there is a plan to integrate ChatGPT into TgTranslator for translation purposes. It would be great if the bot could offer translation services based on this technology.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.