import { Context } from "grammy";
import { UserModel } from "../models/User";

export function saveUser(ctx: Context) {
  if (!ctx.from) return;
  const { id, username, first_name, last_name } = ctx.from;
  try {
    UserModel.upsert({
      telegramId: id,
      username,
      firstName: first_name,
      lastName: last_name,
    });
  } catch (_) {}
}
