-
Notifications
You must be signed in to change notification settings - Fork 1
/
bot_funtions.py
93 lines (62 loc) · 2.01 KB
/
bot_funtions.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
import telegram
from config import TOKEN, URL
from flames import flames
from expand import expand
from translate import translate_to_english, translate_to_tamil
from dicts import meaning
from help import helper
import num2word as digit
bot = telegram.Bot(token=TOKEN)
def send_message_to_user(msg, chat_id):
try:
bot.send_message(chat_id=chat_id, text=msg, parse_mode=telegram.ParseMode.HTML)
except:
bot.send_message(
chat_id=chat_id, text="Sorry try again", parse_mode=telegram.ParseMode.HTML
)
def send_message_to_devolper(msg):
bot.send_message(chat_id=1071607407, text=msg, parse_mode=telegram.ParseMode.HTML)
def send_flames_of_message(p1, p2, chat_id):
send_message_to_user(flames(p1, p2), chat_id)
def send_expand_of_message(word, chat_id):
send_message_to_user(expand(word), chat_id)
def send_message_of_translation(lang, msg, chat_id):
if lang == "en":
if len(msg.split()) == 1:
send_message_to_user(meaning(msg), chat_id)
else:
send_message_to_user(translate_to_tamil(msg), chat_id)
else:
send_message_to_user(translate_to_english(msg), chat_id)
def format_user_name(first, last):
try:
return first + last
except:
return first
def welcome_user(first, chat_id):
msg = f"""
Hi! {first}
My name is Excel
"""
send_message_to_user(msg, chat_id)
def help_user(first, chat_id):
send_message_to_user(helper(first), chat_id)
def word_of_number(msg, chat_id):
send_message_to_user(digit.word(msg), chat_id)
def failed_message():
send_message_to_devolper("Bot is Failed")
def isNumber(s):
for i in range(len(s)):
if not s[i].isdigit():
return False
return True
def about_developer(chat_id):
msg = """
Name: YOGESHWARAN R
Lang: Python 3.8
GitHub: https://github.com/yogeshwaran01
"""
send_message_to_user("Developer", chat_id)
send_message_to_user(msg, chat_id)
def option_of(msg):
return msg[0]