Advertisement
kopyl

Untitled

Apr 8th, 2021
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. class State(MessageFilter):
  2.  
  3.     data_filter = True
  4.  
  5.     def __init__(self, required_state):
  6.         self.required_state = required_state
  7.  
  8.     def get_user_state(self, message):
  9.         user_id = message.chat_id
  10.         user = User(user_id)
  11.         state = user.get_state()
  12.         self.user = user
  13.         self.state = state
  14.  
  15.     def filter(self, message):
  16.         self.get_user_state(message)
  17.         if self.state == self.required_state:
  18.             context_attributes = {
  19.                 "user": [self.user],
  20.                 "state": [self.state]
  21.             }
  22.             return context_attributes
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement