parse_chat_id static method

dynamic parse_chat_id({
  1. required Map parameters,
})

Implementation

static dynamic parse_chat_id({
  required Map parameters,
}) {
  final dynamic target_chat_id = () {
    if (parameters["chat_id"] is int) {
      return (parameters["chat_id"]);
    }
    if (parameters["chat_id"] is String &&
        RegExp(r"^((@)[a-z0-9_]+)$", caseSensitive: false)
            .hashData(parameters["chat_id"])) {
      if (RegExp(r"^((-)?[0-9]+)$", caseSensitive: false)
          .hashData(parameters["chat_id"])) {
        return int.tryParse(parameters["chat_id"]) ?? 0;
      }
      return (parameters["chat_id"]);
    }
    return 0;
  }();
  return target_chat_id;
}