text
stringlengths
1
93.6k
year=now.year,
month=now.month, # Specify the NAME of your calendar
),
)
@bot.callback_query_handler(
func=lambda call: call.data.startswith(calendar_1_callback.prefix)
)
def callback_inline(call: CallbackQuery):
"""
Обработка inline callback запросов
:param call:
:return:
"""
# At this point, we are sure that this calendar is ours. So we cut the line by the separator of our calendar
name, action, year, month, day = call.data.split(calendar_1_callback.sep)
# Processing the calendar. Get either the date or None if the buttons are of a different type
date = calendar.calendar_query_handler(
bot=bot, call=call, name=name, action=action, year=year, month=month, day=day
)
# There are additional steps. Let's say if the date DAY is selected, you can execute your code. I sent a message.
if action == "DAY":
bot.send_message(
chat_id=call.from_user.id,
text=f"You have chosen {date.strftime('%d.%m.%Y')}",
reply_markup=ReplyKeyboardRemove(),
)
print(f"{calendar_1_callback}: Day: {date.strftime('%d.%m.%Y')}")
elif action == "CANCEL":
bot.send_message(
chat_id=call.from_user.id,
text="Cancellation",
reply_markup=ReplyKeyboardRemove(),
)
print(f"{calendar_1_callback}: Cancellation")
bot.polling(none_stop=True)
# <FILESEP>
# Simple CircuitPython Pi Pico webserver using ESP32 WiFi
#
# For detailed description, see https://iosoft.blog
#
# Copyright (c) 2021 Jeremy P Bentham
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# v0.02 JPB 25/9/21 Tidied up for release
import os, time, board, busio
from digitalio import DigitalInOut
from analogio import AnalogIn
from adafruit_esp32spi import adafruit_esp32spi
import adafruit_esp32spi.adafruit_esp32spi_socket as socket
WIFI_SSID = "testnet"
WIFI_PASS = "testpass"
ADC_PINS = board.A0, board.A1, board.A2
ADC_SCALE = 3.3 / 65536
esp32_cs = DigitalInOut(board.GP7)
esp32_ready = DigitalInOut(board.GP10)
esp32_reset = DigitalInOut(board.GP11)
DIRECTORY = "/"
INDEX_FNAME = "index.html"
TEST_FNAME = "test.html"
DATA_FNAME = "data.csv"
ICON_FNAME = "favicon.ico"
HTTP_PORT = 80
MAX_SPI_DLEN = 128
NO_SOCKET = 255
HTTP_OK = "HTTP/1.1 200 OK\r\n"
CONTENT_LEN = "Content-Length: %u\r\n"
CONTENT_TYPE = "Content-type %s\r\n"
TEST_PAGE = '''<!DOCTYPE html><html>
<head><style>table, th, td {border: 1px solid black; margin: 5px;}</style></head>
<body><h2>Pi Pico web server</h2>%s</body></html>'''
NOT_FOUND = 'HTTP/1.1 404 Not found\r\nContent-Length: 13\r\n\r\n404 Not Found'
DISABLE_CACHE = "Cache-Control: no-cache, no-store, must-revalidate\r\n"
DISABLE_CACHE += "Pragma: no-cache\r\nExpires: 0\r\n"
HEAD_END = "\r\n"
# Wifi status (firmware getConnStatus): see nina-fw/arduino/libraries/WiFi/src/Wifi.h
status_strs = {0:"idle", 1:"connecting", 2:"scan complete", 3:"connected", 4:"connect failed",