Exemplo n.º 1
0
 def toggle_dev(self):
     if not check_permissions(self.chat, self.user, 'can_restrict_members'):
         return
     self.group_settings.dev_mode = not self.group_settings.dev_mode
     self.group_settings.save()
     self.message.reply_text(
         f'Dev mode {"on" if self.group_settings.dev_mode else "off"}')
Exemplo n.º 2
0
    def _ban(self, user: UserSettings):
        if check_permissions(self.chat, user.user, 'can_restrict_members'):
            return False

        if self.group_settings.dev_mode:
            return
        self.chat.kick_member(user.user_id, until_date=1)
Exemplo n.º 3
0
    def _kick(self, user: UserSettings, delta: timedelta = None):
        if check_permissions(self.chat, user.user, 'can_restrict_members'):
            return False

        if self.group_settings.dev_mode:
            return

        until = datetime.now() + (delta if delta else timedelta(minutes=1))
        self.chat.kick_member(user.user_id, until_date=until)
Exemplo n.º 4
0
    def _warn(self, user: UserSettings, count: int = None) -> bool or Warning:
        if check_permissions(self.chat, user.user, 'can_restrict_members'):
            return False

        warning = user.warnings.get_or_create(user=user,
                                              group=self.group_settings)[0]

        if count is not None:
            warning.count = count
        else:
            warning.count += 1

        if self.group_settings.dev_mode:
            return warning

        warning.save()
        return warning
Exemplo n.º 5
0
 def filter(self, message: Message) -> bool:
     return check_permissions(message.chat, message.from_user, permission)