text
stringlengths
1
93.6k
write_int16(f, pos_x);
write_int16(f, pos_y);
cpos_y += h.max_height*scale
# read and paste into one big image
dst = Image.new("P", (h.max_width*scale, h.max_height*scale * 128))
attach_palette(dst, pal)
cpos_y = 0
for i in range(128):
name_png = "{}.{:03}.png".format(ff_name, i)
if os.path.exists(name_png):
src = Image.open(name_png)
dst.paste(
src.resize(
(src.size[0]*scale, src.size[1]*scale),
Image.NEAREST
),
(0, cpos_y)
)
cpos_y += h.max_height*scale
# write pixel data
write_uint32(f, 0x414d4141)
write_int16(f, dst.size[0])
write_int16(f, dst.size[1])
for y in range(dst.size[1]):
for x in range(dst.size[0]):
r,g,b,a = pal[dst.getpixel((x,y))]
write_uint8(f, g)
print(ff_name+'.ftb')
Appendix_1 = """
FTB File Format Specification
-----------------------------
File is in little endian encoding.
uint32_t file_id; // 'FTBF' 0x46425446
uint32_t version; // 1
uint32_t section_id; // 'HEAD' 0x44414548
int16_t height;
int16_t ascender;
int16_t descender;
uint32_t section_id; // 'GLYP' 0x50594c47
uint32_t nglyph;
struct {
uint32_t code; // less than 256 in version 1
int16_t bearing_x;
int16_t bearing_y;
int16_t advance;
int16_t width;
int16_t height;
int16_t pos_x;
int16_t pos_y;
} glyphs[nglyph];
uint32_t section_id; // 'AAMA' 0x414d4141
int16_t dim_x;
int16_t dim_y;
uint8_t aamask[dim_y * dim_x]; // row-major order (x y) -> (0 0) (1 0) (2 0) ...
"""
# <FILESEP>
import logging
import datetime
import telebot
from telebot_calendar import Calendar, CallbackData, RUSSIAN_LANGUAGE
from telebot.types import ReplyKeyboardRemove, CallbackQuery
API_TOKEN = "token"
logger = telebot.logger
telebot.logger.setLevel(logging.DEBUG)
bot = telebot.TeleBot(API_TOKEN)
# Creates a unique calendar
calendar = Calendar(language=RUSSIAN_LANGUAGE)
calendar_1_callback = CallbackData("calendar_1", "action", "year", "month", "day")
@bot.message_handler(commands=["start"])
def check_other_messages(message):
"""
Catches a message with the command "start" and sends the calendar
:param message:
:return:
"""
now = datetime.datetime.now() # Get the current date
bot.send_message(
message.chat.id,
"Selected date",
reply_markup=calendar.create_calendar(
name=calendar_1_callback.prefix,