asetalias / amibot-tg

Amibot on steroids: A Telegram bot for Amizone, powered by the go-amizone API!
MIT License
8 stars 7 forks source link

[Feat] get class schedule of any date (calendar) #85

Closed SudoSu-bham closed 11 months ago

SudoSu-bham commented 11 months ago

close #29 The Amibot-tg can now show the class schedule of any dates in current month. This was a long-awaited feature. here is the image of the output Screenshot from 2023-10-25 20-54-44

Maniktherana commented 11 months ago

nice work, some points:

  1. We can merge these two messages

    Screenshot 2023-10-25 at 8 57 01 PM
  2. Now that class schedule can be fetched for a specific day, we should maybe just give a preview of the day we're fetching for in this message:

    Screenshot 2023-10-25 at 8 58 09 PM

We can add more contextual information like

🟢🟢🟢🟢
Schedule for Mon, 25 Oct:
...
  1. Finally, is there a way to make this portion look better? Screenshot 2023-10-25 at 9 00 29 PM

Perhaps just add today's date in the Select Date message so the width of the button map increases

@achintya-7 any inputs?

achintya-7 commented 11 months ago

How about we get the current month and display number of dates according to it.

A switch or match statement with a function can be used (Can decouple the build calendar for loop).

Maniktherana commented 11 months ago

How about we get the current month and display number of dates according to it.

Looks like the code is already doing that:

def create_calendar_markup():
    today = datetime.date.today()
    year = today.year
    month = today.month
    dates = []
    global list_dates
    list_dates = []

    first_day = datetime.date(year, month, 1)
    last_day = datetime.date(year, month + 1, 1) - datetime.timedelta(days=1)

    for day in range(1, last_day.day + 1):
        date = datetime.date(year, month, day)
        dates.append(InlineKeyboardButton(str(day), callback_data=date.strftime("%Y-%m-%d")))
        list_dates.append(date.strftime("%Y-%m-%d"))

    return InlineKeyboardMarkup([dates[i:i + 7] for i in range(0, len(dates), 7)])   

A switch or match statement with a function can be used (Can decouple the build calendar for loop).

Could work on it later imo, some other parts of the codebase need to be refactored. Rn lets focus on how to present everything if functionality is there

achintya-7 commented 11 months ago

Looks perfect to me. Just add this to util. Let's keep the telegram-handler a bit clear and to the point.

SudoSu-bham commented 11 months ago

@Maniktherana We can add point 1 and 2 so that it look nice if someone is fetching the schedule using calendar. I will try to make calendar look more appealing.

Maniktherana commented 11 months ago

@Maniktherana We can add point 1 and 2 so that it look nice if someone is fetching the schedule using calendar. I will try to make calendar look more appealing.

Sounds good, just try to format dates like Mon, 25 Oct wherever possible

SudoSu-bham commented 11 months ago

The markup size of calendar has been increased and the output of class schedule message also looks good now. here is the image

Screenshot from 2023-10-25 22-46-36

Maniktherana commented 11 months ago

The showing schedule for text should come after the dots and might as well remove the class schedule text under the dots. Consider making a separate formatter or adding optional kwargs to the class schedule formatter.

Other than that looks fine.

SudoSu-bham commented 11 months ago

updated Screenshot from 2023-10-26 17-25-13

Maniktherana commented 11 months ago

looks good, remove draft when ready for review

SudoSu-bham commented 11 months ago

Updated the telegram_handler file moved everything to the util folder, Also the calendar output is changed. Also the calendar markup method is made faster by reducing the execution time to O(1), if the function is called repetitively.

New output

Screenshot from 2023-10-28 01-07-22