-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
157 lines (129 loc) · 6.37 KB
/
main.py
File metadata and controls
157 lines (129 loc) · 6.37 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
import telebot
import sympy
import random
from telebot import types
bot = telebot.TeleBot('token')
# @bot.message_handler(commands=['start'])
# def welcome(message):
# sti = open('static/welcome.webp', 'rb')
# bot.send_sticker(message.chat.id, sti)
#
# # keyboard
# markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
# item1 = types.KeyboardButton("🎲 Рандомное число")
# item2 = types.KeyboardButton("😊 Как дела?")
#
# markup.add(item1, item2)
#
# bot.send_message(message.chat.id,
# "Добро пожаловать, {0.first_name}!\nЯ - <b>{1.first_name}</b>, бот созданный чтобы быть подопытным кроликом.".format(
# message.from_user, bot.get_me()),
# parse_mode='html', reply_markup=markup)
@bot.message_handler(content_types=['text'])
def lalala(message):
try:
if message.chat.type == 'private':
if message.text == '/start':
bot.send_message(message.chat.id, 'ХАЙ')
return
x, y = sympy.symbols('x y')
usertext = message.text.split('\n')
xi = usertext[0].split('=')
eta = usertext[1].split('=')
enterux = usertext[2].split('=')
enteruy = usertext[3].split('=')
enteruxx = usertext[4].split('=')
enteruyy = usertext[5].split('=')
enteruxy = usertext[6].split('=')
xix = sympy.diff(xi[1], x)
xixx = sympy.diff(xix, x)
xiy = sympy.diff(xi[1], y)
xiyy = sympy.diff(xiy, y)
etax = sympy.diff(eta[1], x)
etaxx = sympy.diff(etax, x)
etay = sympy.diff(eta[1], y)
etayy = sympy.diff(etay, y)
etaxy = sympy.diff(etay, x)
xixy = sympy.diff(xiy, x)
xixy, xix, xiy, xiyy = str(xixy), str(xix), str(xiy), str(xiyy)
etax, etaxx, etay, etayy = str(etax), str(etaxx), str(etay), str(etayy)
etaxy, xixy = str(etaxy), str(xixy)
dicfun = {'*log(e)': ''}
for key in dicfun.keys():
xixy = xixy.replace(key, dicfun[key])
xix = xix.replace(key, dicfun[key])
xiy = xiy.replace(key, dicfun[key])
xiyy = xiyy.replace(key, dicfun[key])
etax = etax.replace(key, dicfun[key])
etaxx = etaxx.replace(key, dicfun[key])
etay = etay.replace(key, dicfun[key])
etayy = etayy.replace(key, dicfun[key])
etaxy = etaxy.replace(key, dicfun[key])
xixy = xixy.replace(key, dicfun[key])
bot.send_message(message.chat.id, f'ξx={xix}\nξy={xiy}\n')
bot.send_message(message.chat.id, f'ηx={etax}\nηy={etay}\n')
bot.send_message(message.chat.id, f'ξxx={xixx}\nξyy={xiyy}\n')
bot.send_message(message.chat.id, f'ηxx={etaxx}\nηyy={etayy}\n')
bot.send_message(message.chat.id, f'ξxy={xixy}\nηxy={etaxy}\n')
dicvar = {'a': 'Uξ', 'b': 'Uη', 'g': 'Uξη', 'd': 'Uξξ', 'f': 'Uηη'}
ux = sympy.simplify(f'a*{xix} + b*{etax}')
uy = sympy.simplify(f'a*{xiy} + b*{etay}')
uxx = sympy.simplify(
f'd*{xix}*{xix} + 2*g*{xix}*{etax} + f*{etax}*{etax} + a*{xixx} + b*{etaxx}')
uxy = sympy.simplify(
f'd*{xix}*{xiy} + g*({xix}*{etay} + {xiy}*{etax}) + f*{etax}*{etay} + a*{xixy} + b*{etaxy}')
uyy = sympy.simplify(
f'd*{xiy}*{xiy} + 2*g*{xiy}*{etay} + f*{etay}*{etay} + a*{xiyy} + b*{etayy}')
ux = str(ux)
uy = str(uy)
uyy = str(uyy)
uxx = str(uxx)
uxy = str(uxy)
equat = sympy.simplify(
f'{enterux[1]}*({ux}) + {enteruy[1]}*({uy}) + {enteruxx[1]}*({uxx}) + {enteruyy[1]}*({uyy}) + {enteruxy[1]}*({uxy})')
equat = str(equat)
for key in dicvar.keys():
ux = ux.replace(key, dicvar[key])
uy = uy.replace(key, dicvar[key])
uxx = uxx.replace(key, dicvar[key])
uxy = uxy.replace(key, dicvar[key])
uyy = uyy.replace(key, dicvar[key])
equat = equat.replace(key, dicvar[key])
bot.send_message(message.chat.id, f'Ux={ux}\nUy={uy}\nUxx={uxx}\nUyy={uyy}\nUxy={uxy}\n')
bot.send_message(message.chat.id, f'Подстановка: {equat}')
# if message.text == '🎲 Рандомное число':
# bot.send_message(message.chat.id, str(random.randint(0, 100)))
# elif message.text == '😊 Как дела?':
#
# markup = types.InlineKeyboardMarkup(row_width=2)
# item1 = types.InlineKeyboardButton("Хорошо", callback_data='good')
# item2 = types.InlineKeyboardButton("Не очень", callback_data='bad')
#
# markup.add(item1, item2)
#
# bot.send_message(message.chat.id, 'Отлично, сам как?', reply_markup=markup)
# else:
# bot.send_message(message.chat.id, 'Я не знаю что ответить 😢')
except Exception as e:
bot.send_message(message.chat.id, 'непон')
# @bot.callback_query_handler(func=lambda call: True)
# def callback_inline(call):
# try:
# if call.message:
# if call.data == 'good':
# bot.send_message(call.message.chat.id, 'Вот и отличненько 😊')
# elif call.data == 'bad':
# bot.send_message(call.message.chat.id, 'Бывает 😢')
#
# # remove inline buttons
# bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="😊 Как дела?",
# reply_markup=None)
#
# # show alert
# bot.answer_callback_query(callback_query_id=call.id, show_alert=False,
# text="ЭТО ТЕСТОВОЕ УВЕДОМЛЕНИЕ!!11")
#
# except Exception as e:
# print(repr(e))
# RUN
bot.polling(none_stop=True)