Advertisement
Olegos

Send message

Jan 12th, 2021
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.02 KB | None | 0 0
  1. def send_message(message='', peer_id=None, keyboard=None, attachment=None, user_id=None, peer_ids=None, sticker_id=None, payload=None):
  2.     message = str(message)
  3.     if len(message) > 4096:
  4.         result = []
  5.         for i in range(0, len(message), 4096):
  6.             result.append(
  7.                 send_message(
  8.                     message=message[i: i + 4096],
  9.                     peer_id=peer_id,
  10.                     peer_ids=peer_ids,
  11.                     user_id=user_id,
  12.                     attachment=attachment,
  13.                     sticker_id=sticker_id,
  14.                     payload=payload,
  15.                     keyboard=keyboard,
  16.                 )
  17.             )
  18.         return True
  19.     return call.messages.send(
  20.         sticker_id=sticker_id,
  21.         user_id=user_id,
  22.         peer_id=peer_id,
  23.         peer_ids=peer_ids,
  24.         attachment=attachment,
  25.         message=message,
  26.         random_id=0,
  27.         payload=payload,
  28.         keyboard=json.dumps(keyboard) if keyboard is not None else None
  29.     )
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement