upd send rules
This commit is contained in:
+6
-1
@@ -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,8 +74,12 @@ 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):
|
||||
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}')
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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))
|
||||
Binary file not shown.
Reference in New Issue
Block a user