29 lines
761 B
Python
29 lines
761 B
Python
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)
|