Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import telebot
- from time import sleep
- from telebot import types
- from selenium.webdriver.common.keys import Keys
- from selenium.webdriver.common.action_chains import ActionChains
- from oauth2client.service_account import ServiceAccountCredentials
- import os
- import gspread
- import re
- from selenium import webdriver
- import pprint
- import yadisk
- #fake: Не скажу
- #original: Не скажу
- TOKEN = 'Не скажу'
- bot = telebot.TeleBot(TOKEN)
- scope = ['https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive']
- creds = ServiceAccountCredentials.from_json_keyfile_name('star.json', scope)
- client = gspread.authorize(creds)
- sheet = client.open("Картины")
- worksheet = sheet.worksheet('Песни')
- jek = 0
- namer_name = ''
- name_us = ''
- login_us = ''
- id_us = ''
- sms_us = ''
- mir = ''
- text_name = ''
- num_to = ''
- # !!!!!!!!!!!!!!!!!!!!!!!
- collection = None
- # !!!!!!!!!!!!!!!!!!!!!!!
- acord_name = ''
- ex_num = 0
- id_name = 0
- text_func = False
- acord_func = False
- trute = False
- otvet_user = False
- namer_func = False
- num = 1
- bu = False
- m = 0
- admin = False
- delit = False
- l = 0
- num_reply = 0
- @bot.message_handler(commands=['import'])
- def import_text(message):
- y = yadisk.YaDisk(token="AgAAAAAe11HFAAZriPtDsS0Ad0BmoPnm71G9B7Q")
- print(y.check_token())
- y.remove("/song.txt", permanently=True)
- y.upload("song.txt", "/song.txt")
- bot.send_message(message.chat.id , 'Импорт окончен, песни сохранены')
- @bot.message_handler(commands=['export'])
- def export(message):
- y = yadisk.YaDisk(token="AgAAAAAe11HFAAZriPtDsS0Ad0BmoPnm71G9B7Q")
- print(y.check_token())
- y.download("/song.txt", "song.txt")
- bot.send_message(message.chat.id, 'Экспорт окончен')
- def export_song():
- y = yadisk.YaDisk(token="AgAAAAAe11HFAAZriPtDsS0Ad0BmoPnm71G9B7Q")
- print(y.check_token())
- y.download("/song.txt", "song.txt")
- #старт бота
- @bot.message_handler(commands=['start'])
- def start(message):
- markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
- markup.row("Добавить песню", "Изменить песню")
- if str(message.chat.id) != str('418914656'):
- markup.row("Написать администратору")
- if str(message.chat.id) == str('418914656'):
- markup.row("Написать всем")
- bot.send_message(message.chat.id, 'Приветствую!', reply_markup=markup)
- markup = types.InlineKeyboardMarkup(row_width=1)
- item = types.InlineKeyboardButton("Создать сборник", callback_data='new_songs')
- item2 = types.InlineKeyboardButton("Выбрать сборник", callback_data='choice_songs')
- markup.add(item, item2)
- bot.send_message(message.chat.id, """
- V1.3.3
- Инструкция пользования ботом!
- Списки:
- - "Общий список" - появляется при написании "список" в нем расположены все песни в алфавитном порядке.
- - "Список по букве" - появляется при вводе любой буквы, песни в этом списке расположены в алфавитном порядке и начинаются на букву которую ввели.
- Поиск песен:
- - Введи текст из песни соблюдая регистр и знаки препинания.
- - Введи номер песни из списка.
- - Выбери песню из списка нажав на ее номер.
- Аккорды:
- Под каждой песней есть кнопка "Аккорды" при нажатии на нее вам высветиться текст данной песни с аккордами.
- /id - чтобы узнать свой id.
- Связь:
- - "Написать администратору" - Отправить сообщение администратору бота.
- Либо:
- @Nosachov_Ivan - Администратор,
- @MrMelsik - Модератор (разработчик), о всех ошибках сообщать ему.
- """.format(message.from_user, bot.get_me()),
- parse_mode='html', reply_markup=markup)
- @bot.message_handler(commands=['id'])
- def myid(message):
- yourid = message.chat.id
- bot.send_message(message.chat.id, str(yourid))
- @bot.message_handler(commands=['find'])
- def find(message):
- global l, acord, trute, delit, num_to
- l = None
- try:
- print(int(message.text))
- id_name = int(message.text)
- n = True
- except:
- name = message.text
- n = False
- print('name = ' + name)
- text = []
- some = []
- md = ''
- names = []
- handle = open("song.txt", "r")
- line = handle.readline()
- acord = []
- a = None
- sam = []
- b = None
- for line in handle:
- if "&" in line:
- names.append(line)
- elif "`" in line:
- a = True
- elif "~" in line:
- b = True
- if a == True:
- if "~" not in line:
- some.append(line)
- elif "~" in line:
- md = ''.join(map(str, some))
- text.append(md)
- del(some)
- some = []
- a = False
- if b == True:
- if "nnb" not in line:
- sam.append(line)
- elif "nnb" in line:
- md2 = ''.join(map(str, sam))
- acord.append(md2)
- del(sam)
- sam = []
- b = False
- if n == False:
- if ',' in name:
- name = name.replace(',','')
- if '.' in name:
- name = name.replace('.','')
- if '!' in name:
- name = name.replace('!','')
- if '?' in name:
- name = name.replace('?','')
- if ';' in name:
- name = name.replace(';','')
- if ':' in name:
- name = name.replace(':','')
- for i in range(0,len(names)):
- if ',' in names[i]:
- names[i] = names[i].replace(',','')
- if '.' in names[i]:
- names[i] = names[i].replace('.','')
- if '!' in names[i]:
- names[i] = names[i].replace('!','')
- if '?' in names[i]:
- names[i] = names[i].replace('?','')
- if ';' in names[i]:
- names[i] = names[i].replace(';','')
- if ':' in names[i]:
- names[i] = names[i].replace(':','')
- if name.lower() in names[i].lower():
- names[i] = str.replace(names[i],"&", "" )
- bot.send_message(message.chat.id, names[i]+ '/' + str(int(i) + 1))
- text[i] = str.replace(text[i],"`", "")
- markup = types.InlineKeyboardMarkup(row_width=1)
- item = types.InlineKeyboardButton("Аккорды", callback_data='see')
- markup.add(item)
- bot.send_message(message.chat.id, text[i], reply_markup=markup)
- l = i
- break
- if l != i:
- if ',' in name:
- name = name.replace(',','')
- if '.' in name:
- name = name.replace('.','')
- if '!' in name:
- name = name.replace('!','')
- if '?' in name:
- name = name.replace('?','')
- if ';' in name:
- name = name.replace(';','')
- if ':' in name:
- name = name.replace(':','')
- for i in range(0, len(text)):
- if ',' in text[i]:
- text[i] = text[i].replace(',','')
- if '.' in text[i]:
- text[i] = text[i].replace('.','')
- if '!' in text[i]:
- text[i] = text[i].replace('!','')
- if '?' in text[i]:
- text[i] = text[i].replace('?','')
- if ';' in text[i]:
- text[i] = text[i].replace(';','')
- if ':' in text[i]:
- text[i] = text[i].replace(':','')
- if name in text[i]:
- names[i] = str.replace(names[i],"&", "" )
- bot.send_message(message.chat.id, names[i]+ '/' + str(int(i) + 1))
- text[i] = str.replace(text[i],"`", "")
- markup = types.InlineKeyboardMarkup(row_width=1)
- item = types.InlineKeyboardButton("Аккорды", callback_data='see')
- markup.add(item)
- bot.send_message(message.chat.id, text[i], reply_markup=markup)
- l = i
- break
- else:
- try:
- names[id_name-1] = str.replace(names[id_name-1],"&", "")
- bot.send_message(message.chat.id, names[id_name-1] + '/' + str(id_name))
- text[id_name-1] = str.replace(text[id_name-1],"`", "")
- markup = types.InlineKeyboardMarkup(row_width=1)
- item = types.InlineKeyboardButton("Аккорды", callback_data='see')
- markup.add(item)
- bot.send_message(message.chat.id, text[id_name-1], reply_markup=markup)
- l = id_name-1
- except Exception as e:
- print(repr(e))
- bot.send_message(message.chat.id, 'Песни под таким номером не существует!')
- @bot.message_handler(commands=['add'])
- def add(message):
- global trute, song_acord, song_name, song_text
- bot.send_message(message.chat.id, 'Введите текст(с аккордами если имеются)')
- trute = True
- @bot.message_handler(commands=['sdf'])
- def num_two(message):
- write_song = True
- global trute, song_acord, song_name, song_text, admin, delit
- song_acord = message.text
- trute = False
- text = []
- some = []
- md = ''
- names = []
- handle = open("song.txt", "r")
- line = handle.readline()
- acord = []
- a = None
- sam = []
- b = None
- for line in handle:
- if "&" in line:
- names.append(line)
- elif "`" in line:
- a = True
- elif "~" in line:
- b = True
- if a == True:
- if "~" not in line:
- some.append(line)
- elif "~" in line:
- md = ''.join(map(str, some))
- text.append(md)
- del(some)
- some = []
- a = False
- if b == True:
- if "nnb" not in line:
- sam.append(line)
- elif "nnb" in line:
- md2 = ''.join(map(str, sam))
- acord.append(md2)
- del(sam)
- sam = []
- b = False
- for i in range(0,len(names)):
- if '\n\n\n' in text[i]:
- text[i] = text[i].replace('\n\n\n', '\n\n')
- if '\n\n\n\n' in text[i]:
- text[i] = text[i].replace('\n\n\n\n', '\n\n')
- if '\n\n\n\n\n' in text[i]:
- text[i] = text[i].replace('\n\n\n\n\n', '\n\n')
- if '\n\n\n\n\n\n' in text[i]:
- text[i] = text[i].replace('\n\n\n\n\n\n', '\n\n')
- if '\n\n\n\n\n\n\n' in text[i]:
- text[i] = text[i].replace('\n\n\n\n\n\n\n', '\n\n')
- #C D E F G A H m # b 7
- d = ['C','c','D','d','E','e','F','f','G','g','A','a','H','h','M','m','#','B','b', '7']
- m = song_acord
- song_text = m
- print('1')
- print(song_text)
- lo = []
- new_song = []
- for line in song_text.split('\n'):
- 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():
- new_song.append(line)
- song_text = '\n'.join(new_song)
- print(song_text)
- for line in song_text.split('\n'):
- lo.append(line)
- break
- song_name = '\n'.join(lo)
- for i in range(0,len(names)):
- print('&' +song_name + ' : ' + names[i])
- if song_name in names[i]:
- write_song = False
- bot.send_message(message.chat.id, 'Такая песня уже существует!')
- break
- if write_song == True:
- bot.send_message(message.chat.id, 'Песня под номером ' + str(len(names)+1))
- print(song_name)
- sleep(5)
- f = open("song.txt", "a")
- f.write('\n&'+song_name+'\n')
- f.write('`'+song_text+'\n')
- f.write('~'+song_acord+'\nnnb')
- f.close()
- markup = types.InlineKeyboardMarkup(row_width=1)
- item = types.InlineKeyboardButton("Импорт", callback_data='imp')
- markup.add(item)
- bot.send_message(message.chat.id, 'Песня успешно добавлена', reply_markup=markup)
- trute = False
- delit = False
- @bot.message_handler(commands=['00'])
- def administrator(message):
- global admin
- if admin == False:
- admin = True
- bot.send_message(message.chat.id, 'Отлично, теперь вы можете добавить/изменить песню!')
- elif admin == True:
- admin = False
- bot.send_message(message.chat.id, 'Вы успешно вышли')
- @bot.message_handler(commands=['secret_cmd'])
- def change_acords(message):
- first_alv = False
- global num_to, mir
- a = num_to
- print(num_to)
- print(a)
- d = ['C','c','D','d','E','e','F','f','G','g','A','a','H','h','M','m','#','B','b', '7']
- m = a
- nb = []
- tonals = []
- song = m
- new_song = []
- song = []
- for line in m.split('\n'):
- try:
- if 'a' in line.lower():
- print('a')
- cr_m = line.index('A')
- cr_m = cr_m + 1
- try:
- if line[cr_m] != '#':
- line = line.replace('A', 'A$')
- else:
- print('#')
- line = line.replace('A#', 'A#$')
- except:
- line = line.replace('A', 'A$')
- if 'c' in line.lower():
- print('c')
- cr_m = line.index('C')
- print('c')
- cr_m = cr_m + 1
- try:
- if line[cr_m] != '#':
- line = line.replace('C', 'C$')
- else:
- print('#')
- line = line.replace('C#', 'C#$')
- except:
- line = line.replace('C', 'C$')
- if 'd' in line.lower():
- print('d')
- cr_m = line.index('D')
- cr_m = cr_m + 1
- try:
- if line[cr_m] != '#':
- line = line.replace('D', 'D$')
- else:
- print('#')
- line = line.replace('D#', 'D#$')
- except:
- line = line.replace('D', 'D$')
- if 'g' in line.lower():
- print('g')
- cr_m = line.index('G')
- cr_m = cr_m + 1
- try:
- if line[cr_m] != '#':
- line = line.replace('G', 'G$')
- else:
- print('#')
- line = line.replace('G#', 'G#$')
- except:
- line = line.replace('G', 'G$')
- if 'h' in line.lower():
- print('h')
- cr_m = line.index('H')
- cr_m = cr_m + 1
- try:
- if line[cr_m] != '#':
- line = line.replace('H', 'H$')
- else:
- pass
- except:
- line = line.replace('H', 'H$')
- if 'f' in line.lower():
- print('f')
- cr_m = line.index('F')
- cr_m = cr_m + 1
- try:
- if line[cr_m] != '#':
- line = line.replace('F', 'F$')
- else:
- print('#')
- line = line.replace('F#', 'F#$')
- except:
- line = line.replace('F', 'F$')
- if 'e' in line.lower():
- print('e')
- cr_m = line.index('E')
- cr_m = cr_m + 1
- try:
- if line[cr_m] != '#':
- line = line.replace('E', 'E$')
- except:
- line = line.replace('E', 'E$')
- song.append(line)
- except:
- pass
- for line in song:
- 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():
- new_song.append(line)
- else:
- x = 0
- while first_alv == False:
- first_bool = False
- if first_bool == False:
- line = " ".join(line.split())
- first_b = line[x]
- if first_b.lower() == 'c':
- if line[x+1] == '#':
- first_b = 'C#'
- else:
- first_b = 'C'
- elif first_b.lower() == 'd':
- if line[x+1] == '#':
- first_b = 'D#'
- else:
- first_b = 'D'
- elif first_b.lower() == 'f':
- if line[x+1] == '#':
- first_b = 'F#'
- else:
- first_b = 'F'
- elif first_b.lower() == 'g':
- if line[x+1] == '#':
- first_b = 'G#'
- else:
- first_b = 'G'
- elif first_b.lower() == 'a':
- if line[x+1] == '#':
- first_b = 'A#'
- else:
- first_b = 'A'
- first_bool = True
- if first_bool == True:
- 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':
- x = x + 1
- else:
- first_alv = True
- break
- break
- print('Тональность')
- print(first_b)
- if first_b.lower() == 'c':
- num_b = 1
- elif first_b.lower() == 'c#':
- num_b = 2
- elif first_b.lower() == 'd':
- num_b = 3
- elif first_b.lower() == 'd#':
- num_b = 4
- elif first_b.lower() == 'e':
- num_b = 5
- elif first_b.lower() == 'f':
- num_b = 6
- elif first_b.lower() == 'f#':
- num_b = 7
- elif first_b.lower() == 'g':
- num_b = 8
- elif first_b.lower() == 'g#':
- num_b = 9
- elif first_b.lower() == 'a':
- num_b = 10
- elif first_b.lower() == 'a#':
- num_b = 11
- elif first_b.lower() == 'h':
- num_b = 12
- print(num_b)
- b = {
- 1: 'C',
- 2: 'C#',
- 3: 'D',
- 4: 'D#',
- 5: 'E',
- 6: 'F',
- 7: 'F#',
- 8: 'G',
- 9: 'G#',
- 10: 'A',
- 11: 'A#',
- 12: 'H'
- }
- #запасные переменные
- l = 0
- cd = 0
- cien = 1
- mi = False
- make = 0
- minus = False
- sin = []
- songi = []
- for line in song:
- if 'Bb' in line:
- line = line.replace('Bb', 'A#')
- if 'B' in line:
- line = line.replace('B', 'A#')
- if '+' in line:
- line = line.replace('+','')
- if '-' in line:
- line = line.replace('-','')
- if '(' in line:
- line = line.replace('(','')
- if ')' in line:
- line = line.replace(')','')
- if '=' in line:
- line = line.replace('=','')
- if 'b' in line.lower():
- line = line.replace('b', '')
- if '¦' in line:
- line = line.replace('¦', '')
- 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():
- songi.append(line)
- else:
- line = " ".join(line.split())
- if cien == 1:
- rgx = re.compile("(\w[\w']*\w|\w)")
- out=rgx.findall(line)
- if line[1] == '#':
- out[0] = out[0] + '#'
- if line[2] == 'm' or line[1] == 'm':
- mi = True
- print('mi = True')
- maker = out[0]
- make = num_b
- if mir.lower() == 'c':
- l = 1
- elif mir.lower() == 'c#':
- l = 2
- elif mir.lower() == 'd':
- l = 3
- elif mir.lower() == 'd#':
- l = 4
- elif mir.lower() == 'e':
- l = 5
- elif mir.lower() == 'f':
- l = 6
- elif mir.lower() == 'f#':
- l = 7
- elif mir.lower() == 'g':
- l = 8
- elif mir.lower() == 'g#':
- l = 9
- elif mir.lower() == 'a':
- l = 10
- elif mir.lower() == 'a#':
- l = 11
- elif mir.lower() == 'h':
- l = 12
- ins = make - l
- cd = ins
- ins = make - ins
- print('ins = ' + str(ins))
- print('make = ' + str(make))
- print('l = ' + str(l))
- print('maker = ' + str(maker))
- print('cd = '+ str(cd))
- if ins == 0:
- ins = 1
- if ins == -1:
- ins = 12
- if ins == -2:
- ins = 11
- if ins == -3:
- ins = 10
- if ins == -4:
- ins = 9
- if ins == -5:
- ins = 8
- if ins == -6:
- ins = 7
- if ins == -7:
- ins =6
- if ins == -8:
- ins = 5
- if ins == -9:
- ins = 4
- if ins == -10:
- ins = 3
- if ins == -11:
- ins = 2
- if ins == -12:
- ins = 1
- if l > make:
- minus = True
- if l < make:
- minus = False
- cien = 2
- if 'd$' in line.lower():
- kit = False
- cr = line.index('D')
- cr = cr + 1
- kit = True
- if kit == True:
- d_maker = 'd'
- print(d_maker + ' DMAKER!!!!')
- for key in range(1, len(b)):
- if b[key].lower() == d_maker:
- make = key
- break
- d_ins = make - cd
- if d_ins == 0:
- d_ins = 12
- if d_ins < 0:
- d_ins = d_ins + 12
- if d_ins == 13:
- d_ins = 1
- if d_ins > 13:
- d_ins = d_ins - 12
- line = line.replace('D$', b[d_ins])
- kit = False
- if 'g$' in line.lower():
- kit = False
- cr = line.index('G')
- cr = cr + 1
- kit = True
- if kit == True:
- d_maker = 'g'
- print(d_maker + ' DMAKER!!!!')
- for key in range(1, len(b)):
- if b[key].lower() == d_maker:
- make = key
- break
- d_ins = make - cd
- if d_ins == 0:
- d_ins = 12
- if d_ins < 0:
- d_ins = d_ins + 12
- if d_ins == 13:
- d_ins = 1
- if d_ins > 13:
- d_ins = d_ins - 12
- line = line.replace('G$', b[d_ins])
- kit = False
- if 'c$' in line.lower():
- kit = False
- cr = line.index('C')
- cr = cr + 1
- kit = True
- if kit == True:
- d_maker = 'c'
- print(d_maker + ' DMAKER!!!!')
- for key in range(1, len(b)):
- if b[key].lower() == d_maker:
- make = key
- break
- print(make)
- d_ins = make - cd
- if d_ins == 0:
- d_ins = 12
- if d_ins < 0:
- d_ins = d_ins + 12
- if d_ins == 13:
- d_ins = 1
- if d_ins > 13:
- d_ins = d_ins - 12
- line = line.replace('C$', b[d_ins])
- kit = False
- print(line.lower())
- if 'f$' in line.lower():
- kit = False
- cr = line.index('F')
- cr = cr + 1
- kit = True
- if kit == True:
- d_maker = 'f'
- print(d_maker + ' DMAKER!!!!')
- for key in range(1, len(b)):
- if b[key].lower() == d_maker:
- make = key
- break
- d_ins = make - cd
- if d_ins == 0:
- d_ins = 12
- if d_ins < 0:
- d_ins = d_ins + 12
- if d_ins == 13:
- d_ins = 1
- if d_ins > 13:
- d_ins = d_ins - 12
- line = line.replace('F$', b[d_ins])
- kit = False
- if 'h$' in line.lower():
- kit = False
- cr = line.index('H')
- cr = cr + 1
- kit = True
- if kit == True:
- d_maker = 'h'
- print(d_maker + ' DMAKER!!!!')
- for key in range(1, len(b)):
- if b[key].lower() == d_maker:
- make = key
- break
- make = 12
- d_ins = make - cd
- print('d' + ' ' + str(d_ins))
- if d_ins == 0:
- d_ins = 12
- if d_ins < 0:
- d_ins = d_ins + 12
- if d_ins == 13:
- d_ins = 1
- if d_ins > 13:
- d_ins = d_ins - 12
- print('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
- print('d' + ' ' + str(d_ins))
- print('m ' + str(make))
- print('cd ' + str(cd))
- line = line.replace('H$', b[d_ins])
- kit = False
- if 'e$' in line.lower():
- kit = False
- cr = line.index('E')
- cr = cr + 1
- kit = True
- if kit == True:
- d_maker = 'e'
- print(d_maker + ' DMAKER!!!!')
- for key in range(1, len(b)):
- if b[key].lower() == d_maker:
- make = key
- break
- d_ins = make - cd
- if d_ins == 0:
- d_ins = 12
- if d_ins < 0:
- d_ins = d_ins + 12
- if d_ins == 13:
- d_ins = 1
- if d_ins > 13:
- d_ins = d_ins - 12
- line = line.replace('E$', b[d_ins])
- kit = False
- if 'a$' in line.lower():
- kit = False
- cr = line.index('A')
- cr = cr + 1
- kit = True# # # # # # # # # # # # # # # # # # # ## # # # # # # # # #
- if kit == True:
- d_maker = 'a'
- print(d_maker + ' DMAKER!!!!')
- for key in range(1, len(b)):
- if b[key].lower() == d_maker:
- print(key)
- make = key
- break
- d_ins = make - cd
- if d_ins == 0:
- d_ins = 12
- if d_ins < 0:
- d_ins = d_ins + 12
- if d_ins == 13:
- d_ins = 1
- if d_ins > 13:
- d_ins = d_ins - 12
- print('d' + ' ' + str(d_ins))
- print('m ' + str(make))
- print('cd ' + str(cd))
- line = line.replace('A$', b[d_ins])
- kit = False
- if 'c#$' in line.lower():
- print('1')
- kit = False
- cr = line.index('C')
- cr = cr + 2
- kit = True
- if kit == True:
- d_maker = 'c#'
- print('1')
- for key in range(1, len(b)):
- if b[key].lower() == d_maker:
- make = key
- break
- d_ins = make - cd
- print('make ' + str(make) + ' : ' + str(cd) + ' : ' + str(d_ins) )
- if d_ins == 0:
- d_ins = 12
- if d_ins < 0:
- d_ins = d_ins + 12
- if d_ins == 13:
- d_ins = 1
- if d_ins > 13:
- d_ins = d_ins - 12
- print(str(make) + 'nc')
- print(cd)
- print(d_ins)
- print(b[d_ins])
- line = line.replace('C#$', b[d_ins])
- kit = False
- if 'd#$' in line.lower():
- print('1')
- kit = False
- cr = line.index('D')
- cr = cr + 2
- kit = True
- if kit == True:
- d_maker = 'd#'
- print('1')
- for key in range(1, len(b)):
- if b[key].lower() == d_maker:
- make = key
- break
- d_ins = make - cd
- print('make ' + str(make) + ' : ' + str(cd) + ' : ' + str(d_ins) )
- if d_ins == 0:
- d_ins = 12
- if d_ins < 0:
- d_ins = d_ins + 12
- if d_ins == 13:
- d_ins = 1
- if d_ins > 13:
- d_ins = d_ins - 12
- print('2')
- print(str(make) + 'nd')
- print(cd)
- print(d_ins)
- print(b[d_ins])
- line = line.replace('D#$', b[d_ins])
- kit = False
- if 'f#$' in line.lower():
- print('1')
- kit = False
- cr = line.index('F')
- cr = cr + 2
- kit = True
- if kit == True:
- d_maker = 'f#'
- print('1')
- for key in range(1, len(b)):
- if b[key].lower() == d_maker:
- make = key
- break
- d_ins = make - cd
- print('make ' + str(make) + ' : ' + str(cd) + ' : ' + str(d_ins) )
- if d_ins == 0:
- d_ins = 12
- if d_ins < 0:
- d_ins = d_ins + 12
- if d_ins == 13:
- d_ins = 1
- if d_ins > 13:
- d_ins = d_ins - 12
- print('2')
- print(str(make) + 'nf')
- print(cd)
- print(d_ins)
- print(b[d_ins])
- line = line.replace('F#$', b[d_ins])
- kit = False
- if 'g#$' in line.lower():
- print('1')
- kit = False
- cr = line.index('G')
- cr = cr + 2
- kit = True
- if kit == True:
- d_maker = 'g#'
- print('1')
- for key in range(1, len(b)):
- if b[key].lower() == d_maker:
- make = key
- break
- d_ins = make - cd
- print('make ' + str(make) + ' : ' + str(cd) + ' : ' + str(d_ins) )
- if d_ins == 0:
- d_ins = 12
- if d_ins < 0:
- d_ins = d_ins + 12
- if d_ins == 13:
- d_ins = 1
- if d_ins > 13:
- d_ins = d_ins - 12
- print('2')
- print(str(make) + 'nd')
- print(cd)
- print(d_ins)
- print(b[d_ins])
- line = line.replace('G#$', b[d_ins])
- kit = False
- if 'a#$' in line.lower():
- print('1')
- kit = False
- cr = line.index('A')
- cr = cr + 2
- kit = True
- if kit == True:
- d_maker = 'a#'
- print('1')
- for key in range(1, len(b)):
- if b[key].lower() == d_maker:
- make = key
- break
- d_ins = make - cd
- print('make ' + str(make) + ' : ' + str(cd) + ' : ' + str(d_ins) )
- if d_ins == 0:
- d_ins = 12
- if d_ins < 0:
- d_ins = d_ins + 12
- if d_ins == 13:
- d_ins = 1
- if d_ins > 13:
- d_ins = d_ins - 12
- print('2')
- print(str(make) + 'nd')
- print(cd)
- print(d_ins)
- print(b[d_ins])
- line = line.replace('A#$', b[d_ins])
- kit = False
- sin.append(line)
- num = []
- for line in sin:
- #line = line.replace('$','')
- num.append(line)
- #for i in range(0,10):
- #print('')
- for i in range(0,len(num)):
- print(num[i])
- #for i in range(0, len(songi)):
- #print(songi[i])
- #for i in range(0, len(sin)):
- #print(sin[i])
- #print('\n\n\n\n\n\n\n\n\n')
- ac = -1
- end_song = []
- for line in song:
- 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():
- pass
- else:
- ac = ac + 1
- line = line.replace(line, num[ac])
- end_song.append(line)
- end_s = '\n'.join(end_song)
- bot.send_message(message.chat.id, end_s)
- @bot.message_handler(commands=['all_song'])
- def all_song(message):
- global trute, delit
- try:
- text = []
- some = []
- md = ''
- names = []
- mi = []
- handle = open("song.txt", "r")
- line = handle.readline()
- acord = []
- d = 1
- a = None
- slov = {}
- sam = []
- b = None
- for line in handle:
- if "&" in line:
- names.append(line)
- slov[names[0]]=str(d)
- d += 1
- del(names)
- names = []
- elif "`" in line:
- a = True
- elif "~" in line:
- b = True
- if a == True:
- if "~" not in line:
- some.append(line)
- elif "~" in line:
- md = ''.join(map(str, some))
- text.append(md)
- del(some)
- some = []
- a = False
- if b == True:
- if "nnb" not in line:
- sam.append(line)
- elif "nnb" in line:
- md2 = ''.join(map(str, sam))
- acord.append(md2)
- del(sam)
- sam = []
- b = False
- all_text = []
- name = 'а'
- for i in range(0,len(names)):
- if name.lower() in names[i][1].lower():
- names[i] = str.replace(names[i],"&", "" )
- all_text.append(names[i]+'/'+str(int(i)+1))
- n = '\n'.join(map(str, all_text))
- list_keys = list(slov.keys())
- list_keys.sort()
- ck = 0
- for i in list_keys:
- lm = str.replace(i,"&", "" )
- k = str.replace(lm, "\n", "")
- if ck < 10:
- print('lm ' + str(lm))
- print('k ' + str(k))
- mi.append(str(k)+' | '+'/'+ str(slov[i]) + '\n')
- ck = ck + 1
- mi_app = []
- ls = None
- for i in range(0, len(mi)):
- if i < 10:
- print(mi[i])
- mi_app.append(mi[i])
- if len(mi_app) == 40:
- ls = '\n'.join(map(str,mi_app))
- bot.send_message(message.chat.id, ls)
- del(ls)
- del(mi_app)
- mi_app = []
- elif i == len(mi)-1:
- ls = '\n'.join(map(str,mi_app))
- bot.send_message(message.chat.id, ls)
- del(ls)
- del(mi_app)
- mi_app = []
- trute = False
- delit = False
- except Exception as e:
- print(repr(e))
- trute = False
- delit = False
- @bot.message_handler(commands=['find_bu'])
- def find_bu(message):
- try:
- global bu, acord, trute, delit
- name = message.text
- text = []
- some = []
- md = ''
- names = []
- handle = open("song.txt", "r")
- line = handle.readline()
- acord = []
- a = None
- sam = []
- b = None
- for line in handle:
- if "&" in line:
- names.append(line)
- elif "`" in line:
- a = True
- elif "~" in line:
- b = True
- if a == True:
- if "~" not in line:
- some.append(line)
- elif "~" in line:
- md = ''.join(map(str, some))
- text.append(md)
- del(some)
- some = []
- a = False
- if b == True:
- if "nnb" not in line:
- sam.append(line)
- elif "nnb" in line:
- md2 = ''.join(map(str, sam))
- acord.append(md2)
- del(sam)
- sam = []
- b = False
- all_text = []
- for i in range(0,len(names)):
- if name.lower() in names[i][1].lower():
- names[i] = str.replace(names[i],"&", "" )
- all_text.append(names[i]+'/'+str(int(i)+1))
- n = '\n'.join(map(str, all_text))
- bot.send_message(message.chat.id, n)
- bu = False
- trute = False
- delit = False
- except:
- bot.send_message(message.chat.id, 'Песен на такую букву не существует!')
- bu = False
- @bot.message_handler(commands=['find_song2'])
- def find_text2(message):
- global num_to
- try:
- global l, acord, trute, delit
- id_name = message.text
- id_name = str.replace(id_name, "/", "")
- text = []
- some = []
- md = ''
- names = []
- handle = open("song.txt", "r")
- line = handle.readline()
- acord = []
- a = None
- sam = []
- b = None
- for line in handle:
- if "&" in line:
- names.append(line)
- elif "`" in line:
- a = True
- elif "~" in line:
- b = True
- if a == True:
- if "~" not in line:
- some.append(line)
- elif "~" in line:
- md = ''.join(map(str, some))
- text.append(md)
- del(some)
- some = []
- a = False
- if b == True:
- if "nnb" not in line:
- sam.append(line)
- elif "nnb" in line:
- md2 = ''.join(map(str, sam))
- acord.append(md2)
- del(sam)
- sam = []
- b = False
- names[int(id_name)-1] = str.replace(names[int(id_name)-1],"&", "")
- bot.send_message(message.chat.id, names[int(id_name)-1] + '/' + str(id_name))
- text[int(id_name)-1] = str.replace(text[int(id_name)-1],"`", "")
- markup = types.InlineKeyboardMarkup(row_width=1)
- item = types.InlineKeyboardButton("Аккорды", callback_data='see')
- markup.add(item)
- bot.send_message(message.chat.id, text[int(id_name)-1], reply_markup=markup)
- l = int(id_name)-1
- except:
- bot.send_message(message.chat.id, 'Такого номера не существует!')
- trute = False
- delit = False
- @bot.message_handler(commands=['delete'])
- def delete(message):
- try:
- global delit, id_name, nom, acord, trute, text_func, acord_func, namer_func
- text = []
- some = []
- nom = 0
- md = ''
- names = []
- biglen = False
- if int(id_name) > 1:
- biglen = True
- handle = open("song.txt", "r")
- line = handle.readline()
- acord = []
- a = None
- sam = []
- b = None
- print('all')
- for line in handle:
- if "&" in line:
- if namer_func == True:
- if nom == int(id_name)-1:
- if biglen == False:
- line = line.replace(line, '&'+namer_name+'\n')
- elif biglen == True:
- line = line.replace(line, 'nnb' + '\n&'+namer_name+'\n')
- names.append(line)
- print(nom)
- nom += 1
- j = nom
- ac = nom
- elif namer_func == False:
- if biglen == True:
- if nom == int(id_name)-1:
- line = line.replace(line, 'nnb' + '\n' + line)
- names.append(line)
- print(nom)
- nom += 1
- j = nom
- ac = nom
- elif "`" in line:
- a = True
- elif "~" in line:
- b = True
- if a == True:
- if "~" not in line:
- if text_func == True:
- if int(nom) == int(id_name):
- if j == int(id_name):
- line = line.replace(line, '`'+text_name+'\n')
- j= 0
- else:
- line = line.replace(line, '')
- some.append(line)
- elif text_func == False:
- some.append(line)
- elif "~" in line:
- md = ''.join(map(str, some))
- text.append(md)
- del(some)
- some = []
- a = False
- if b == True:
- if "nnb" not in line:
- if acord_func == True:
- if int(nom) == int(id_name):
- if ac == int(id_name):
- line = line.replace(line, '~'+acord_name +'\n')
- ac= 0
- else:
- line = line.replace(line, '')
- sam.append(line)
- elif acord_func == False:
- sam.append(line)
- elif "nnb" in line:
- md2 = ''.join(map(str, sam))
- if nom != int(id_name)-1:
- acord.append(md2+'nnb')
- elif nom == int(id_name)-1:
- acord.append(md2)
- del(sam)
- sam = []
- b = False
- for i in range(0, len(names)):
- print('\n'+names[i]+text[i]+acord[i])
- handle.close()
- for i in range(0,len(names)):
- if '\n\n\n' in text[i]:
- text[i] = text[i].replace('\n\n\n', '\n\n')
- if '\n\n\n\n' in text[i]:
- text[i] = text[i].replace('\n\n\n\n', '\n\n')
- if '\n\n\n\n\n' in text[i]:
- text[i] = text[i].replace('\n\n\n\n\n', '\n\n')
- if '\n\n\n\n\n\n' in text[i]:
- text[i] = text[i].replace('\n\n\n\n\n\n', '\n\n')
- if '\n\n\n\n\n\n\n' in text[i]:
- text[i] = text[i].replace('\n\n\n\n\n\n\n', '\n\n')
- print(names)
- handle2 = open('song.txt', 'w')
- for i in range(0,len(names)):
- handle2.write('\n'+names[i]+text[i]+acord[i])
- text[i] = text[i].replace('`', '')
- acord[i] = acord[i].replace('~', '')
- names[i] = names[i].replace('&', '')
- if 'nnb' in acord[i]:
- acord[i] = acord[i].replace('nnb', '')
- if 'nnb' in names[i]:
- names[i] = names[i].replace('nnb', '')
- if ' ' in names[i][0]:
- names[i] = names[i].replace(' ', '')
- if ' ' in acord[i][0]:
- acord[i] = acord[i].replace(' ', '')
- if ' ' in text[i][0]:
- text[i] = text[i].replace(' ', '')
- bot.send_message(message.chat.id, 'Изменение успешно!')
- trute = False
- delit = False
- except Exception as e:
- print(repr(e))
- bot.send_message(message.chat.id, 'Такого номера не существует!')
- trute = False
- delit = False
- text_func = False
- acord_func = False
- index = 1
- namer_func = False
- change(message)
- @bot.message_handler(commands=['change'])
- def change(message):
- markup = types.InlineKeyboardMarkup(row_width=1)
- item = types.InlineKeyboardButton("Название", callback_data='replace_1')
- item2 = types.InlineKeyboardButton("Текст", callback_data='replace_2')
- item3 = types.InlineKeyboardButton("Аккорды", callback_data='replace_3')
- item4 = types.InlineKeyboardButton("Готово", callback_data='done')
- markup.add(item, item2, item3,item4)
- bot.send_message(message.chat.id, 'Что вы хотите изменить?', reply_markup=markup)
- @bot.message_handler(content_types=['text'])
- def text(message):
- global num, song_name, otvet_user, song_text, acord, song_acord, trute, admin, bu, name2, delit
- if namer_func == True:
- global namer_name
- namer_name = message.text
- delete(message)
- elif text_func == True:
- global text_name
- text_name = message.text
- delete(message)
- elif acord_func == True:
- global acord_name
- acord_name = message.text
- delete(message)
- elif bu == True:
- print('one')
- find_bu(message)
- elif message.text == 'Добавить песню':
- print('two')
- if admin == True:
- add(message)
- elif admin == False:
- bot.send_message(message.chat.id, 'Введите номер доступа')
- trute = False
- elif message.text == 'Написать всем':
- bot.send_message(message.chat.id , 'Вы написали всем')
- elif message.text == 'Написать администратору':
- bot.send_message(message.chat.id, 'Напишите сообщение')
- bot.register_next_step_handler(message, admin_sms)
- elif message.text == 'Изменить песню':
- print('three')
- if admin == True:
- bot.send_message(message.chat.id, 'Введите номер песни')
- delit = True
- trute = False
- elif admin == False:
- bot.send_message(message.chat.id, 'Введите номер доступа!')
- trute = False
- elif message.text[0] == '/':
- print('four')
- find_text2(message)
- elif message.text.lower() == 'список':
- print('fife')
- all_song(message)
- elif len(message.text) == 1 and delit == False:
- if delit == False and trute == False:
- print('six')
- try:
- print(int(message.text))
- find(message)
- except:
- bu = True
- find_bu(message)
- else:
- if trute == False:
- print('yes!1')
- if otvet_user == True:
- print(str(id_us) + ' jk')
- bot.send_message(id_us,'*Ответ от администратора*\n' + message.text, parse_mode="Markdown")
- bot.send_message(message.chat.id, 'Сообщение успешно отправлено')
- otvet_user = False
- elif delit == False:
- print('yes!')
- find(message)
- elif delit == True:
- global id_name
- id_name = message.text
- change(message)
- elif trute == True:
- print('2')
- song_acord = message.text
- num_two(message)
- def admin_sms(message):
- #418914656 -
- global name_us, login_us, sms_us, id_us
- try:
- name_us = message.from_user.first_name
- login_us = message.from_user.username
- sms_us = message.text
- id_us = message.chat.id
- except:
- id_us = message.chat.id
- name_us = message.from_user.first_name
- sms_us = message.text
- markup = types.InlineKeyboardMarkup(row_width=2)
- item = types.InlineKeyboardButton("Да", callback_data='yesof')
- item2 = types.InlineKeyboardButton("Нет", callback_data='noof')
- markup.add(item,item2)
- bot.send_message(message.chat.id, 'Вы уверены?', reply_markup=markup)
- def namer(message):
- bot.send_message(message.chat.id, 'Введите текст песни')
- bot.register_next_step_handler(message, texti)
- def texti(message):
- global text_name
- text_name = message.text
- bot.send_message(message.chat.id, 'Веддите текст с аккордами')
- bot.register_next_step_handler(message, acordi)
- def acordi(message):
- global acord_name
- acord_name = message.text
- delete(message)
- def text2(message):
- global trute, song_acord, song_name, song_text
- song_text = message.text
- bot.send_message(message.chat.id, 'Теперь текст с аккордами')
- bot.register_next_step_handler(message, text3)
- def text3(message):
- global trute, song_acord, song_name, song_text, admin, delit
- song_acord = message.text
- bot.send_message(message.chat.id, 'Успешно!')
- trute = False
- text = []
- some = []
- md = ''
- names = []
- handle = open("song.txt", "r")
- line = handle.readline()
- acord = []
- a = None
- sam = []
- b = None
- for line in handle:
- if "&" in line:
- names.append(line)
- elif "`" in line:
- a = True
- elif "~" in line:
- b = True
- if a == True:
- if "~" not in line:
- some.append(line)
- elif "~" in line:
- md = ''.join(map(str, some))
- text.append(md)
- del(some)
- some = []
- a = False
- if b == True:
- if "nnb" not in line:
- sam.append(line)
- elif "nnb" in line:
- md2 = ''.join(map(str, sam))
- acord.append(md2)
- del(sam)
- sam = []
- b = False
- for i in range(0,len(names)):
- if '\n\n\n' in text[i]:
- text[i] = text[i].replace('\n\n\n', '\n\n')
- if '\n\n\n\n' in text[i]:
- text[i] = text[i].replace('\n\n\n\n', '\n\n')
- if '\n\n\n\n\n' in text[i]:
- text[i] = text[i].replace('\n\n\n\n\n', '\n\n')
- if '\n\n\n\n\n\n' in text[i]:
- text[i] = text[i].replace('\n\n\n\n\n\n', '\n\n')
- if '\n\n\n\n\n\n\n' in text[i]:
- text[i] = text[i].replace('\n\n\n\n\n\n\n', '\n\n')
- bot.send_message(message.chat.id, 'Песня под номером ' + str(len(names)+1))
- f = open("song.txt", "a")
- f.write('\n&'+song_name+'\n')
- f.write('`'+song_text+'\n')
- f.write('~'+song_acord+'\nnnb')
- f.close()
- trute = False
- delit = False
- bot.send_message(message.chat.id, 'Ожидайте...')
- sheets(message)
- @bot.callback_query_handler(func=lambda call: True)
- def callback_inline(call):
- global trute, delit, namer_func, text_func, acord_func, mir, num_to, login_us, otvet_user
- try:
- if call.message:
- if call.data == 'see':
- acord[l] = str.replace(acord[l],"~", "")
- num_to = acord[l]
- markup = types.InlineKeyboardMarkup(row_width=6)
- item = types.InlineKeyboardButton("C", callback_data='c')
- item2 = types.InlineKeyboardButton("C#", callback_data='c2')
- item3 = types.InlineKeyboardButton("D", callback_data='d')
- item4 = types.InlineKeyboardButton("D#", callback_data='d2')
- item5 = types.InlineKeyboardButton("E", callback_data='e')
- item6 = types.InlineKeyboardButton("F", callback_data='f')
- item7 = types.InlineKeyboardButton("F#", callback_data='f2')
- item8 = types.InlineKeyboardButton("G", callback_data='g')
- item9 = types.InlineKeyboardButton("G#", callback_data='g2')
- item10 = types.InlineKeyboardButton("A", callback_data='a')
- item11 = types.InlineKeyboardButton("A#", callback_data='a2')
- item12 = types.InlineKeyboardButton("H", callback_data='h')
- markup.add(item, item2, item3, item4, item5, item6, item7, item8, item9, item10, item11, item12)
- bot.send_message(call.message.chat.id, acord[l], reply_markup=markup)
- elif call.data == 'c':
- mir = 'c'
- change_acords(call.message)
- elif call.data == 'c2':
- mir = 'c#'
- change_acords(call.message)
- elif call.data == 'd':
- mir = 'd'
- change_acords(call.message)
- elif call.data == 'd2':
- mir = 'd#'
- change_acords(call.message)
- elif call.data == 'e':
- mir = 'e'
- change_acords(call.message)
- elif call.data == 'f':
- mir = 'f'
- change_acords(call.message)
- elif call.data == 'f2':
- mir = 'f#'
- change_acords(call.message)
- elif call.data == 'g':
- mir = 'g'
- change_acords(call.message)
- elif call.data == 'g2':
- mir = 'g#'
- change_acords(call.message)
- elif call.data == 'a':
- mir = 'a'
- change_acords(call.message)
- elif call.data == 'a2':
- mir = 'a#'
- change_acords(call.message)
- elif call.data == 'h':
- mir = 'h'
- change_acords(call.message)
- elif call.data == 'imp':
- import_text(call.message)
- elif call.data == 'replace_1':
- bot.send_message(call.message.chat.id, 'Введите название')
- namer_func = True
- elif call.data == 'replace_2':
- bot.send_message(call.message.chat.id, 'Введите текст')
- text_func = True
- elif call.data == 'replace_3':
- bot.send_message(call.message.chat.id, 'Введите текст с аккордами')
- acord_func = True
- elif call.data == 'done':
- bot.send_message(call.message.chat.id, 'Изменения успешно применены')
- namer_func = False
- text_func = False
- acord_func = False
- elif call.data == 'otvet':
- bot.send_message(call.message.chat.id, 'Введите сообщение')
- otvet_user = True
- elif call.data == 'yesof':
- #418914656 - admin
- #846352856 - moder
- try:
- if login_us == '':
- if minesd == 123123:
- print(1+'s')
- markup = types.InlineKeyboardMarkup(row_width=1)
- item = types.InlineKeyboardButton("Ответить", callback_data='otvet')
- markup.add(item)
- bot.send_message(418914656, '*'+ name_us +' @'+login_us + '*\n' + sms_us, parse_mode="Markdown", reply_markup=markup)
- except:
- markup = types.InlineKeyboardMarkup(row_width=1)
- item = types.InlineKeyboardButton("Ответить", callback_data='otvet')
- markup.add(item)
- login_us = ''
- print(id_us)
- bot.send_message(418914656, '*'+ name_us +'* `Логин не найден` '+ '\n' + sms_us, parse_mode="Markdown", reply_markup=markup)
- bot.send_message(call.message.chat.id, 'Сообщение успешно отправилось!')
- elif call.data == 'new_songs':
- bot.send_message(call.message.chat.id,'пофиг')
- elif call.data == 'choice_songs':
- bot.send_message(call.message.chat.id, 'дада')
- elif call.data == 'noof':
- bot.send_message(call.message.chat.id, 'Сообщение не отправлено')
- except Exception as e:
- print(repr(e))
- trute = False
- delit = False
- if num_reply == 0:
- export_song()
- num_reply = 1
- bot.polling()
Add Comment
Please, Sign In to add comment