Match Type

Objects of type Match are usually returned by Botfather API methods. Matches describe where something has been found and how good the match is.

Match object instantiation

You can create your own matches, e.g. for custom match methods. An invalid match can be created by passing nothing to the match’s constructor; its score will be **-**1.0. To create a valid Match, one has to provide a Rect describing the match’s location and the match’s score. The match’s score tells how good the match is: 1.0 means the match matches the searched object 100%, and 0.0 means the match isn’t even valid. (1.0 = 100%, 0.5 = 50%, 0.35 = 35%).

  • var invalid_match = new Match();
  • var good_match = new Match(new Rect(40, 75, 100, 100), 0.97);

Match object methods


Match.getScore();

Returns the match’s score. The score describes how well the match matches what has been searched for. A score of 0.0 means the match matches the subject 0%, 0.42 means the match matches 42%, and 1.0 means the match matches 100%.

Match.setScore(new_score);

  • new_score (number): A float number between 0.0 (0%) and 1.0 (100%).

Sets the match’s score to new_score.

Match.getRect();

Returns where the match matches the object searched for.

Match.setRect(new_rect);

  • new_rect (Rect): The rect describing where the match matches the searched for object.

Sets the match’s location/rect to new_rect.

Match.isValid();

Returns true if the match’s score is greater than 0.0.