Co-authored-by: Aakash <BLUE-DEVIL1134@users.noreply.github.com> Co-authored-by: Aditya <me@xditya.me> Co-authored-by: Danish <danish@ultroid.tech> Co-authored-by: buddhhu <buddhuu@users.noreply.github.com> Co-authored-by: sppidy <sppidy@users.noreply.github.com> Co-authored-by: Arnab Paryali <Arnabxd@users.noreply.github.com> Co-authored-by: divkix <divkix@users.noreply.github.com> Co-authored-by: hellboi_atul <hellboi-atul@users.noreply.github.com> Co-authored-by: Programming Error <error@notavailable.live> Co-authored-by: New-dev0 <New-dev0@notavailable.live>
47 lines
1.3 KiB
Python
47 lines
1.3 KiB
Python
# Ultroid - UserBot
|
|
# Copyright (C) 2020 TeamUltroid
|
|
#
|
|
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
|
# PLease read the GNU Affero General Public License in
|
|
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
|
|
|
"""
|
|
✘ Commands Available -
|
|
|
|
• `{i}eod` or `{i}eod <dd/mm>`
|
|
`Get Event of the Day`
|
|
"""
|
|
|
|
import re
|
|
from datetime import datetime as dr
|
|
|
|
import requests as r
|
|
from bs4 import BeautifulSoup as bs
|
|
|
|
from . import *
|
|
|
|
|
|
@ultroid_cmd(pattern="eod ?(.*)")
|
|
async def diela(e):
|
|
match = e.pattern_match.group(1)
|
|
m = await eor(e, "`Processing... `")
|
|
li = "https://daysoftheyear.com"
|
|
te = "♻️ **Events of the Day**\n\n"
|
|
if match:
|
|
date = match.split("/")[0]
|
|
month = match.split("/")[1]
|
|
li += "/days/2021/" + month + "/" + date
|
|
te = f"♻️ **Events for {match}/2021**\n\n"
|
|
else:
|
|
da = dr.today().strftime("%F").split("-")
|
|
li += "/days/2021/" + da[1] + "/" + da[2]
|
|
ct = r.get(li).content
|
|
bt = bs(ct, "html.parser", from_encoding="utf-8")
|
|
ml = bt.find_all("a", "js-link-target", href=re.compile("daysoftheyear.com/days"))
|
|
for eve in ml[:5]:
|
|
te += "• " + f'[{eve.text}]({eve["href"]})\n'
|
|
await m.edit(te, link_preview=False)
|
|
|
|
|
|
HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=HNDLR)}"})
|