improve adding quotes, improve reading quotes
This commit is contained in:
+7
-3
@@ -266,9 +266,13 @@ def list_jobs(message):
|
||||
@bot.message_handler(func=is_white, commands=['add'])
|
||||
def add_stan_quote(message):
|
||||
if message.reply_to_message and message.reply_to_message.text:
|
||||
with open('Stan.txt', 'a', encoding='utf8') as stan_quotes:
|
||||
stan_quotes.write('\n' + message.reply_to_message.text)
|
||||
bot.send_message(message.chat.id, f'Добавил: {message.reply_to_message.text}')
|
||||
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):
|
||||
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>')
|
||||
else:
|
||||
bot.send_message(message.chat.id,
|
||||
f'⛔️ <b><u>Не добавил</u></b>, есть токое\n └ <i>{message.reply_to_message.text}</i>')
|
||||
|
||||
|
||||
@bot.message_handler(func=is_admin, commands=['stats'])
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ LIB = '📚 <b><a href="https://telegra.ph/what-to-read-10-06">Библиоте
|
||||
|
||||
SPAM = ['me.sv/', 'tg.sv/', 'goo.by/', 'go.sv/', 'intim.video/', 'uclck.ru/']
|
||||
NON_GRATA = ['дудар', 'хауди', 'dudar']
|
||||
BAN_WORDS = ['GREEN ROOM']
|
||||
BAN_WORDS = ['GREEN']
|
||||
|
||||
ZEN = ['Beautiful is better than ugly.', 'Explicit is better than implicit.', 'Simple is better than complex.',
|
||||
'Complex is better than complicated.', 'Flat is better than nested.', 'Sparse is better than dense.',
|
||||
|
||||
+1
-2
@@ -1,10 +1,9 @@
|
||||
""" Stan quote generator. """
|
||||
import random
|
||||
|
||||
quotes = [i.rstrip() for i in open('Stan.txt', 'r', encoding='utf8')]
|
||||
|
||||
|
||||
def speak(chance_of):
|
||||
number = random.randint(0, chance_of)
|
||||
if number == 0:
|
||||
quotes = (i.rstrip() for i in open('Stan.txt', 'r', encoding='utf8'))
|
||||
return random.choice(quotes)
|
||||
|
||||
Reference in New Issue
Block a user