-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTransBot_Bata3.py
96 lines (87 loc) · 4.2 KB
/
TransBot_Bata3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#-*- coding:utf-8 -*-
# 번역기봇 제작:권오준 http://www.kwon5jun.com
import discord
import asyncio
import os
import urllib.request
from googletrans import Translator
client = discord.Client()
@client.event
async def on_ready():
print("="*20)
print(client.user.name)
print('너굴번역기 버전3 작동!!!')
print("="*20)
@client.event
async def on_message(message):
await client.change_presence(game=discord.Game(name='!!help 번역기봇 베타3버전입니다.@ 오류문의는 꼬기빙수#5197 ')) # ~~~ playing
if message.author != client.user: # 봇이 봇에게 명령하지 못합니다.
if message.content.startswith('!!help'): # !commands
print("도움말을 요청")
await client.send_message(message.channel, """
모든 명령어 앞에는 항상 !!를 붙입니다. Bata V3
!!en2ko [...] English -> Korean
!!ko2en [...] Korean -> English
!![...]2[...] [...] LANGUAGES -> LANGUAGES
ex) !!en2ko Hi
LANGUAGES List: !!language """) # bot's answer
elif message.content.startswith('!!language'):
print("언어안내 출력")
await client.send_message(message.channel, """
LANGUAGES List:
'ko': 'korean'---- 'en':'english'---- 'ja':'japanese'
'fy': 'frisian'--- 'uk': 'ukrainian'- 'ps': 'pashto'
'hr': 'croatian'-- 'ar': 'arabic'---- 'so': 'somali'
'vi': 'vietnamese' 'tr': 'turkish'--- 'ne': 'nepali'
'bs': 'bosnian'--- 'es': 'spanish'--- 'mg': 'malagasy'
'id': 'indonesian' 'ig': 'igbo'------ 'sk': 'slovak'
'mi': 'maori'----- 'ro': 'romanian'-- 'iw': 'hebrew'
'zu': 'zulu'------ 'st': 'sesotho'--- 'he': 'Hebrew'
'si': 'sinhala'--- 'lv': 'latvian'--- 'fy': 'frisian'
'km': 'khmer'----- 'no': 'norwegian'- 'su': 'sundanese'
'sw': 'swahili'--- 'fr': 'french'---- 'ta': 'tamil'
'fi': 'finnish'--- 'tl': 'filipino'-- 'hi': 'hindi'
'ny': 'chichewa'-- 'gu': 'gujarati'-- 'ru': 'russian'
'pa': 'punjabi'--- 'sl': 'slovenian'- 'ha': 'hausa'
'co': 'corsican'-- 'la': 'latin'----- 'sv': 'swedish'
'it': 'italian'--- 'sr': 'serbian'--- 'uz': 'uzbek'
'nl': 'dutch'----- 'ur': 'urdu'------ 'ht': 'haitian'
'de': 'german'---- 'sq': 'albanian'-- 'te': 'telugu'
'is': 'icelandic'- 'gl': 'galician'-- 'ml': 'malayalam'
'pl': 'polish'---- 'lo': 'lao'------- 'ms': 'malay'
'cs': 'czech'----- 'th': 'thai'------ 'be': 'belarusian'
'mn': 'mongolian'- 'bg': 'bulgarian'- 'sm': 'samoan'
'eu': 'basque'---- 'ka': 'georgian'-- 'hy': 'armenian'
'yo': 'yoruba'---- 'kn': 'kannada'--- 'lt': 'lithuanian'
'eo': 'esperanto'- 'et': 'estonian'-- 'kk': 'kazakh'
'tg': 'tajik'----- 'mk': 'macedonian' 'jw': 'javanese'
'mt': 'maltese'--- 'da': 'danish'---- 'fa': 'persian'
'sn': 'shona'----- 'bn': 'bengali'--- 'am': 'amharic'
'pt': 'portuguese' 'hu': 'hungarian'- 'mr': 'marathi'
'lb': 'luxembourg' 'ky': 'kyrgyz'---- 'hmn': 'hmong'
'cy': 'welsh'----- 'az': 'Azerbaijan' 'yi': 'yiddish'
'ga': 'irish'----- 'sd': 'sindhi'---- 'af': 'afrikaans'
'el': 'greek'----- 'ca': 'catalan'--- 'xh': 'xhosa' """)
#--언어>언어
elif message.content.startswith('!!'):
m = message.content
if(len(m)>8):
try:
translator = Translator()
txtname = message.author.display_name
sourcetxt = m[2:4]
targettxt = m[5:7]
await client.send_message(message.channel,sourcetxt+"""->"""+targettxt+"""번역하였습니다. (translated it.)
["""+ txtname +"""] """+translator.translate(m[7:], src=sourcetxt, dest=targettxt).text)
print(txtname+"님이 "+sourcetxt+"->"+targettxt+"로 번역하였습니다.")
except:
print("번역오류")
await client.send_message(message.channel,"""번역오류! (translation error!)""")
elif(len(m)==2):
print("번역할 언어를 입력하세요")
await client.send_message(message.channel,"""번역할 언어를 입력하세요. (Please enter a language to translate.)""")
else:
print("번역할 문자를 입력하세요")
await client.send_message(message.channel,"""번역할 문자를 입력하세요. (Please enter what you want to translate.)""")
access_token = os.environ["BOT_TOKEN"]
client.run('access_token') #디스코드 사이트 > 개발자 포털 > 내 봇 > Bot token