mode refactoring
This commit is contained in:
+2
-2
@@ -266,8 +266,8 @@ def list_jobs(message):
|
|||||||
@bot.message_handler(func=is_white, commands=['add'])
|
@bot.message_handler(func=is_white, commands=['add'])
|
||||||
def add_stan_quote(message):
|
def add_stan_quote(message):
|
||||||
if message.reply_to_message and message.reply_to_message.text:
|
if message.reply_to_message and message.reply_to_message.text:
|
||||||
with open('Stan.txt', 'a+', encoding='utf8') as stan_quotes:
|
with open('Stan.txt', 'a', encoding='utf8') as stan_quotes:
|
||||||
if message.reply_to_message.text not in (i.rstrip() for i in stan_quotes):
|
if message.reply_to_message.text not in (i.rstrip() for i in open('Stan.txt', 'r', encoding='utf8')):
|
||||||
stan_quotes.write('\n' + message.reply_to_message.text)
|
stan_quotes.write('\n' + message.reply_to_message.text)
|
||||||
bot.send_message(message.chat.id, f'✅ <b>Добавил</b>\n └ <i>{message.reply_to_message.text}</i>')
|
bot.send_message(message.chat.id, f'✅ <b>Добавил</b>\n └ <i>{message.reply_to_message.text}</i>')
|
||||||
else:
|
else:
|
||||||
|
|||||||
+1
-2
@@ -5,5 +5,4 @@ import random
|
|||||||
def speak(chance_of):
|
def speak(chance_of):
|
||||||
number = random.randint(0, chance_of)
|
number = random.randint(0, chance_of)
|
||||||
if number == 0:
|
if number == 0:
|
||||||
quotes = (i.rstrip() for i in open('Stan.txt', 'r', encoding='utf8'))
|
return random.choice(i.rstrip() for i in open('Stan.txt', 'r', encoding='utf8'))
|
||||||
return random.choice(quotes)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user