Add translate.py
This commit is contained in:
parent
798a54f429
commit
8224c58da1
1 changed files with 29 additions and 0 deletions
29
translate.py
Normal file
29
translate.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
import os
|
||||
|
||||
from googletrans import Translator
|
||||
from twitch_chat_irc import twitch_chat_irc
|
||||
from dotenv import load_dotenv
|
||||
|
||||
channel_to_read_chat_from = ""
|
||||
channel_to_send_translations_to = ""
|
||||
|
||||
load_dotenv()
|
||||
|
||||
username = os.getenv('TWITCH_LOGIN_NAME')
|
||||
oauth = os.getenv('TWITCH_OAUTH_TOKEN')
|
||||
|
||||
connection = twitch_chat_irc.TwitchChatIRC()
|
||||
connection = twitch_chat_irc.TwitchChatIRC(username, oauth)
|
||||
|
||||
translator = Translator()
|
||||
|
||||
def do_something(message):
|
||||
|
||||
msg = message["message"]
|
||||
translated_text = translator.translate(msg)
|
||||
print(translated_text)
|
||||
|
||||
translated = translated_text.text
|
||||
connection.send(channel_to_read_chat_from, f"{message['display-name']}: {translated}")
|
||||
|
||||
connection.listen(channel_to_send_translations_to, on_message=do_something)
|
Loading…
Reference in a new issue