upd send rules

This commit is contained in:
Rykov7
2023-01-23 14:44:29 +03:00
parent 44f6771c49
commit bbb0cbc9b5
4 changed files with 25 additions and 2 deletions
+7 -2
View File
@@ -10,6 +10,7 @@ from . import reminder
from . import reloader
from . import report
from . import get
from . import rules
from .helpers import get_me, search_it
from .filters import *
from .config import *
@@ -73,9 +74,13 @@ def send_links(message):
send_or_reply(message, f"{RULES}\n{FAQ}\n{LIB}")
@bot.message_handler(commands=['rules'])
@bot.message_handler(commands=['rules', 'r'])
def send_rules(message):
send_or_reply(message, f'{RULES}')
args = message.text.split()
if len(args) > 1 and args[-1].isdigit():
send_or_reply(message, rules.get_rule(args[-1]))
else:
send_or_reply(message, f'{RULES}')
@bot.message_handler(commands=['faq'])
+2
View File
@@ -6,6 +6,7 @@ from . import config
from . import get
from . import helpers
from . import report
from . import rules
from . import stan
@@ -16,4 +17,5 @@ def reload_modules():
reload(config)
reload(helpers)
reload(report)
reload(rules)
reload(stan)
+16
View File
@@ -0,0 +1,16 @@
from bs4 import BeautifulSoup
from urllib.request import urlopen
html = BeautifulSoup(urlopen('https://telegra.ph/pythonchatru-07-07'), 'lxml')
def get_rule(li):
li = int(li)
try:
return html.find_all('li')[li - 1].text
except IndexError:
return 'Нет такого правила.'
if __name__ == '__main__':
print(get_rule(1))
BIN
View File
Binary file not shown.