Guest User

Untitled

a guest
Aug 27th, 2020
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 61.24 KB | None | 0 0
  1. import telebot
  2. from time import sleep
  3. from telebot import types
  4. from selenium.webdriver.common.keys import Keys
  5. from selenium.webdriver.common.action_chains import ActionChains
  6. from oauth2client.service_account import ServiceAccountCredentials
  7. import os
  8. import gspread
  9. import re
  10. from selenium import webdriver
  11. import pprint
  12. import yadisk
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20. #fake: Не скажу
  21. #original: Не скажу
  22. TOKEN = 'Не скажу'
  23. bot = telebot.TeleBot(TOKEN)
  24.  
  25. scope = ['https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive']
  26. creds = ServiceAccountCredentials.from_json_keyfile_name('star.json', scope)
  27.  
  28. client = gspread.authorize(creds)
  29. sheet = client.open("Картины")
  30.  
  31. worksheet = sheet.worksheet('Песни')
  32. jek = 0
  33. namer_name = ''
  34. name_us = ''
  35. login_us = ''
  36. id_us = ''
  37. sms_us = ''
  38. mir = ''
  39. text_name = ''
  40. num_to = ''
  41. # !!!!!!!!!!!!!!!!!!!!!!!
  42. collection = None
  43. # !!!!!!!!!!!!!!!!!!!!!!!
  44. acord_name = ''
  45. ex_num = 0
  46. id_name = 0
  47. text_func = False
  48. acord_func = False
  49. trute = False
  50. otvet_user = False
  51. namer_func = False
  52. num = 1
  53. bu = False
  54. m = 0
  55. admin = False
  56. delit = False
  57.  
  58. l = 0
  59. num_reply = 0
  60.  
  61. @bot.message_handler(commands=['import'])
  62. def import_text(message):
  63. y = yadisk.YaDisk(token="AgAAAAAe11HFAAZriPtDsS0Ad0BmoPnm71G9B7Q")
  64. print(y.check_token())
  65. y.remove("/song.txt", permanently=True)
  66. y.upload("song.txt", "/song.txt")
  67. bot.send_message(message.chat.id , 'Импорт окончен, песни сохранены')
  68. @bot.message_handler(commands=['export'])
  69. def export(message):
  70. y = yadisk.YaDisk(token="AgAAAAAe11HFAAZriPtDsS0Ad0BmoPnm71G9B7Q")
  71. print(y.check_token())
  72. y.download("/song.txt", "song.txt")
  73. bot.send_message(message.chat.id, 'Экспорт окончен')
  74. def export_song():
  75. y = yadisk.YaDisk(token="AgAAAAAe11HFAAZriPtDsS0Ad0BmoPnm71G9B7Q")
  76. print(y.check_token())
  77. y.download("/song.txt", "song.txt")
  78. #старт бота
  79. @bot.message_handler(commands=['start'])
  80. def start(message):
  81.  
  82. markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
  83. markup.row("Добавить песню", "Изменить песню")
  84. if str(message.chat.id) != str('418914656'):
  85. markup.row("Написать администратору")
  86. if str(message.chat.id) == str('418914656'):
  87. markup.row("Написать всем")
  88. bot.send_message(message.chat.id, 'Приветствую!', reply_markup=markup)
  89. markup = types.InlineKeyboardMarkup(row_width=1)
  90. item = types.InlineKeyboardButton("Создать сборник", callback_data='new_songs')
  91. item2 = types.InlineKeyboardButton("Выбрать сборник", callback_data='choice_songs')
  92. markup.add(item, item2)
  93. bot.send_message(message.chat.id, """
  94. V1.3.3
  95. Инструкция пользования ботом!
  96.  
  97. Списки:
  98. - "Общий список" - появляется при написании "список" в нем расположены все песни в алфавитном порядке.
  99. - "Список по букве" - появляется при вводе любой буквы, песни в этом списке расположены в алфавитном порядке и начинаются на букву которую ввели.
  100.  
  101. Поиск песен:
  102. - Введи текст из песни соблюдая регистр и знаки препинания.
  103. - Введи номер песни из списка.
  104. - Выбери песню из списка нажав на ее номер.
  105.  
  106. Аккорды:
  107. Под каждой песней есть кнопка "Аккорды" при нажатии на нее вам высветиться текст данной песни с аккордами.
  108. /id - чтобы узнать свой id.
  109. Связь:
  110. - "Написать администратору" - Отправить сообщение администратору бота.
  111. Либо:
  112. @Nosachov_Ivan - Администратор,
  113. @MrMelsik - Модератор (разработчик), о всех ошибках сообщать ему.
  114. """.format(message.from_user, bot.get_me()),
  115. parse_mode='html', reply_markup=markup)
  116.  
  117. @bot.message_handler(commands=['id'])
  118. def myid(message):
  119. yourid = message.chat.id
  120. bot.send_message(message.chat.id, str(yourid))
  121. @bot.message_handler(commands=['find'])
  122. def find(message):
  123. global l, acord, trute, delit, num_to
  124.  
  125. l = None
  126. try:
  127. print(int(message.text))
  128. id_name = int(message.text)
  129. n = True
  130. except:
  131. name = message.text
  132. n = False
  133. print('name = ' + name)
  134. text = []
  135. some = []
  136. md = ''
  137. names = []
  138. handle = open("song.txt", "r")
  139. line = handle.readline()
  140. acord = []
  141. a = None
  142. sam = []
  143. b = None
  144. for line in handle:
  145. if "&" in line:
  146. names.append(line)
  147. elif "`" in line:
  148. a = True
  149. elif "~" in line:
  150. b = True
  151. if a == True:
  152. if "~" not in line:
  153. some.append(line)
  154. elif "~" in line:
  155. md = ''.join(map(str, some))
  156. text.append(md)
  157. del(some)
  158. some = []
  159. a = False
  160. if b == True:
  161. if "nnb" not in line:
  162. sam.append(line)
  163. elif "nnb" in line:
  164. md2 = ''.join(map(str, sam))
  165.  
  166. acord.append(md2)
  167. del(sam)
  168. sam = []
  169. b = False
  170. if n == False:
  171. if ',' in name:
  172. name = name.replace(',','')
  173. if '.' in name:
  174. name = name.replace('.','')
  175. if '!' in name:
  176. name = name.replace('!','')
  177. if '?' in name:
  178. name = name.replace('?','')
  179. if ';' in name:
  180. name = name.replace(';','')
  181. if ':' in name:
  182. name = name.replace(':','')
  183. for i in range(0,len(names)):
  184. if ',' in names[i]:
  185. names[i] = names[i].replace(',','')
  186. if '.' in names[i]:
  187. names[i] = names[i].replace('.','')
  188. if '!' in names[i]:
  189. names[i] = names[i].replace('!','')
  190. if '?' in names[i]:
  191. names[i] = names[i].replace('?','')
  192. if ';' in names[i]:
  193. names[i] = names[i].replace(';','')
  194. if ':' in names[i]:
  195. names[i] = names[i].replace(':','')
  196. if name.lower() in names[i].lower():
  197. names[i] = str.replace(names[i],"&", "" )
  198. bot.send_message(message.chat.id, names[i]+ '/' + str(int(i) + 1))
  199.  
  200. text[i] = str.replace(text[i],"`", "")
  201.  
  202. markup = types.InlineKeyboardMarkup(row_width=1)
  203. item = types.InlineKeyboardButton("Аккорды", callback_data='see')
  204. markup.add(item)
  205. bot.send_message(message.chat.id, text[i], reply_markup=markup)
  206.  
  207.  
  208. l = i
  209. break
  210.  
  211. if l != i:
  212. if ',' in name:
  213. name = name.replace(',','')
  214. if '.' in name:
  215. name = name.replace('.','')
  216. if '!' in name:
  217. name = name.replace('!','')
  218. if '?' in name:
  219. name = name.replace('?','')
  220. if ';' in name:
  221. name = name.replace(';','')
  222. if ':' in name:
  223. name = name.replace(':','')
  224. for i in range(0, len(text)):
  225. if ',' in text[i]:
  226. text[i] = text[i].replace(',','')
  227. if '.' in text[i]:
  228. text[i] = text[i].replace('.','')
  229. if '!' in text[i]:
  230. text[i] = text[i].replace('!','')
  231. if '?' in text[i]:
  232. text[i] = text[i].replace('?','')
  233. if ';' in text[i]:
  234. text[i] = text[i].replace(';','')
  235. if ':' in text[i]:
  236. text[i] = text[i].replace(':','')
  237. if name in text[i]:
  238. names[i] = str.replace(names[i],"&", "" )
  239. bot.send_message(message.chat.id, names[i]+ '/' + str(int(i) + 1))
  240.  
  241. text[i] = str.replace(text[i],"`", "")
  242.  
  243. markup = types.InlineKeyboardMarkup(row_width=1)
  244. item = types.InlineKeyboardButton("Аккорды", callback_data='see')
  245. markup.add(item)
  246. bot.send_message(message.chat.id, text[i], reply_markup=markup)
  247.  
  248.  
  249. l = i
  250. break
  251.  
  252.  
  253. else:
  254. try:
  255. names[id_name-1] = str.replace(names[id_name-1],"&", "")
  256. bot.send_message(message.chat.id, names[id_name-1] + '/' + str(id_name))
  257.  
  258. text[id_name-1] = str.replace(text[id_name-1],"`", "")
  259.  
  260. markup = types.InlineKeyboardMarkup(row_width=1)
  261. item = types.InlineKeyboardButton("Аккорды", callback_data='see')
  262. markup.add(item)
  263. bot.send_message(message.chat.id, text[id_name-1], reply_markup=markup)
  264. l = id_name-1
  265. except Exception as e:
  266. print(repr(e))
  267. bot.send_message(message.chat.id, 'Песни под таким номером не существует!')
  268. @bot.message_handler(commands=['add'])
  269. def add(message):
  270. global trute, song_acord, song_name, song_text
  271. bot.send_message(message.chat.id, 'Введите текст(с аккордами если имеются)')
  272. trute = True
  273. @bot.message_handler(commands=['sdf'])
  274. def num_two(message):
  275. write_song = True
  276. global trute, song_acord, song_name, song_text, admin, delit
  277. song_acord = message.text
  278. trute = False
  279. text = []
  280. some = []
  281. md = ''
  282. names = []
  283. handle = open("song.txt", "r")
  284. line = handle.readline()
  285. acord = []
  286. a = None
  287. sam = []
  288. b = None
  289. for line in handle:
  290. if "&" in line:
  291. names.append(line)
  292. elif "`" in line:
  293. a = True
  294. elif "~" in line:
  295. b = True
  296. if a == True:
  297. if "~" not in line:
  298. some.append(line)
  299. elif "~" in line:
  300. md = ''.join(map(str, some))
  301. text.append(md)
  302. del(some)
  303. some = []
  304. a = False
  305. if b == True:
  306. if "nnb" not in line:
  307. sam.append(line)
  308. elif "nnb" in line:
  309. md2 = ''.join(map(str, sam))
  310.  
  311. acord.append(md2)
  312. del(sam)
  313. sam = []
  314. b = False
  315. for i in range(0,len(names)):
  316. if '\n\n\n' in text[i]:
  317. text[i] = text[i].replace('\n\n\n', '\n\n')
  318. if '\n\n\n\n' in text[i]:
  319. text[i] = text[i].replace('\n\n\n\n', '\n\n')
  320. if '\n\n\n\n\n' in text[i]:
  321. text[i] = text[i].replace('\n\n\n\n\n', '\n\n')
  322. if '\n\n\n\n\n\n' in text[i]:
  323. text[i] = text[i].replace('\n\n\n\n\n\n', '\n\n')
  324. if '\n\n\n\n\n\n\n' in text[i]:
  325. text[i] = text[i].replace('\n\n\n\n\n\n\n', '\n\n')
  326. #C D E F G A H m # b 7
  327. d = ['C','c','D','d','E','e','F','f','G','g','A','a','H','h','M','m','#','B','b', '7']
  328. m = song_acord
  329. song_text = m
  330. print('1')
  331. print(song_text)
  332. lo = []
  333. new_song = []
  334. for line in song_text.split('\n'):
  335. if 'a' not in line.lower() and 'h' not in line.lower() and 'e' not in line.lower() and 'f' not in line.lower() and 'm' not in line.lower() and 'g' not in line.lower() and 'd' not in line.lower() and 'c' not in line.lower() and '#' not in line.lower() and 'b' not in line.lower() and '7' not in line.lower():
  336. new_song.append(line)
  337. song_text = '\n'.join(new_song)
  338. print(song_text)
  339. for line in song_text.split('\n'):
  340. lo.append(line)
  341. break
  342. song_name = '\n'.join(lo)
  343. for i in range(0,len(names)):
  344. print('&' +song_name + ' : ' + names[i])
  345. if song_name in names[i]:
  346. write_song = False
  347. bot.send_message(message.chat.id, 'Такая песня уже существует!')
  348. break
  349. if write_song == True:
  350. bot.send_message(message.chat.id, 'Песня под номером ' + str(len(names)+1))
  351. print(song_name)
  352. sleep(5)
  353. f = open("song.txt", "a")
  354. f.write('\n&'+song_name+'\n')
  355. f.write('`'+song_text+'\n')
  356. f.write('~'+song_acord+'\nnnb')
  357.  
  358. f.close()
  359. markup = types.InlineKeyboardMarkup(row_width=1)
  360. item = types.InlineKeyboardButton("Импорт", callback_data='imp')
  361. markup.add(item)
  362. bot.send_message(message.chat.id, 'Песня успешно добавлена', reply_markup=markup)
  363.  
  364. trute = False
  365. delit = False
  366. @bot.message_handler(commands=['00'])
  367. def administrator(message):
  368. global admin
  369. if admin == False:
  370. admin = True
  371. bot.send_message(message.chat.id, 'Отлично, теперь вы можете добавить/изменить песню!')
  372. elif admin == True:
  373. admin = False
  374. bot.send_message(message.chat.id, 'Вы успешно вышли')
  375.  
  376. @bot.message_handler(commands=['secret_cmd'])
  377. def change_acords(message):
  378. first_alv = False
  379. global num_to, mir
  380. a = num_to
  381. print(num_to)
  382. print(a)
  383.  
  384. d = ['C','c','D','d','E','e','F','f','G','g','A','a','H','h','M','m','#','B','b', '7']
  385. m = a
  386. nb = []
  387. tonals = []
  388. song = m
  389. new_song = []
  390. song = []
  391.  
  392. for line in m.split('\n'):
  393. try:
  394. if 'a' in line.lower():
  395. print('a')
  396. cr_m = line.index('A')
  397. cr_m = cr_m + 1
  398. try:
  399. if line[cr_m] != '#':
  400. line = line.replace('A', 'A$')
  401. else:
  402. print('#')
  403. line = line.replace('A#', 'A#$')
  404. except:
  405. line = line.replace('A', 'A$')
  406.  
  407. if 'c' in line.lower():
  408. print('c')
  409. cr_m = line.index('C')
  410. print('c')
  411. cr_m = cr_m + 1
  412. try:
  413. if line[cr_m] != '#':
  414. line = line.replace('C', 'C$')
  415. else:
  416. print('#')
  417. line = line.replace('C#', 'C#$')
  418. except:
  419. line = line.replace('C', 'C$')
  420. if 'd' in line.lower():
  421. print('d')
  422. cr_m = line.index('D')
  423. cr_m = cr_m + 1
  424. try:
  425. if line[cr_m] != '#':
  426. line = line.replace('D', 'D$')
  427. else:
  428. print('#')
  429. line = line.replace('D#', 'D#$')
  430. except:
  431. line = line.replace('D', 'D$')
  432. if 'g' in line.lower():
  433. print('g')
  434. cr_m = line.index('G')
  435. cr_m = cr_m + 1
  436. try:
  437. if line[cr_m] != '#':
  438. line = line.replace('G', 'G$')
  439. else:
  440. print('#')
  441. line = line.replace('G#', 'G#$')
  442. except:
  443. line = line.replace('G', 'G$')
  444. if 'h' in line.lower():
  445. print('h')
  446. cr_m = line.index('H')
  447. cr_m = cr_m + 1
  448. try:
  449. if line[cr_m] != '#':
  450. line = line.replace('H', 'H$')
  451. else:
  452. pass
  453. except:
  454. line = line.replace('H', 'H$')
  455. if 'f' in line.lower():
  456. print('f')
  457. cr_m = line.index('F')
  458. cr_m = cr_m + 1
  459. try:
  460. if line[cr_m] != '#':
  461. line = line.replace('F', 'F$')
  462. else:
  463. print('#')
  464. line = line.replace('F#', 'F#$')
  465. except:
  466. line = line.replace('F', 'F$')
  467. if 'e' in line.lower():
  468. print('e')
  469. cr_m = line.index('E')
  470. cr_m = cr_m + 1
  471. try:
  472. if line[cr_m] != '#':
  473. line = line.replace('E', 'E$')
  474. except:
  475. line = line.replace('E', 'E$')
  476. song.append(line)
  477. except:
  478. pass
  479. for line in song:
  480. if 'a' not in line.lower() and 'h' not in line.lower() and 'e' not in line.lower() and 'f' not in line.lower() and 'm' not in line.lower() and 'g' not in line.lower() and 'd' not in line.lower() and 'c' not in line.lower() and '#' not in line.lower() and 'b' not in line.lower() and '7' not in line.lower():
  481. new_song.append(line)
  482. else:
  483. x = 0
  484. while first_alv == False:
  485. first_bool = False
  486. if first_bool == False:
  487. line = " ".join(line.split())
  488. first_b = line[x]
  489.  
  490. if first_b.lower() == 'c':
  491. if line[x+1] == '#':
  492. first_b = 'C#'
  493. else:
  494. first_b = 'C'
  495. elif first_b.lower() == 'd':
  496. if line[x+1] == '#':
  497. first_b = 'D#'
  498. else:
  499. first_b = 'D'
  500. elif first_b.lower() == 'f':
  501. if line[x+1] == '#':
  502. first_b = 'F#'
  503. else:
  504. first_b = 'F'
  505. elif first_b.lower() == 'g':
  506. if line[x+1] == '#':
  507. first_b = 'G#'
  508. else:
  509. first_b = 'G'
  510. elif first_b.lower() == 'a':
  511. if line[x+1] == '#':
  512. first_b = 'A#'
  513. else:
  514. first_b = 'A'
  515. first_bool = True
  516. if first_bool == True:
  517. if first_b != 'A' and first_b != 'A#' and first_b != 'C' and first_b != 'C#' and first_b != 'G' and first_b != 'G#' and first_b != 'F#' and first_b != 'F' and first_b != 'D' and first_b != 'D#' and first_b != 'H' and first_b != 'E':
  518.  
  519. x = x + 1
  520. else:
  521. first_alv = True
  522. break
  523. break
  524.  
  525.  
  526. print('Тональность')
  527. print(first_b)
  528.  
  529. if first_b.lower() == 'c':
  530. num_b = 1
  531.  
  532. elif first_b.lower() == 'c#':
  533. num_b = 2
  534. elif first_b.lower() == 'd':
  535. num_b = 3
  536. elif first_b.lower() == 'd#':
  537. num_b = 4
  538. elif first_b.lower() == 'e':
  539. num_b = 5
  540. elif first_b.lower() == 'f':
  541. num_b = 6
  542. elif first_b.lower() == 'f#':
  543. num_b = 7
  544. elif first_b.lower() == 'g':
  545. num_b = 8
  546. elif first_b.lower() == 'g#':
  547. num_b = 9
  548. elif first_b.lower() == 'a':
  549. num_b = 10
  550. elif first_b.lower() == 'a#':
  551. num_b = 11
  552. elif first_b.lower() == 'h':
  553. num_b = 12
  554. print(num_b)
  555.  
  556. b = {
  557. 1: 'C',
  558. 2: 'C#',
  559. 3: 'D',
  560. 4: 'D#',
  561. 5: 'E',
  562. 6: 'F',
  563. 7: 'F#',
  564. 8: 'G',
  565. 9: 'G#',
  566. 10: 'A',
  567. 11: 'A#',
  568. 12: 'H'
  569. }
  570. #запасные переменные
  571. l = 0
  572. cd = 0
  573. cien = 1
  574. mi = False
  575. make = 0
  576. minus = False
  577.  
  578. sin = []
  579. songi = []
  580. for line in song:
  581. if 'Bb' in line:
  582. line = line.replace('Bb', 'A#')
  583. if 'B' in line:
  584. line = line.replace('B', 'A#')
  585. if '+' in line:
  586. line = line.replace('+','')
  587. if '-' in line:
  588. line = line.replace('-','')
  589. if '(' in line:
  590. line = line.replace('(','')
  591. if ')' in line:
  592. line = line.replace(')','')
  593. if '=' in line:
  594. line = line.replace('=','')
  595. if 'b' in line.lower():
  596. line = line.replace('b', '')
  597. if '¦' in line:
  598. line = line.replace('¦', '')
  599. if 'a' not in line.lower() and 'h' not in line.lower() and 'e' not in line.lower() and 'f' not in line.lower() and 'm' not in line.lower() and 'g' not in line.lower() and 'd' not in line.lower() and 'c' not in line.lower() and '#' not in line.lower() and 'b' not in line.lower() and '7' not in line.lower():
  600. songi.append(line)
  601. else:
  602. line = " ".join(line.split())
  603. if cien == 1:
  604. rgx = re.compile("(\w[\w']*\w|\w)")
  605. out=rgx.findall(line)
  606. if line[1] == '#':
  607. out[0] = out[0] + '#'
  608. if line[2] == 'm' or line[1] == 'm':
  609. mi = True
  610. print('mi = True')
  611. maker = out[0]
  612.  
  613. make = num_b
  614. if mir.lower() == 'c':
  615. l = 1
  616.  
  617. elif mir.lower() == 'c#':
  618. l = 2
  619. elif mir.lower() == 'd':
  620. l = 3
  621. elif mir.lower() == 'd#':
  622. l = 4
  623. elif mir.lower() == 'e':
  624. l = 5
  625. elif mir.lower() == 'f':
  626. l = 6
  627. elif mir.lower() == 'f#':
  628. l = 7
  629. elif mir.lower() == 'g':
  630. l = 8
  631. elif mir.lower() == 'g#':
  632. l = 9
  633. elif mir.lower() == 'a':
  634. l = 10
  635. elif mir.lower() == 'a#':
  636. l = 11
  637. elif mir.lower() == 'h':
  638. l = 12
  639. ins = make - l
  640. cd = ins
  641. ins = make - ins
  642. print('ins = ' + str(ins))
  643. print('make = ' + str(make))
  644. print('l = ' + str(l))
  645. print('maker = ' + str(maker))
  646. print('cd = '+ str(cd))
  647. if ins == 0:
  648. ins = 1
  649. if ins == -1:
  650. ins = 12
  651. if ins == -2:
  652. ins = 11
  653. if ins == -3:
  654. ins = 10
  655. if ins == -4:
  656. ins = 9
  657. if ins == -5:
  658. ins = 8
  659. if ins == -6:
  660. ins = 7
  661. if ins == -7:
  662. ins =6
  663. if ins == -8:
  664. ins = 5
  665. if ins == -9:
  666. ins = 4
  667. if ins == -10:
  668. ins = 3
  669. if ins == -11:
  670. ins = 2
  671. if ins == -12:
  672. ins = 1
  673.  
  674.  
  675.  
  676. if l > make:
  677. minus = True
  678. if l < make:
  679. minus = False
  680. cien = 2
  681. if 'd$' in line.lower():
  682. kit = False
  683. cr = line.index('D')
  684. cr = cr + 1
  685. kit = True
  686. if kit == True:
  687. d_maker = 'd'
  688. print(d_maker + ' DMAKER!!!!')
  689. for key in range(1, len(b)):
  690. if b[key].lower() == d_maker:
  691. make = key
  692. break
  693.  
  694. d_ins = make - cd
  695. if d_ins == 0:
  696. d_ins = 12
  697. if d_ins < 0:
  698. d_ins = d_ins + 12
  699. if d_ins == 13:
  700. d_ins = 1
  701. if d_ins > 13:
  702. d_ins = d_ins - 12
  703. line = line.replace('D$', b[d_ins])
  704. kit = False
  705.  
  706. if 'g$' in line.lower():
  707. kit = False
  708. cr = line.index('G')
  709. cr = cr + 1
  710. kit = True
  711. if kit == True:
  712. d_maker = 'g'
  713. print(d_maker + ' DMAKER!!!!')
  714. for key in range(1, len(b)):
  715. if b[key].lower() == d_maker:
  716. make = key
  717. break
  718.  
  719. d_ins = make - cd
  720. if d_ins == 0:
  721. d_ins = 12
  722. if d_ins < 0:
  723. d_ins = d_ins + 12
  724. if d_ins == 13:
  725. d_ins = 1
  726. if d_ins > 13:
  727. d_ins = d_ins - 12
  728. line = line.replace('G$', b[d_ins])
  729. kit = False
  730.  
  731. if 'c$' in line.lower():
  732. kit = False
  733. cr = line.index('C')
  734. cr = cr + 1
  735. kit = True
  736. if kit == True:
  737. d_maker = 'c'
  738. print(d_maker + ' DMAKER!!!!')
  739. for key in range(1, len(b)):
  740. if b[key].lower() == d_maker:
  741. make = key
  742. break
  743. print(make)
  744. d_ins = make - cd
  745. if d_ins == 0:
  746. d_ins = 12
  747. if d_ins < 0:
  748. d_ins = d_ins + 12
  749. if d_ins == 13:
  750. d_ins = 1
  751. if d_ins > 13:
  752. d_ins = d_ins - 12
  753. line = line.replace('C$', b[d_ins])
  754. kit = False
  755. print(line.lower())
  756.  
  757. if 'f$' in line.lower():
  758. kit = False
  759. cr = line.index('F')
  760. cr = cr + 1
  761. kit = True
  762. if kit == True:
  763. d_maker = 'f'
  764. print(d_maker + ' DMAKER!!!!')
  765. for key in range(1, len(b)):
  766. if b[key].lower() == d_maker:
  767. make = key
  768. break
  769.  
  770. d_ins = make - cd
  771. if d_ins == 0:
  772. d_ins = 12
  773. if d_ins < 0:
  774. d_ins = d_ins + 12
  775. if d_ins == 13:
  776. d_ins = 1
  777. if d_ins > 13:
  778. d_ins = d_ins - 12
  779. line = line.replace('F$', b[d_ins])
  780. kit = False
  781. if 'h$' in line.lower():
  782. kit = False
  783. cr = line.index('H')
  784. cr = cr + 1
  785.  
  786. kit = True
  787. if kit == True:
  788. d_maker = 'h'
  789. print(d_maker + ' DMAKER!!!!')
  790. for key in range(1, len(b)):
  791. if b[key].lower() == d_maker:
  792. make = key
  793. break
  794. make = 12
  795.  
  796. d_ins = make - cd
  797. print('d' + ' ' + str(d_ins))
  798. if d_ins == 0:
  799. d_ins = 12
  800. if d_ins < 0:
  801. d_ins = d_ins + 12
  802. if d_ins == 13:
  803. d_ins = 1
  804. if d_ins > 13:
  805. d_ins = d_ins - 12
  806. print('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
  807. print('d' + ' ' + str(d_ins))
  808. print('m ' + str(make))
  809. print('cd ' + str(cd))
  810. line = line.replace('H$', b[d_ins])
  811. kit = False
  812. if 'e$' in line.lower():
  813. kit = False
  814. cr = line.index('E')
  815. cr = cr + 1
  816. kit = True
  817. if kit == True:
  818. d_maker = 'e'
  819. print(d_maker + ' DMAKER!!!!')
  820. for key in range(1, len(b)):
  821. if b[key].lower() == d_maker:
  822. make = key
  823. break
  824.  
  825. d_ins = make - cd
  826. if d_ins == 0:
  827. d_ins = 12
  828. if d_ins < 0:
  829. d_ins = d_ins + 12
  830. if d_ins == 13:
  831. d_ins = 1
  832. if d_ins > 13:
  833. d_ins = d_ins - 12
  834. line = line.replace('E$', b[d_ins])
  835. kit = False
  836. if 'a$' in line.lower():
  837. kit = False
  838. cr = line.index('A')
  839. cr = cr + 1
  840. kit = True# # # # # # # # # # # # # # # # # # # ## # # # # # # # # #
  841. if kit == True:
  842. d_maker = 'a'
  843. print(d_maker + ' DMAKER!!!!')
  844. for key in range(1, len(b)):
  845. if b[key].lower() == d_maker:
  846. print(key)
  847. make = key
  848. break
  849.  
  850. d_ins = make - cd
  851. if d_ins == 0:
  852. d_ins = 12
  853. if d_ins < 0:
  854. d_ins = d_ins + 12
  855. if d_ins == 13:
  856. d_ins = 1
  857. if d_ins > 13:
  858. d_ins = d_ins - 12
  859. print('d' + ' ' + str(d_ins))
  860. print('m ' + str(make))
  861. print('cd ' + str(cd))
  862. line = line.replace('A$', b[d_ins])
  863. kit = False
  864.  
  865. if 'c#$' in line.lower():
  866. print('1')
  867. kit = False
  868. cr = line.index('C')
  869. cr = cr + 2
  870. kit = True
  871. if kit == True:
  872. d_maker = 'c#'
  873. print('1')
  874. for key in range(1, len(b)):
  875. if b[key].lower() == d_maker:
  876. make = key
  877. break
  878.  
  879. d_ins = make - cd
  880. print('make ' + str(make) + ' : ' + str(cd) + ' : ' + str(d_ins) )
  881. if d_ins == 0:
  882. d_ins = 12
  883. if d_ins < 0:
  884. d_ins = d_ins + 12
  885. if d_ins == 13:
  886. d_ins = 1
  887. if d_ins > 13:
  888. d_ins = d_ins - 12
  889. print(str(make) + 'nc')
  890. print(cd)
  891. print(d_ins)
  892. print(b[d_ins])
  893. line = line.replace('C#$', b[d_ins])
  894. kit = False
  895. if 'd#$' in line.lower():
  896. print('1')
  897. kit = False
  898. cr = line.index('D')
  899. cr = cr + 2
  900. kit = True
  901. if kit == True:
  902. d_maker = 'd#'
  903. print('1')
  904. for key in range(1, len(b)):
  905. if b[key].lower() == d_maker:
  906. make = key
  907. break
  908.  
  909. d_ins = make - cd
  910. print('make ' + str(make) + ' : ' + str(cd) + ' : ' + str(d_ins) )
  911. if d_ins == 0:
  912. d_ins = 12
  913. if d_ins < 0:
  914. d_ins = d_ins + 12
  915. if d_ins == 13:
  916. d_ins = 1
  917. if d_ins > 13:
  918. d_ins = d_ins - 12
  919. print('2')
  920. print(str(make) + 'nd')
  921. print(cd)
  922. print(d_ins)
  923. print(b[d_ins])
  924. line = line.replace('D#$', b[d_ins])
  925. kit = False
  926. if 'f#$' in line.lower():
  927. print('1')
  928. kit = False
  929. cr = line.index('F')
  930. cr = cr + 2
  931. kit = True
  932. if kit == True:
  933. d_maker = 'f#'
  934. print('1')
  935. for key in range(1, len(b)):
  936. if b[key].lower() == d_maker:
  937. make = key
  938. break
  939.  
  940. d_ins = make - cd
  941. print('make ' + str(make) + ' : ' + str(cd) + ' : ' + str(d_ins) )
  942. if d_ins == 0:
  943. d_ins = 12
  944. if d_ins < 0:
  945. d_ins = d_ins + 12
  946. if d_ins == 13:
  947. d_ins = 1
  948. if d_ins > 13:
  949. d_ins = d_ins - 12
  950. print('2')
  951. print(str(make) + 'nf')
  952. print(cd)
  953. print(d_ins)
  954. print(b[d_ins])
  955. line = line.replace('F#$', b[d_ins])
  956. kit = False
  957. if 'g#$' in line.lower():
  958. print('1')
  959. kit = False
  960. cr = line.index('G')
  961. cr = cr + 2
  962. kit = True
  963. if kit == True:
  964. d_maker = 'g#'
  965. print('1')
  966. for key in range(1, len(b)):
  967. if b[key].lower() == d_maker:
  968. make = key
  969. break
  970.  
  971. d_ins = make - cd
  972. print('make ' + str(make) + ' : ' + str(cd) + ' : ' + str(d_ins) )
  973. if d_ins == 0:
  974. d_ins = 12
  975. if d_ins < 0:
  976. d_ins = d_ins + 12
  977. if d_ins == 13:
  978. d_ins = 1
  979. if d_ins > 13:
  980. d_ins = d_ins - 12
  981. print('2')
  982. print(str(make) + 'nd')
  983. print(cd)
  984. print(d_ins)
  985. print(b[d_ins])
  986. line = line.replace('G#$', b[d_ins])
  987. kit = False
  988. if 'a#$' in line.lower():
  989. print('1')
  990. kit = False
  991. cr = line.index('A')
  992. cr = cr + 2
  993. kit = True
  994. if kit == True:
  995. d_maker = 'a#'
  996. print('1')
  997. for key in range(1, len(b)):
  998. if b[key].lower() == d_maker:
  999. make = key
  1000. break
  1001.  
  1002. d_ins = make - cd
  1003. print('make ' + str(make) + ' : ' + str(cd) + ' : ' + str(d_ins) )
  1004. if d_ins == 0:
  1005. d_ins = 12
  1006. if d_ins < 0:
  1007. d_ins = d_ins + 12
  1008. if d_ins == 13:
  1009. d_ins = 1
  1010. if d_ins > 13:
  1011. d_ins = d_ins - 12
  1012. print('2')
  1013. print(str(make) + 'nd')
  1014. print(cd)
  1015. print(d_ins)
  1016. print(b[d_ins])
  1017. line = line.replace('A#$', b[d_ins])
  1018. kit = False
  1019.  
  1020. sin.append(line)
  1021. num = []
  1022. for line in sin:
  1023. #line = line.replace('$','')
  1024. num.append(line)
  1025. #for i in range(0,10):
  1026. #print('')
  1027. for i in range(0,len(num)):
  1028. print(num[i])
  1029.  
  1030. #for i in range(0, len(songi)):
  1031. #print(songi[i])
  1032. #for i in range(0, len(sin)):
  1033. #print(sin[i])
  1034. #print('\n\n\n\n\n\n\n\n\n')
  1035. ac = -1
  1036. end_song = []
  1037. for line in song:
  1038. if 'a' not in line.lower() and 'h' not in line.lower() and 'e' not in line.lower() and 'f' not in line.lower() and 'm' not in line.lower() and 'g' not in line.lower() and 'd' not in line.lower() and 'c' not in line.lower() and '#' not in line.lower() and 'b' not in line.lower() and '7' not in line.lower():
  1039. pass
  1040. else:
  1041. ac = ac + 1
  1042. line = line.replace(line, num[ac])
  1043. end_song.append(line)
  1044. end_s = '\n'.join(end_song)
  1045. bot.send_message(message.chat.id, end_s)
  1046.  
  1047.  
  1048. @bot.message_handler(commands=['all_song'])
  1049. def all_song(message):
  1050. global trute, delit
  1051. try:
  1052. text = []
  1053. some = []
  1054. md = ''
  1055. names = []
  1056. mi = []
  1057. handle = open("song.txt", "r")
  1058. line = handle.readline()
  1059. acord = []
  1060. d = 1
  1061. a = None
  1062. slov = {}
  1063. sam = []
  1064. b = None
  1065. for line in handle:
  1066. if "&" in line:
  1067. names.append(line)
  1068. slov[names[0]]=str(d)
  1069. d += 1
  1070. del(names)
  1071. names = []
  1072. elif "`" in line:
  1073. a = True
  1074. elif "~" in line:
  1075. b = True
  1076. if a == True:
  1077. if "~" not in line:
  1078. some.append(line)
  1079. elif "~" in line:
  1080. md = ''.join(map(str, some))
  1081. text.append(md)
  1082. del(some)
  1083. some = []
  1084. a = False
  1085. if b == True:
  1086. if "nnb" not in line:
  1087. sam.append(line)
  1088. elif "nnb" in line:
  1089. md2 = ''.join(map(str, sam))
  1090.  
  1091. acord.append(md2)
  1092. del(sam)
  1093. sam = []
  1094. b = False
  1095.  
  1096. all_text = []
  1097. name = 'а'
  1098. for i in range(0,len(names)):
  1099. if name.lower() in names[i][1].lower():
  1100. names[i] = str.replace(names[i],"&", "" )
  1101. all_text.append(names[i]+'/'+str(int(i)+1))
  1102. n = '\n'.join(map(str, all_text))
  1103. list_keys = list(slov.keys())
  1104. list_keys.sort()
  1105. ck = 0
  1106. for i in list_keys:
  1107. lm = str.replace(i,"&", "" )
  1108. k = str.replace(lm, "\n", "")
  1109. if ck < 10:
  1110. print('lm ' + str(lm))
  1111. print('k ' + str(k))
  1112. mi.append(str(k)+' | '+'/'+ str(slov[i]) + '\n')
  1113. ck = ck + 1
  1114. mi_app = []
  1115. ls = None
  1116. for i in range(0, len(mi)):
  1117. if i < 10:
  1118. print(mi[i])
  1119. mi_app.append(mi[i])
  1120. if len(mi_app) == 40:
  1121. ls = '\n'.join(map(str,mi_app))
  1122. bot.send_message(message.chat.id, ls)
  1123. del(ls)
  1124. del(mi_app)
  1125. mi_app = []
  1126. elif i == len(mi)-1:
  1127. ls = '\n'.join(map(str,mi_app))
  1128. bot.send_message(message.chat.id, ls)
  1129. del(ls)
  1130. del(mi_app)
  1131. mi_app = []
  1132. trute = False
  1133. delit = False
  1134. except Exception as e:
  1135. print(repr(e))
  1136. trute = False
  1137. delit = False
  1138.  
  1139. @bot.message_handler(commands=['find_bu'])
  1140. def find_bu(message):
  1141. try:
  1142. global bu, acord, trute, delit
  1143. name = message.text
  1144. text = []
  1145. some = []
  1146. md = ''
  1147. names = []
  1148. handle = open("song.txt", "r")
  1149. line = handle.readline()
  1150. acord = []
  1151. a = None
  1152. sam = []
  1153. b = None
  1154. for line in handle:
  1155. if "&" in line:
  1156. names.append(line)
  1157. elif "`" in line:
  1158. a = True
  1159. elif "~" in line:
  1160. b = True
  1161. if a == True:
  1162. if "~" not in line:
  1163. some.append(line)
  1164. elif "~" in line:
  1165. md = ''.join(map(str, some))
  1166. text.append(md)
  1167. del(some)
  1168. some = []
  1169. a = False
  1170. if b == True:
  1171. if "nnb" not in line:
  1172. sam.append(line)
  1173. elif "nnb" in line:
  1174. md2 = ''.join(map(str, sam))
  1175.  
  1176. acord.append(md2)
  1177. del(sam)
  1178. sam = []
  1179. b = False
  1180. all_text = []
  1181. for i in range(0,len(names)):
  1182. if name.lower() in names[i][1].lower():
  1183. names[i] = str.replace(names[i],"&", "" )
  1184. all_text.append(names[i]+'/'+str(int(i)+1))
  1185. n = '\n'.join(map(str, all_text))
  1186. bot.send_message(message.chat.id, n)
  1187. bu = False
  1188. trute = False
  1189. delit = False
  1190. except:
  1191. bot.send_message(message.chat.id, 'Песен на такую букву не существует!')
  1192. bu = False
  1193. @bot.message_handler(commands=['find_song2'])
  1194. def find_text2(message):
  1195. global num_to
  1196. try:
  1197. global l, acord, trute, delit
  1198. id_name = message.text
  1199. id_name = str.replace(id_name, "/", "")
  1200. text = []
  1201. some = []
  1202. md = ''
  1203. names = []
  1204. handle = open("song.txt", "r")
  1205. line = handle.readline()
  1206. acord = []
  1207. a = None
  1208. sam = []
  1209. b = None
  1210. for line in handle:
  1211. if "&" in line:
  1212. names.append(line)
  1213. elif "`" in line:
  1214. a = True
  1215. elif "~" in line:
  1216. b = True
  1217. if a == True:
  1218. if "~" not in line:
  1219. some.append(line)
  1220. elif "~" in line:
  1221. md = ''.join(map(str, some))
  1222. text.append(md)
  1223. del(some)
  1224. some = []
  1225. a = False
  1226. if b == True:
  1227. if "nnb" not in line:
  1228. sam.append(line)
  1229. elif "nnb" in line:
  1230. md2 = ''.join(map(str, sam))
  1231.  
  1232. acord.append(md2)
  1233. del(sam)
  1234. sam = []
  1235. b = False
  1236. names[int(id_name)-1] = str.replace(names[int(id_name)-1],"&", "")
  1237. bot.send_message(message.chat.id, names[int(id_name)-1] + '/' + str(id_name))
  1238.  
  1239. text[int(id_name)-1] = str.replace(text[int(id_name)-1],"`", "")
  1240.  
  1241. markup = types.InlineKeyboardMarkup(row_width=1)
  1242. item = types.InlineKeyboardButton("Аккорды", callback_data='see')
  1243. markup.add(item)
  1244. bot.send_message(message.chat.id, text[int(id_name)-1], reply_markup=markup)
  1245. l = int(id_name)-1
  1246. except:
  1247. bot.send_message(message.chat.id, 'Такого номера не существует!')
  1248. trute = False
  1249. delit = False
  1250.  
  1251. @bot.message_handler(commands=['delete'])
  1252. def delete(message):
  1253. try:
  1254. global delit, id_name, nom, acord, trute, text_func, acord_func, namer_func
  1255. text = []
  1256. some = []
  1257. nom = 0
  1258. md = ''
  1259. names = []
  1260. biglen = False
  1261. if int(id_name) > 1:
  1262. biglen = True
  1263. handle = open("song.txt", "r")
  1264. line = handle.readline()
  1265. acord = []
  1266. a = None
  1267. sam = []
  1268. b = None
  1269. print('all')
  1270.  
  1271. for line in handle:
  1272. if "&" in line:
  1273. if namer_func == True:
  1274. if nom == int(id_name)-1:
  1275. if biglen == False:
  1276. line = line.replace(line, '&'+namer_name+'\n')
  1277. elif biglen == True:
  1278. line = line.replace(line, 'nnb' + '\n&'+namer_name+'\n')
  1279. names.append(line)
  1280. print(nom)
  1281. nom += 1
  1282. j = nom
  1283. ac = nom
  1284. elif namer_func == False:
  1285. if biglen == True:
  1286. if nom == int(id_name)-1:
  1287. line = line.replace(line, 'nnb' + '\n' + line)
  1288.  
  1289. names.append(line)
  1290. print(nom)
  1291. nom += 1
  1292. j = nom
  1293. ac = nom
  1294.  
  1295. elif "`" in line:
  1296. a = True
  1297. elif "~" in line:
  1298. b = True
  1299. if a == True:
  1300.  
  1301. if "~" not in line:
  1302. if text_func == True:
  1303. if int(nom) == int(id_name):
  1304. if j == int(id_name):
  1305. line = line.replace(line, '`'+text_name+'\n')
  1306. j= 0
  1307. else:
  1308. line = line.replace(line, '')
  1309.  
  1310. some.append(line)
  1311. elif text_func == False:
  1312. some.append(line)
  1313. elif "~" in line:
  1314. md = ''.join(map(str, some))
  1315. text.append(md)
  1316. del(some)
  1317. some = []
  1318. a = False
  1319. if b == True:
  1320. if "nnb" not in line:
  1321. if acord_func == True:
  1322. if int(nom) == int(id_name):
  1323. if ac == int(id_name):
  1324. line = line.replace(line, '~'+acord_name +'\n')
  1325. ac= 0
  1326. else:
  1327. line = line.replace(line, '')
  1328.  
  1329. sam.append(line)
  1330. elif acord_func == False:
  1331. sam.append(line)
  1332.  
  1333. elif "nnb" in line:
  1334. md2 = ''.join(map(str, sam))
  1335. if nom != int(id_name)-1:
  1336. acord.append(md2+'nnb')
  1337. elif nom == int(id_name)-1:
  1338. acord.append(md2)
  1339. del(sam)
  1340. sam = []
  1341. b = False
  1342. for i in range(0, len(names)):
  1343. print('\n'+names[i]+text[i]+acord[i])
  1344. handle.close()
  1345. for i in range(0,len(names)):
  1346. if '\n\n\n' in text[i]:
  1347. text[i] = text[i].replace('\n\n\n', '\n\n')
  1348. if '\n\n\n\n' in text[i]:
  1349. text[i] = text[i].replace('\n\n\n\n', '\n\n')
  1350. if '\n\n\n\n\n' in text[i]:
  1351. text[i] = text[i].replace('\n\n\n\n\n', '\n\n')
  1352. if '\n\n\n\n\n\n' in text[i]:
  1353. text[i] = text[i].replace('\n\n\n\n\n\n', '\n\n')
  1354. if '\n\n\n\n\n\n\n' in text[i]:
  1355. text[i] = text[i].replace('\n\n\n\n\n\n\n', '\n\n')
  1356. print(names)
  1357. handle2 = open('song.txt', 'w')
  1358. for i in range(0,len(names)):
  1359. handle2.write('\n'+names[i]+text[i]+acord[i])
  1360. text[i] = text[i].replace('`', '')
  1361. acord[i] = acord[i].replace('~', '')
  1362. names[i] = names[i].replace('&', '')
  1363. if 'nnb' in acord[i]:
  1364. acord[i] = acord[i].replace('nnb', '')
  1365. if 'nnb' in names[i]:
  1366. names[i] = names[i].replace('nnb', '')
  1367. if ' ' in names[i][0]:
  1368. names[i] = names[i].replace(' ', '')
  1369. if ' ' in acord[i][0]:
  1370. acord[i] = acord[i].replace(' ', '')
  1371. if ' ' in text[i][0]:
  1372. text[i] = text[i].replace(' ', '')
  1373.  
  1374. bot.send_message(message.chat.id, 'Изменение успешно!')
  1375. trute = False
  1376. delit = False
  1377. except Exception as e:
  1378. print(repr(e))
  1379. bot.send_message(message.chat.id, 'Такого номера не существует!')
  1380. trute = False
  1381. delit = False
  1382. text_func = False
  1383. acord_func = False
  1384. index = 1
  1385. namer_func = False
  1386. change(message)
  1387. @bot.message_handler(commands=['change'])
  1388. def change(message):
  1389. markup = types.InlineKeyboardMarkup(row_width=1)
  1390. item = types.InlineKeyboardButton("Название", callback_data='replace_1')
  1391. item2 = types.InlineKeyboardButton("Текст", callback_data='replace_2')
  1392. item3 = types.InlineKeyboardButton("Аккорды", callback_data='replace_3')
  1393. item4 = types.InlineKeyboardButton("Готово", callback_data='done')
  1394. markup.add(item, item2, item3,item4)
  1395. bot.send_message(message.chat.id, 'Что вы хотите изменить?', reply_markup=markup)
  1396. @bot.message_handler(content_types=['text'])
  1397. def text(message):
  1398. global num, song_name, otvet_user, song_text, acord, song_acord, trute, admin, bu, name2, delit
  1399. if namer_func == True:
  1400. global namer_name
  1401. namer_name = message.text
  1402. delete(message)
  1403. elif text_func == True:
  1404. global text_name
  1405. text_name = message.text
  1406. delete(message)
  1407. elif acord_func == True:
  1408. global acord_name
  1409. acord_name = message.text
  1410. delete(message)
  1411.  
  1412. elif bu == True:
  1413. print('one')
  1414. find_bu(message)
  1415. elif message.text == 'Добавить песню':
  1416. print('two')
  1417. if admin == True:
  1418. add(message)
  1419. elif admin == False:
  1420. bot.send_message(message.chat.id, 'Введите номер доступа')
  1421. trute = False
  1422. elif message.text == 'Написать всем':
  1423. bot.send_message(message.chat.id , 'Вы написали всем')
  1424. elif message.text == 'Написать администратору':
  1425. bot.send_message(message.chat.id, 'Напишите сообщение')
  1426. bot.register_next_step_handler(message, admin_sms)
  1427. elif message.text == 'Изменить песню':
  1428. print('three')
  1429. if admin == True:
  1430. bot.send_message(message.chat.id, 'Введите номер песни')
  1431. delit = True
  1432. trute = False
  1433. elif admin == False:
  1434. bot.send_message(message.chat.id, 'Введите номер доступа!')
  1435. trute = False
  1436. elif message.text[0] == '/':
  1437. print('four')
  1438. find_text2(message)
  1439.  
  1440. elif message.text.lower() == 'список':
  1441. print('fife')
  1442. all_song(message)
  1443. elif len(message.text) == 1 and delit == False:
  1444. if delit == False and trute == False:
  1445. print('six')
  1446.  
  1447. try:
  1448. print(int(message.text))
  1449. find(message)
  1450. except:
  1451. bu = True
  1452. find_bu(message)
  1453.  
  1454. else:
  1455.  
  1456. if trute == False:
  1457. print('yes!1')
  1458. if otvet_user == True:
  1459. print(str(id_us) + ' jk')
  1460. bot.send_message(id_us,'*Ответ от администратора*\n' + message.text, parse_mode="Markdown")
  1461. bot.send_message(message.chat.id, 'Сообщение успешно отправлено')
  1462. otvet_user = False
  1463. elif delit == False:
  1464. print('yes!')
  1465. find(message)
  1466. elif delit == True:
  1467. global id_name
  1468. id_name = message.text
  1469. change(message)
  1470.  
  1471.  
  1472. elif trute == True:
  1473. print('2')
  1474. song_acord = message.text
  1475. num_two(message)
  1476. def admin_sms(message):
  1477. #418914656 -
  1478. global name_us, login_us, sms_us, id_us
  1479. try:
  1480. name_us = message.from_user.first_name
  1481. login_us = message.from_user.username
  1482. sms_us = message.text
  1483. id_us = message.chat.id
  1484. except:
  1485. id_us = message.chat.id
  1486. name_us = message.from_user.first_name
  1487. sms_us = message.text
  1488.  
  1489. markup = types.InlineKeyboardMarkup(row_width=2)
  1490. item = types.InlineKeyboardButton("Да", callback_data='yesof')
  1491. item2 = types.InlineKeyboardButton("Нет", callback_data='noof')
  1492. markup.add(item,item2)
  1493. bot.send_message(message.chat.id, 'Вы уверены?', reply_markup=markup)
  1494.  
  1495. def namer(message):
  1496.  
  1497. bot.send_message(message.chat.id, 'Введите текст песни')
  1498. bot.register_next_step_handler(message, texti)
  1499. def texti(message):
  1500. global text_name
  1501. text_name = message.text
  1502. bot.send_message(message.chat.id, 'Веддите текст с аккордами')
  1503. bot.register_next_step_handler(message, acordi)
  1504. def acordi(message):
  1505. global acord_name
  1506. acord_name = message.text
  1507. delete(message)
  1508. def text2(message):
  1509. global trute, song_acord, song_name, song_text
  1510. song_text = message.text
  1511. bot.send_message(message.chat.id, 'Теперь текст с аккордами')
  1512. bot.register_next_step_handler(message, text3)
  1513. def text3(message):
  1514. global trute, song_acord, song_name, song_text, admin, delit
  1515. song_acord = message.text
  1516. bot.send_message(message.chat.id, 'Успешно!')
  1517. trute = False
  1518. text = []
  1519. some = []
  1520. md = ''
  1521. names = []
  1522. handle = open("song.txt", "r")
  1523. line = handle.readline()
  1524. acord = []
  1525. a = None
  1526. sam = []
  1527. b = None
  1528. for line in handle:
  1529. if "&" in line:
  1530. names.append(line)
  1531. elif "`" in line:
  1532. a = True
  1533. elif "~" in line:
  1534. b = True
  1535. if a == True:
  1536. if "~" not in line:
  1537. some.append(line)
  1538. elif "~" in line:
  1539. md = ''.join(map(str, some))
  1540. text.append(md)
  1541. del(some)
  1542. some = []
  1543. a = False
  1544. if b == True:
  1545. if "nnb" not in line:
  1546. sam.append(line)
  1547. elif "nnb" in line:
  1548. md2 = ''.join(map(str, sam))
  1549.  
  1550. acord.append(md2)
  1551. del(sam)
  1552. sam = []
  1553. b = False
  1554. for i in range(0,len(names)):
  1555. if '\n\n\n' in text[i]:
  1556. text[i] = text[i].replace('\n\n\n', '\n\n')
  1557. if '\n\n\n\n' in text[i]:
  1558. text[i] = text[i].replace('\n\n\n\n', '\n\n')
  1559. if '\n\n\n\n\n' in text[i]:
  1560. text[i] = text[i].replace('\n\n\n\n\n', '\n\n')
  1561. if '\n\n\n\n\n\n' in text[i]:
  1562. text[i] = text[i].replace('\n\n\n\n\n\n', '\n\n')
  1563. if '\n\n\n\n\n\n\n' in text[i]:
  1564. text[i] = text[i].replace('\n\n\n\n\n\n\n', '\n\n')
  1565. bot.send_message(message.chat.id, 'Песня под номером ' + str(len(names)+1))
  1566. f = open("song.txt", "a")
  1567. f.write('\n&'+song_name+'\n')
  1568. f.write('`'+song_text+'\n')
  1569. f.write('~'+song_acord+'\nnnb')
  1570.  
  1571. f.close()
  1572. trute = False
  1573. delit = False
  1574. bot.send_message(message.chat.id, 'Ожидайте...')
  1575. sheets(message)
  1576.  
  1577. @bot.callback_query_handler(func=lambda call: True)
  1578. def callback_inline(call):
  1579. global trute, delit, namer_func, text_func, acord_func, mir, num_to, login_us, otvet_user
  1580. try:
  1581. if call.message:
  1582. if call.data == 'see':
  1583. acord[l] = str.replace(acord[l],"~", "")
  1584. num_to = acord[l]
  1585. markup = types.InlineKeyboardMarkup(row_width=6)
  1586. item = types.InlineKeyboardButton("C", callback_data='c')
  1587. item2 = types.InlineKeyboardButton("C#", callback_data='c2')
  1588. item3 = types.InlineKeyboardButton("D", callback_data='d')
  1589. item4 = types.InlineKeyboardButton("D#", callback_data='d2')
  1590. item5 = types.InlineKeyboardButton("E", callback_data='e')
  1591. item6 = types.InlineKeyboardButton("F", callback_data='f')
  1592. item7 = types.InlineKeyboardButton("F#", callback_data='f2')
  1593. item8 = types.InlineKeyboardButton("G", callback_data='g')
  1594. item9 = types.InlineKeyboardButton("G#", callback_data='g2')
  1595. item10 = types.InlineKeyboardButton("A", callback_data='a')
  1596. item11 = types.InlineKeyboardButton("A#", callback_data='a2')
  1597. item12 = types.InlineKeyboardButton("H", callback_data='h')
  1598.  
  1599. markup.add(item, item2, item3, item4, item5, item6, item7, item8, item9, item10, item11, item12)
  1600. bot.send_message(call.message.chat.id, acord[l], reply_markup=markup)
  1601. elif call.data == 'c':
  1602. mir = 'c'
  1603. change_acords(call.message)
  1604. elif call.data == 'c2':
  1605. mir = 'c#'
  1606. change_acords(call.message)
  1607. elif call.data == 'd':
  1608. mir = 'd'
  1609. change_acords(call.message)
  1610. elif call.data == 'd2':
  1611. mir = 'd#'
  1612. change_acords(call.message)
  1613. elif call.data == 'e':
  1614. mir = 'e'
  1615. change_acords(call.message)
  1616. elif call.data == 'f':
  1617. mir = 'f'
  1618. change_acords(call.message)
  1619. elif call.data == 'f2':
  1620. mir = 'f#'
  1621. change_acords(call.message)
  1622. elif call.data == 'g':
  1623. mir = 'g'
  1624. change_acords(call.message)
  1625. elif call.data == 'g2':
  1626. mir = 'g#'
  1627. change_acords(call.message)
  1628. elif call.data == 'a':
  1629. mir = 'a'
  1630. change_acords(call.message)
  1631. elif call.data == 'a2':
  1632. mir = 'a#'
  1633. change_acords(call.message)
  1634. elif call.data == 'h':
  1635. mir = 'h'
  1636. change_acords(call.message)
  1637. elif call.data == 'imp':
  1638. import_text(call.message)
  1639. elif call.data == 'replace_1':
  1640. bot.send_message(call.message.chat.id, 'Введите название')
  1641. namer_func = True
  1642. elif call.data == 'replace_2':
  1643. bot.send_message(call.message.chat.id, 'Введите текст')
  1644. text_func = True
  1645. elif call.data == 'replace_3':
  1646. bot.send_message(call.message.chat.id, 'Введите текст с аккордами')
  1647. acord_func = True
  1648. elif call.data == 'done':
  1649. bot.send_message(call.message.chat.id, 'Изменения успешно применены')
  1650. namer_func = False
  1651. text_func = False
  1652. acord_func = False
  1653. elif call.data == 'otvet':
  1654. bot.send_message(call.message.chat.id, 'Введите сообщение')
  1655. otvet_user = True
  1656. elif call.data == 'yesof':
  1657. #418914656 - admin
  1658. #846352856 - moder
  1659. try:
  1660. if login_us == '':
  1661. if minesd == 123123:
  1662. print(1+'s')
  1663. markup = types.InlineKeyboardMarkup(row_width=1)
  1664. item = types.InlineKeyboardButton("Ответить", callback_data='otvet')
  1665. markup.add(item)
  1666. bot.send_message(418914656, '*'+ name_us +' @'+login_us + '*\n' + sms_us, parse_mode="Markdown", reply_markup=markup)
  1667. except:
  1668. markup = types.InlineKeyboardMarkup(row_width=1)
  1669. item = types.InlineKeyboardButton("Ответить", callback_data='otvet')
  1670. markup.add(item)
  1671. login_us = ''
  1672. print(id_us)
  1673. bot.send_message(418914656, '*'+ name_us +'* `Логин не найден` '+ '\n' + sms_us, parse_mode="Markdown", reply_markup=markup)
  1674. bot.send_message(call.message.chat.id, 'Сообщение успешно отправилось!')
  1675. elif call.data == 'new_songs':
  1676. bot.send_message(call.message.chat.id,'пофиг')
  1677. elif call.data == 'choice_songs':
  1678. bot.send_message(call.message.chat.id, 'дада')
  1679. elif call.data == 'noof':
  1680. bot.send_message(call.message.chat.id, 'Сообщение не отправлено')
  1681. except Exception as e:
  1682. print(repr(e))
  1683. trute = False
  1684. delit = False
  1685. if num_reply == 0:
  1686. export_song()
  1687. num_reply = 1
  1688. bot.polling()
  1689.  
  1690.  
Add Comment
Please, Sign In to add comment