unmonoqueteclea/calendar-telegram
关于
A simple inline calendar for Telegram bots
效率与自动化实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文Date Selection tool for Telegram Bots
A simple inline calendar for Telegram bots written in Python using python-telegram-bot. Based on calendar-telegram.
Description
The file telegramcalendar.py proved the API to create an inline keyboard for a Telegram Bot. The user can either select a date or move to the next or previous month by clicking a singe button.
Internals
The file telegramcalendar.py provides the user with two methods:
- create_calendar: This method returns a InlineKeyboardMarkup object with the calendar in the provided year and month.
- process_calendar_selection: This method can be used inside a CallbackQueryHandler method to check if the user has selected a date or wants to move to a different month. It also creates a new calendar with the same text if necessary.
Usage
To use the telecram-calendar-keyboard you need to have python-telegram-bot installed first. A full working example on how to use telegram-calendar-keyboard is provided in bot_example.py. As you can see below, you create a calendar and add it to a message with a reply_markup parameter and then you can process it in a callbackqueyhandler method using the process_calendar_selection method:
def calendar_handler(bot,update):
update.message.reply_text("Please select a date: ",
reply_markup=telegramcalendar.create_calendar())
def inline_handler(bot,update):
selected,date = telegramcalendar.process_calendar_selection(bot, update)
if selected:
bot.send_message(chat_id=update.callback_query.from_user.id,
text="You selected %s" % (date.strftime("%d/%m/%Y")),
reply_markup=ReplyKeyboardRemove())
For a more complex example please check out renfe-notifier-bot
Demo

探索相关项目
加载中…